Gl_Shader_compiler: Correct Depth Compare for Texture Gather operations.

This commit is contained in:
Fernando Sahmkow 2019-12-11 16:10:12 -04:00 committed by FernandoS27
parent 271a3264f3
commit 84a158c977
1 changed files with 21 additions and 8 deletions

View File

@ -1076,7 +1076,7 @@ private:
} }
std::string GenerateTexture(Operation operation, const std::string& function_suffix, std::string GenerateTexture(Operation operation, const std::string& function_suffix,
const std::vector<TextureIR>& extras) { const std::vector<TextureIR>& extras, bool sepparate_dc = false) {
constexpr std::array coord_constructors = {"float", "vec2", "vec3", "vec4"}; constexpr std::array coord_constructors = {"float", "vec2", "vec3", "vec4"};
const auto meta = std::get_if<MetaTexture>(&operation.GetMeta()); const auto meta = std::get_if<MetaTexture>(&operation.GetMeta());
@ -1091,7 +1091,7 @@ private:
expr += "Offset"; expr += "Offset";
} }
expr += '(' + GetSampler(meta->sampler) + ", "; expr += '(' + GetSampler(meta->sampler) + ", ";
expr += coord_constructors.at(count + (has_array ? 1 : 0) + (has_shadow ? 1 : 0) - 1); expr += coord_constructors.at(count + (has_array ? 1 : 0) + (has_shadow && !sepparate_dc ? 1 : 0) - 1);
expr += '('; expr += '(';
for (std::size_t i = 0; i < count; ++i) { for (std::size_t i = 0; i < count; ++i) {
expr += Visit(operation[i]).AsFloat(); expr += Visit(operation[i]).AsFloat();
@ -1104,9 +1104,14 @@ private:
expr += ", float(" + Visit(meta->array).AsInt() + ')'; expr += ", float(" + Visit(meta->array).AsInt() + ')';
} }
if (has_shadow) { if (has_shadow) {
expr += ", " + Visit(meta->depth_compare).AsFloat(); if (sepparate_dc) {
expr += "), " + Visit(meta->depth_compare).AsFloat();
} else {
expr += ", " + Visit(meta->depth_compare).AsFloat() + ')';
} }
} else {
expr += ')'; expr += ')';
}
for (const auto& variant : extras) { for (const auto& variant : extras) {
if (const auto argument = std::get_if<TextureArgument>(&variant)) { if (const auto argument = std::get_if<TextureArgument>(&variant)) {
@ -1706,10 +1711,18 @@ private:
ASSERT(meta); ASSERT(meta);
const auto type = meta->sampler.IsShadow() ? Type::Float : Type::Int; const auto type = meta->sampler.IsShadow() ? Type::Float : Type::Int;
if (meta->sampler.IsShadow()) {
return {GenerateTexture(operation, "Gather", return {GenerateTexture(operation, "Gather",
{TextureAoffi{}, TextureArgument{type, meta->component}}) + {TextureAoffi{}}, true) +
GetSwizzle(meta->element), GetSwizzle(meta->element),
Type::Float}; Type::Float};
} else {
return {GenerateTexture(operation, "Gather",
{TextureAoffi{}, TextureArgument{type, meta->component}},
true) +
GetSwizzle(meta->element),
Type::Float};
}
} }
Expression TextureQueryDimensions(Operation operation) { Expression TextureQueryDimensions(Operation operation) {