GLSL: fix textureSampleLevel() on depth textures.

Multiple bugs here:

1) Like texture(), GLSL's textureLod() on depth textures returns a
   scalar, and does not need to be swizzled. So set glsl_ret_width to
   1 in that case.
2) Like texture(), GLSL's textureLod() always requires a Dref
   parameter, so append a zero if not present.
3) GLSL's "lod" parameter to textureLod() is always a float, unlike
   WGSL's textureSampleLevel() which is an i32 for depth textures,
   so cast it.

Along the way, I discovered that textureLod() is not supported on
samplerCubeShadow or sampler2DArrayShadow (even on Desktop GL). So some
tests will never pass. Logged as https://crbug.com/dawn/1313

Bug: tint:1456
Change-Id: If67d8d288704142278d7a4e52b46e8010776f381
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/82300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Stephen White
2022-03-02 14:01:00 +00:00
committed by Tint LUCI CQ
parent 4acf466ff9
commit 17601930e4
12 changed files with 42 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
SKIP: FAILED
../../src/tint/writer/glsl/generator_impl.cc:2553 internal compiler error: Multiplanar external texture transform was not run.
../../src/tint/writer/glsl/generator_impl.cc:2563 internal compiler error: Multiplanar external texture transform was not run.
********************************************************************

View File

@@ -1,6 +1,6 @@
SKIP: FAILED
../../src/tint/writer/glsl/generator_impl.cc:2553 internal compiler error: Multiplanar external texture transform was not run.
../../src/tint/writer/glsl/generator_impl.cc:2563 internal compiler error: Multiplanar external texture transform was not run.
********************************************************************

View File

@@ -1,11 +1,9 @@
SKIP: FAILED
#version 310 es
uniform highp sampler2DShadow arg_0_arg_1;
void textureSampleLevel_02be59() {
float res = textureLod(arg_0_arg_1, vec2(0.0f, 0.0f), 0).x;
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), float(0));
}
vec4 vertex_main() {
@@ -20,20 +18,13 @@ void main() {
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
Error parsing GLSL shader:
ERROR: 0:6: 'textureLod' : no matching overloaded function found
ERROR: 0:6: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
#version 310 es
precision mediump float;
uniform highp sampler2DShadow arg_0_arg_1;
void textureSampleLevel_02be59() {
float res = textureLod(arg_0_arg_1, vec2(0.0f, 0.0f), 0).x;
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), float(0));
}
void fragment_main() {
@@ -44,19 +35,12 @@ void main() {
fragment_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:7: 'textureLod' : no matching overloaded function found
ERROR: 0:7: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
#version 310 es
uniform highp sampler2DShadow arg_0_arg_1;
void textureSampleLevel_02be59() {
float res = textureLod(arg_0_arg_1, vec2(0.0f, 0.0f), 0).x;
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), float(0));
}
void compute_main() {
@@ -68,10 +52,3 @@ void main() {
compute_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:6: 'textureLod' : no matching overloaded function found
ERROR: 0:6: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@@ -5,7 +5,7 @@ SKIP: FAILED
uniform highp samplerCubeShadow arg_0_arg_1;
void textureSampleLevel_1b0291() {
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, 0.0f), float(0));
}
vec4 vertex_main() {
@@ -33,7 +33,7 @@ precision mediump float;
uniform highp samplerCubeShadow arg_0_arg_1;
void textureSampleLevel_1b0291() {
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, 0.0f), float(0));
}
void fragment_main() {
@@ -56,7 +56,7 @@ ERROR: 2 compilation errors. No code generated.
uniform highp samplerCubeShadow arg_0_arg_1;
void textureSampleLevel_1b0291() {
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, 0.0f), float(0));
}
void compute_main() {

View File

@@ -5,7 +5,7 @@ SKIP: FAILED
uniform highp sampler2DArrayShadow arg_0_arg_1;
void textureSampleLevel_1bf73e() {
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, float(1)), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, float(1), 0.0f), float(0));
}
vec4 vertex_main() {
@@ -33,7 +33,7 @@ precision mediump float;
uniform highp sampler2DArrayShadow arg_0_arg_1;
void textureSampleLevel_1bf73e() {
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, float(1)), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, float(1), 0.0f), float(0));
}
void fragment_main() {
@@ -56,7 +56,7 @@ ERROR: 2 compilation errors. No code generated.
uniform highp sampler2DArrayShadow arg_0_arg_1;
void textureSampleLevel_1bf73e() {
float res = textureLod(arg_0_arg_1, vec3(0.0f, 0.0f, float(1)), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, float(1), 0.0f), float(0));
}
void compute_main() {

View File

@@ -1,11 +1,9 @@
SKIP: FAILED
#version 310 es
uniform highp sampler2DShadow arg_0_arg_1;
void textureSampleLevel_47daa4() {
float res = textureLodOffset(arg_0_arg_1, vec2(0.0f, 0.0f), 0, ivec2(0, 0)).x;
float res = textureLodOffset(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), float(0), ivec2(0, 0));
}
vec4 vertex_main() {
@@ -20,20 +18,13 @@ void main() {
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
return;
}
Error parsing GLSL shader:
ERROR: 0:6: 'textureLodOffset' : no matching overloaded function found
ERROR: 0:6: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
#version 310 es
precision mediump float;
uniform highp sampler2DShadow arg_0_arg_1;
void textureSampleLevel_47daa4() {
float res = textureLodOffset(arg_0_arg_1, vec2(0.0f, 0.0f), 0, ivec2(0, 0)).x;
float res = textureLodOffset(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), float(0), ivec2(0, 0));
}
void fragment_main() {
@@ -44,19 +35,12 @@ void main() {
fragment_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:7: 'textureLodOffset' : no matching overloaded function found
ERROR: 0:7: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
#version 310 es
uniform highp sampler2DShadow arg_0_arg_1;
void textureSampleLevel_47daa4() {
float res = textureLodOffset(arg_0_arg_1, vec2(0.0f, 0.0f), 0, ivec2(0, 0)).x;
float res = textureLodOffset(arg_0_arg_1, vec3(0.0f, 0.0f, 0.0f), float(0), ivec2(0, 0));
}
void compute_main() {
@@ -68,10 +52,3 @@ void main() {
compute_main();
return;
}
Error parsing GLSL shader:
ERROR: 0:6: 'textureLodOffset' : no matching overloaded function found
ERROR: 0:6: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

View File

@@ -1,6 +1,6 @@
SKIP: FAILED
../../src/tint/writer/glsl/generator_impl.cc:2553 internal compiler error: Multiplanar external texture transform was not run.
../../src/tint/writer/glsl/generator_impl.cc:2563 internal compiler error: Multiplanar external texture transform was not run.
********************************************************************

View File

@@ -5,7 +5,7 @@ SKIP: FAILED
uniform highp samplerCubeArrayShadow arg_0_arg_1;
void textureSampleLevel_ae5e39() {
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, float(1)), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, float(1)), float(0));
}
vec4 vertex_main() {
@@ -33,7 +33,7 @@ precision mediump float;
uniform highp samplerCubeArrayShadow arg_0_arg_1;
void textureSampleLevel_ae5e39() {
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, float(1)), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, float(1)), float(0));
}
void fragment_main() {
@@ -56,7 +56,7 @@ ERROR: 2 compilation errors. No code generated.
uniform highp samplerCubeArrayShadow arg_0_arg_1;
void textureSampleLevel_ae5e39() {
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, float(1)), 0).x;
float res = textureLod(arg_0_arg_1, vec4(0.0f, 0.0f, 0.0f, float(1)), float(0));
}
void compute_main() {

View File

@@ -5,7 +5,7 @@ SKIP: FAILED
uniform highp sampler2DArrayShadow arg_0_arg_1;
void textureSampleLevel_ba93b3() {
float res = textureLodOffset(arg_0_arg_1, vec3(0.0f, 0.0f, float(1)), 0, ivec2(0, 0)).x;
float res = textureLodOffset(arg_0_arg_1, vec4(0.0f, 0.0f, float(1), 0.0f), float(0), ivec2(0, 0));
}
vec4 vertex_main() {
@@ -33,7 +33,7 @@ precision mediump float;
uniform highp sampler2DArrayShadow arg_0_arg_1;
void textureSampleLevel_ba93b3() {
float res = textureLodOffset(arg_0_arg_1, vec3(0.0f, 0.0f, float(1)), 0, ivec2(0, 0)).x;
float res = textureLodOffset(arg_0_arg_1, vec4(0.0f, 0.0f, float(1), 0.0f), float(0), ivec2(0, 0));
}
void fragment_main() {
@@ -56,7 +56,7 @@ ERROR: 2 compilation errors. No code generated.
uniform highp sampler2DArrayShadow arg_0_arg_1;
void textureSampleLevel_ba93b3() {
float res = textureLodOffset(arg_0_arg_1, vec3(0.0f, 0.0f, float(1)), 0, ivec2(0, 0)).x;
float res = textureLodOffset(arg_0_arg_1, vec4(0.0f, 0.0f, float(1), 0.0f), float(0), ivec2(0, 0));
}
void compute_main() {

View File

@@ -1,5 +1,3 @@
SKIP: FAILED
#version 310 es
precision mediump float;
@@ -23,7 +21,7 @@ void main_1() {
vec2 coords12 = vf12;
vec3 coords123 = vf123;
vec4 coords1234 = vf1234;
vec4 x_79 = vec4(textureLod(x_20_x_10, vf12, int(f1)).x, 0.0f, 0.0f, 0.0f);
vec4 x_79 = vec4(textureLod(x_20_x_10, vec3(vf12, 0.0f), float(int(f1))), 0.0f, 0.0f, 0.0f);
return;
}
@@ -35,10 +33,3 @@ void main() {
tint_symbol();
return;
}
Error parsing GLSL shader:
ERROR: 0:24: 'textureLod' : no matching overloaded function found
ERROR: 0:24: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.