Commit e8e4debc by Olli Etuaho

Fix invalid generated sampling functions in HLSL output

In some generated shaders, "levels" would be read before it is assigned by GetDimensions when clamping mip level to valid range. Fix these cases. BUG=angleproject:1092 TEST=dEQP-GLES3.functional.shaders.texture_functions.* (12 tests start passing) Change-Id: I9fce8d378606738e5172673d222bce7968e26789 Reviewed-on: https://chromium-review.googlesource.com/312022 Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarOlli Etuaho <oetuaho@nvidia.com>
parent 3e960463
...@@ -924,11 +924,12 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator) ...@@ -924,11 +924,12 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator)
} }
else else
{ {
out << " x.GetDimensions(0, width, height, layers, levels);\n";
if (textureFunction->method == TextureFunction::IMPLICIT || if (textureFunction->method == TextureFunction::IMPLICIT ||
textureFunction->method == TextureFunction::BIAS) textureFunction->method == TextureFunction::BIAS)
{ {
out << " x.GetDimensions(0, width, height, layers, levels);\n" out << " float2 tSized = float2(t.x * width, t.y * height);\n"
" float2 tSized = float2(t.x * width, t.y * height);\n"
" float dx = length(ddx(tSized));\n" " float dx = length(ddx(tSized));\n"
" float dy = length(ddy(tSized));\n" " float dy = length(ddy(tSized));\n"
" float lod = log2(max(dx, dy));\n"; " float lod = log2(max(dx, dy));\n";
...@@ -940,8 +941,7 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator) ...@@ -940,8 +941,7 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator)
} }
else if (textureFunction->method == TextureFunction::GRAD) else if (textureFunction->method == TextureFunction::GRAD)
{ {
out << " x.GetDimensions(0, width, height, layers, levels);\n" out << " float lod = log2(max(length(ddx), length(ddy)));\n";
" float lod = log2(max(length(ddx), length(ddy)));\n";
} }
out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n";
...@@ -963,11 +963,12 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator) ...@@ -963,11 +963,12 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator)
} }
else else
{ {
out << " x.GetDimensions(0, width, height, levels);\n";
if (textureFunction->method == TextureFunction::IMPLICIT || if (textureFunction->method == TextureFunction::IMPLICIT ||
textureFunction->method == TextureFunction::BIAS) textureFunction->method == TextureFunction::BIAS)
{ {
out << " x.GetDimensions(0, width, height, levels);\n" out << " float2 tSized = float2(t.x * width, t.y * height);\n"
" float2 tSized = float2(t.x * width, t.y * height);\n"
" float dx = length(ddx(tSized));\n" " float dx = length(ddx(tSized));\n"
" float dy = length(ddy(tSized));\n" " float dy = length(ddy(tSized));\n"
" float lod = log2(max(dx, dy));\n"; " float lod = log2(max(dx, dy));\n";
...@@ -977,14 +978,9 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator) ...@@ -977,14 +978,9 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator)
out << " lod += bias;\n"; out << " lod += bias;\n";
} }
} }
else if (textureFunction->method == TextureFunction::LOD)
{
out << " x.GetDimensions(0, width, height, levels);\n";
}
else if (textureFunction->method == TextureFunction::GRAD) else if (textureFunction->method == TextureFunction::GRAD)
{ {
out << " x.GetDimensions(0, width, height, levels);\n" out << " float lod = log2(max(length(ddx), length(ddy)));\n";
" float lod = log2(max(length(ddx), length(ddy)));\n";
} }
out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n";
...@@ -1007,11 +1003,13 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator) ...@@ -1007,11 +1003,13 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator)
} }
else else
{ {
out << " x.GetDimensions(0, width, height, depth, levels);\n";
if (textureFunction->method == TextureFunction::IMPLICIT || if (textureFunction->method == TextureFunction::IMPLICIT ||
textureFunction->method == TextureFunction::BIAS) textureFunction->method == TextureFunction::BIAS)
{ {
out << " x.GetDimensions(0, width, height, depth, levels);\n" out << " float3 tSized = float3(t.x * width, t.y * height, t.z * "
" float3 tSized = float3(t.x * width, t.y * height, t.z * depth);\n" "depth);\n"
" float dx = length(ddx(tSized));\n" " float dx = length(ddx(tSized));\n"
" float dy = length(ddy(tSized));\n" " float dy = length(ddy(tSized));\n"
" float lod = log2(max(dx, dy));\n"; " float lod = log2(max(dx, dy));\n";
...@@ -1023,8 +1021,7 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator) ...@@ -1023,8 +1021,7 @@ void OutputHLSL::header(const BuiltInFunctionEmulator *builtInFunctionEmulator)
} }
else if (textureFunction->method == TextureFunction::GRAD) else if (textureFunction->method == TextureFunction::GRAD)
{ {
out << " x.GetDimensions(0, width, height, depth, levels);\n" out << " float lod = log2(max(length(ddx), length(ddy)));\n";
" float lod = log2(max(length(ddx), length(ddy)));\n";
} }
out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n"; out << " uint mip = uint(min(max(round(lod), 0), levels - 1));\n";
......
...@@ -75,10 +75,6 @@ ...@@ -75,10 +75,6 @@
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojoffset.sampler3d_float_fragment = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojoffset.sampler3d_float_fragment = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.isamplercube_* = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.isamplercube_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.usamplercube_* = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.usamplercube_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.isampler2darray_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.usampler2darray_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.isampler3d_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.usampler3d_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.sampler2dshadow_* = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelod.sampler2dshadow_* = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.isampler2d_vertex = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.isampler2d_vertex = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.isampler2d_fragment = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.isampler2d_fragment = FAIL
...@@ -94,10 +90,6 @@ ...@@ -94,10 +90,6 @@
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.usampler3d_fragment = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.usampler3d_fragment = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.sampler2dshadow_vertex = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.sampler2dshadow_vertex = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.sampler2dshadow_fragment = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.texturelodoffset.sampler2dshadow_fragment = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.isampler3d_vertex = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.isampler3d_fragment = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.usampler3d_vertex = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.usampler3d_fragment = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.sampler2dshadow_vertex = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.sampler2dshadow_vertex = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.sampler2dshadow_fragment = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlod.sampler2dshadow_fragment = FAIL
1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlodoffset.isampler2d_vec3_vertex = FAIL 1092 WIN : dEQP-GLES3.functional.shaders.texture_functions.textureprojlodoffset.isampler2d_vec3_vertex = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment