This is the first part of !608, which I decided to separate to ease review.
It consists of improvements to SM1 testing, mainly: - Correctly passing int and bool uniforms as IEEE 754 floats to SM1 profiles. - The introduction of the "only" qualifier to avoid abusing `[require]` blocks in case tests retrieve different results for different shader models. - Allowing some of the tests we already have for SM4/SM6 to run in SM1 after those improvements.
-- v2: tests: Remove [require] directives for tests that use int and bool uniforms. tests/shader-runner: Introduce "if" qualifier. tests: Don't ignore SM1 on a non-const-indexing.shader_test test. tests/vkd3d-shader: Set uninitialized uniforms to zero.
From: Francisco Casas fcasas@codeweavers.com
Avoids a potential source of non-determinism. --- tests/shader_runner.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 6c5c1dba3..1969cce7a 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -540,9 +540,12 @@ static void set_resource(struct shader_runner *runner, struct resource *resource
static void set_uniforms(struct shader_runner *runner, size_t offset, size_t count, const void *uniforms) { + size_t initial_capacity = runner->uniform_capacity; + runner->uniform_count = align(max(runner->uniform_count, offset + count), 4); vkd3d_array_reserve((void **)&runner->uniforms, &runner->uniform_capacity, runner->uniform_count, sizeof(*runner->uniforms)); + memset(runner->uniforms + initial_capacity, 0, runner->uniform_capacity - initial_capacity); memcpy(runner->uniforms + offset, uniforms, count * sizeof(*runner->uniforms)); }
From: Francisco Casas fcasas@codeweavers.com
The previous [require] block makes us skip the test for SM4. --- tests/hlsl/non-const-indexing.shader_test | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tests/hlsl/non-const-indexing.shader_test b/tests/hlsl/non-const-indexing.shader_test index b0452148e..ba60367fe 100644 --- a/tests/hlsl/non-const-indexing.shader_test +++ b/tests/hlsl/non-const-indexing.shader_test @@ -216,7 +216,11 @@ draw quad probe all rgba (1, 5, 3, 4)
-[pixel shader] +[require] +% reset requirements + + +[pixel shader todo(sm<4)] uniform float4 f[4]; uniform uint4 u; uniform uint4 v;
From: Francisco Casas fcasas@codeweavers.com
When the "if" qualifier is added to a directive, the directive is skipped if the shader->minimum_shader_model is not included in the range.
This can be used on the "probe" directives for tests that have different expected results on different shader models, without having to resort to [require] blocks. --- tests/hlsl/arithmetic-int.shader_test | 8 ++--- tests/hlsl/duplicate-modifiers.shader_test | 7 ++-- .../initializer-implicit-array.shader_test | 9 ++--- tests/hlsl/initializer-numeric.shader_test | 6 ++-- tests/hlsl/non-const-indexing.shader_test | 36 +++---------------- tests/shader_runner.c | 36 +++++++++++++++++-- 6 files changed, 47 insertions(+), 55 deletions(-)
diff --git a/tests/hlsl/arithmetic-int.shader_test b/tests/hlsl/arithmetic-int.shader_test index 46b641811..7a64894d1 100644 --- a/tests/hlsl/arithmetic-int.shader_test +++ b/tests/hlsl/arithmetic-int.shader_test @@ -104,10 +104,9 @@ float4 main() : SV_TARGET draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
+ [require] shader model >= 4.0 -% dxcompiler performs this calculation on unsigned values and emits zero. -shader model < 6.0
[pixel shader] float4 main() : SV_TARGET @@ -120,10 +119,9 @@ float4 main() : SV_TARGET
[test] draw quad -probe all rgba (-2147483648.0, -2147483648.0, -2147483648.0, -2147483648.0) +if(sm<6) probe all rgba (-2147483648.0, -2147483648.0, -2147483648.0, -2147483648.0) +if(sm>=6) probe all rgba (0.0, 0.0, 0.0, 0.0)
-[require] -shader model >= 4.0
[pixel shader] float4 main() : sv_target diff --git a/tests/hlsl/duplicate-modifiers.shader_test b/tests/hlsl/duplicate-modifiers.shader_test index bf1d9c1b8..87f564952 100644 --- a/tests/hlsl/duplicate-modifiers.shader_test +++ b/tests/hlsl/duplicate-modifiers.shader_test @@ -1,7 +1,3 @@ -% Returns (0.1, 0.3, 0.2, 0.4) with dxcompiler -[require] -shader model < 6.0 - [pixel shader] typedef const precise row_major float2x2 mat_t; float4 main() : sv_target @@ -12,4 +8,5 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (0.1, 0.2, 0.3, 0.4) +if(sm<6) probe all rgba (0.1, 0.2, 0.3, 0.4) +if(sm>=6) probe all rgba (0.1, 0.3, 0.2, 0.4) diff --git a/tests/hlsl/initializer-implicit-array.shader_test b/tests/hlsl/initializer-implicit-array.shader_test index 25cd15644..e11825996 100644 --- a/tests/hlsl/initializer-implicit-array.shader_test +++ b/tests/hlsl/initializer-implicit-array.shader_test @@ -11,10 +11,6 @@ draw quad probe all rgba (50, 60, 70, 80)
-% dxcompiler emits a nop shader which returns immediately. -[require] -shader model < 6.0 - [pixel shader] float4 main() : sv_target { @@ -26,10 +22,9 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (5.0, 6.0, 7.0, 8.0) +% dxcompiler emits a nop shader which returns immediately. +if(sm<6) probe all rgba (5.0, 6.0, 7.0, 8.0)
-[require] -% reset requirements
[pixel shader] float4 main() : sv_target diff --git a/tests/hlsl/initializer-numeric.shader_test b/tests/hlsl/initializer-numeric.shader_test index 617b67405..1b41dfb5a 100644 --- a/tests/hlsl/initializer-numeric.shader_test +++ b/tests/hlsl/initializer-numeric.shader_test @@ -60,9 +60,6 @@ draw quad probe all rgba (3.0, 250.0, 16.0, 4.2949673e+009) 4
-[require] -shader model < 6.0 - [pixel shader] float4 main() : sv_target { @@ -73,4 +70,5 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (-1294967296.0, 3000000000.0, 0.0, 0.0) 4 +if(sm<6) probe all rgba (-1294967296.0, 3000000000.0, 0.0, 0.0) 4 +if(sm>=6) probe all rgba (3000000000.0, 3000000000.0, 0.0, 0.0) 4 diff --git a/tests/hlsl/non-const-indexing.shader_test b/tests/hlsl/non-const-indexing.shader_test index ba60367fe..aed33092c 100644 --- a/tests/hlsl/non-const-indexing.shader_test +++ b/tests/hlsl/non-const-indexing.shader_test @@ -236,23 +236,6 @@ float4 main() : sv_target }
% FXC is incapable of compiling this correctly, but results differ for SM1-3 vs SM4-5. -[require] -shader model < 4.0 - -[test] -uniform 0 float 1.0 -uniform 4 float 2.0 -uniform 8 float 3.0 -uniform 12 float 4.0 -uniform 16 uint4 3 1 0 2 -uniform 20 uint4 0 3 1 2 -todo draw quad -todo(sm<4) probe all rgba (1.0, 1.0, 1.0, 1.0) - -[require] -shader model >= 4.0 -shader model < 6.0 - [test] uniform 0 float 1.0 uniform 4 float 2.0 @@ -260,18 +243,7 @@ uniform 8 float 3.0 uniform 12 float 4.0 uniform 16 uint4 3 1 0 2 uniform 20 uint4 0 3 1 2 -draw quad -todo probe all rgba (4.0, 4.0, 4.0, 4.0) - -[require] -shader model >= 6.0 - -[test] -uniform 0 float 1.0 -uniform 4 float 2.0 -uniform 8 float 3.0 -uniform 12 float 4.0 -uniform 16 uint4 3 1 0 2 -uniform 20 uint4 0 3 1 2 -draw quad -probe all rgba (4.0, 3.0, 2.0, 1.0) +todo(sm<4) draw quad +if(sm<4) todo probe all rgba (1.0, 1.0, 1.0, 1.0) +if(sm>=4 & sm<6) todo probe all rgba (4.0, 4.0, 4.0, 4.0) +if(sm>=6) probe all rgba (4.0, 3.0, 2.0, 1.0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 1969cce7a..d21465482 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -645,14 +645,46 @@ static void read_uint64_t2(const char **line, struct u64vec2 *v)
static void parse_test_directive(struct shader_runner *runner, const char *line) { + bool skip_directive = false; + const char *line_ini; + bool match = true; char *rest; int ret;
runner->is_todo = false;
- if (match_string_with_args(line, "todo", &line, runner->minimum_shader_model)) + while (match) { - runner->is_todo = true; + match = false; + + if (match_string_with_args(line, "todo", &line, runner->minimum_shader_model)) + { + runner->is_todo = true; + match = true; + } + + line_ini = line; + if (match_string_with_args(line, "if", &line, runner->minimum_shader_model)) + { + match = true; + } + else if (line != line_ini) + { + /* Matched "if" but for other shader models. */ + skip_directive = true; + match = true; + } + } + + if (skip_directive) + { + const char *new_line; + + if ((new_line = strchr(line, '\n'))) + line = new_line + 1; + else + line += strlen(line); + return; }
if (match_string(line, "dispatch", &line))
From: Francisco Casas fcasas@codeweavers.com
These tests should actually compile and run in SM1, which is possible if we pass the int and uint uniforms in the expected IEEE 754 float format for SM1 shaders.
Also, bools should be passed as 1.0f or 0.0f to SM1. --- tests/hlsl/any.shader_test | 46 ++++---- tests/hlsl/bool-cast.shader_test | 18 ++- tests/hlsl/cast-to-float.shader_test | 21 ++-- tests/hlsl/cast-to-half.shader_test | 21 ++-- tests/hlsl/cast-to-int.shader_test | 24 ++-- tests/hlsl/cast-to-uint.shader_test | 4 +- tests/hlsl/ceil.shader_test | 10 +- tests/hlsl/floor.shader_test | 9 +- tests/hlsl/function-cast.shader_test | 7 +- tests/hlsl/ldexp.shader_test | 12 +- tests/hlsl/lerp.shader_test | 15 +-- tests/hlsl/sign.shader_test | 35 +++--- tests/hlsl/switch.shader_test | 165 ++++++++++++++++----------- tests/hlsl/trunc.shader_test | 9 +- 14 files changed, 220 insertions(+), 176 deletions(-)
diff --git a/tests/hlsl/any.shader_test b/tests/hlsl/any.shader_test index afaf81fac..83a1dad97 100644 --- a/tests/hlsl/any.shader_test +++ b/tests/hlsl/any.shader_test @@ -48,10 +48,8 @@ uniform 0 float4 -1.0 0.0 0.0 0.0 todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
-[require] -shader model >= 4.0
-[pixel shader] +[pixel shader todo(sm<4)] uniform uint4 b;
float4 main() : sv_target @@ -60,26 +58,32 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 1 1 1 1 -draw quad +if(sm<4) uniform 0 float4 1 1 1 1 +if(sm>=4) uniform 0 uint4 1 1 1 1 +todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) -uniform 0 uint4 1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) -uniform 0 uint4 0 1 0 0 -draw quad +if(sm<4) uniform 0 float4 0 1 0 0 +if(sm>=4) uniform 0 uint4 0 1 0 0 +todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) -uniform 0 uint4 0 0 1 0 -draw quad +if(sm<4) uniform 0 float4 0 0 1 0 +if(sm>=4) uniform 0 uint4 0 0 1 0 +todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) -uniform 0 uint4 0 0 0 1 -draw quad +if(sm<4) uniform 0 float4 0 0 0 1 +if(sm>=4) uniform 0 uint4 0 0 0 1 +todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) -uniform 0 uint4 0 0 0 0 -draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
-[pixel shader] +[pixel shader todo(sm<4)] uniform uint b;
float4 main() : sv_target @@ -88,9 +92,11 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0) -uniform 0 uint4 0 0 0 0 -draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0) diff --git a/tests/hlsl/bool-cast.shader_test b/tests/hlsl/bool-cast.shader_test index 09ca12e2b..f3e4cf0d6 100644 --- a/tests/hlsl/bool-cast.shader_test +++ b/tests/hlsl/bool-cast.shader_test @@ -14,11 +14,7 @@ draw quad probe all rgba (0.0, 0.0, 1.0, 1.0)
-[require] -shader model >= 4.0 - - -[pixel shader] +[pixel shader todo(sm<4)] uniform float4 x; uniform int4 y;
@@ -29,12 +25,13 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 0.0 0.0 2.0 4.0 -uniform 4 int4 0 1 0 10 -draw quad +if(sm<4) uniform 4 float4 0 1 0 10 +if(sm>=4) uniform 4 int4 0 1 0 10 +todo(sm<4) draw quad probe all rgba (0.0, 10.0, 1.0, 11.0)
-[pixel shader] +[pixel shader todo(sm<4)] uniform bool4 b;
float4 main() : sv_target @@ -43,6 +40,7 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 0x00000001 0x00000002 0x80000000 0x00000000 -draw quad +if(sm<4) uniform 0 float4 1.0 1.0 1.0 0.0 +if(sm>=4) uniform 0 uint4 0x00000001 0x00000002 0x80000000 0x00000000 +todo(sm<4) draw quad probe all rgba (2.0, 2.0, 2.0, 0.0) diff --git a/tests/hlsl/cast-to-float.shader_test b/tests/hlsl/cast-to-float.shader_test index caaf98c02..bcb546e2d 100644 --- a/tests/hlsl/cast-to-float.shader_test +++ b/tests/hlsl/cast-to-float.shader_test @@ -1,7 +1,4 @@ -[require] -shader model >= 4.0 - -[pixel shader] +[pixel shader todo(sm<4)] uniform int i; uniform uint u; uniform bool b; @@ -13,15 +10,19 @@ float4 main() : sv_target }
[test] -uniform 0 int -1 -uniform 1 uint 3 -uniform 2 int -2 -uniform 3 float 0.5 -draw quad +if(sm<4) uniform 0 float -1 +if(sm<4) uniform 4 float 3 +if(sm<4) uniform 8 float 1 +if(sm<4) uniform 12 float 0.5 +if(sm>=4) uniform 0 int -1 +if(sm>=4) uniform 1 uint 3 +if(sm>=4) uniform 2 int -2 +if(sm>=4) uniform 3 float 0.5 +todo(sm<4) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
-[pixel shader]
+[pixel shader] float4 main() : sv_target { int i = -1; diff --git a/tests/hlsl/cast-to-half.shader_test b/tests/hlsl/cast-to-half.shader_test index b8feb6760..0580fe25f 100644 --- a/tests/hlsl/cast-to-half.shader_test +++ b/tests/hlsl/cast-to-half.shader_test @@ -1,7 +1,4 @@ -[require] -shader model >= 4.0 - -[pixel shader] +[pixel shader todo(sm<4)] uniform int i; uniform uint u; uniform bool b; @@ -13,15 +10,19 @@ float4 main() : sv_target }
[test] -uniform 0 int -1 -uniform 1 uint 3 -uniform 2 int -2 -uniform 3 float 0.5 -draw quad +if(sm<4) uniform 0 float -1 +if(sm<4) uniform 4 float 3 +if(sm<4) uniform 8 float 1 +if(sm<4) uniform 12 float 0.5 +if(sm>=4) uniform 0 int -1 +if(sm>=4) uniform 1 uint 3 +if(sm>=4) uniform 2 int -2 +if(sm>=4) uniform 3 float 0.5 +todo(sm<4) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
-[pixel shader]
+[pixel shader] float4 main() : sv_target { int i = -1; diff --git a/tests/hlsl/cast-to-int.shader_test b/tests/hlsl/cast-to-int.shader_test index 3e850fb5b..385e3375f 100644 --- a/tests/hlsl/cast-to-int.shader_test +++ b/tests/hlsl/cast-to-int.shader_test @@ -1,7 +1,4 @@ -[require] -shader model >= 4.0 - -[pixel shader] +[pixel shader todo(sm<4)] uniform float f; uniform uint u; uniform bool b; @@ -19,15 +16,19 @@ float4 main() : sv_target }
[test] -uniform 0 float 2.6 -uniform 1 int -2 -uniform 2 int -2 -uniform 3 float -3.6 -draw quad +if(sm<4) uniform 0 float 2.6 +if(sm<4) uniform 4 float -2 +if(sm<4) uniform 8 float 1.0 +if(sm<4) uniform 12 float -3.6 +if(sm>=4) uniform 0 float 2.6 +if(sm>=4) uniform 1 int -2 +if(sm>=4) uniform 2 int -2 +if(sm>=4) uniform 3 float -3.6 +todo(sm<4) draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
-[pixel shader]
+[pixel shader] float4 main() : sv_target { float f = 2.6; @@ -45,4 +46,5 @@ float4 main() : sv_target
[test] draw quad -probe all rgba (0.5, 0.5, 0.5, 0.5) +if(sm<4) todo probe all rgba (0.5, 4.2949673e+009, 0.5, 0.5) +if(sm>=4) probe all rgba (0.5, 0.5, 0.5, 0.5) diff --git a/tests/hlsl/cast-to-uint.shader_test b/tests/hlsl/cast-to-uint.shader_test index 07479984a..9344fffc8 100644 --- a/tests/hlsl/cast-to-uint.shader_test +++ b/tests/hlsl/cast-to-uint.shader_test @@ -1,6 +1,8 @@ +% On SM1, uints can only be used with known-positive values. [require] shader model >= 4.0
+ [pixel shader] uniform float f; uniform int i; @@ -26,8 +28,8 @@ uniform 3 float -3.6 draw quad probe all rgba (0.5, 0.5, 0.5, 0.5)
-[pixel shader]
+[pixel shader] float4 main() : sv_target { float f = 2.6; diff --git a/tests/hlsl/ceil.shader_test b/tests/hlsl/ceil.shader_test index 46414a92b..aa4bdf297 100644 --- a/tests/hlsl/ceil.shader_test +++ b/tests/hlsl/ceil.shader_test @@ -37,10 +37,7 @@ uniform 0 float4 -0.5 6.5 7.5 3.4 todo(sm<4) draw quad probe all rgba (7.0, 8.0, 0.0, 4.0) 4
-[require] -shader model >= 4.0 - -[pixel shader] +[pixel shader todo(sm<4)] uniform int4 u;
float4 main() : sv_target @@ -52,6 +49,7 @@ float4 main() : sv_target }
[test] -uniform 0 int4 -1 6 7 3 -draw quad +if(sm<4) uniform 0 float4 -1 6 7 3 +if(sm>=4) uniform 0 int4 -1 6 7 3 +todo(sm<4) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0) 4 diff --git a/tests/hlsl/floor.shader_test b/tests/hlsl/floor.shader_test index 89e1f12ef..ed1ab7688 100644 --- a/tests/hlsl/floor.shader_test +++ b/tests/hlsl/floor.shader_test @@ -37,10 +37,8 @@ uniform 0 float4 -0.5 6.5 7.5 3.4 todo(sm<4) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0) 4
-[require] -shader model >= 4.0
-[pixel shader] +[pixel shader todo(sm<4)] uniform int4 u;
float4 main() : sv_target @@ -52,6 +50,7 @@ float4 main() : sv_target }
[test] -uniform 0 int4 -1 6 7 3 -draw quad +if(sm<4) uniform 0 float4 -1 6 7 3 +if(sm>=4) uniform 0 int4 -1 6 7 3 +todo(sm<4) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0) 4 diff --git a/tests/hlsl/function-cast.shader_test b/tests/hlsl/function-cast.shader_test index c92289863..f049b79d1 100644 --- a/tests/hlsl/function-cast.shader_test +++ b/tests/hlsl/function-cast.shader_test @@ -69,8 +69,6 @@ uniform 0 float4 -1.9 -1.0 2.9 4.0 todo draw quad probe all rgba (-1.0, -1.0, 2.0, 4.0)
-[require] -shader model >= 4.0
[pixel shader todo] uniform int4 i; @@ -88,6 +86,7 @@ float4 main() : sv_target }
[test] -uniform 0 int4 -2 0 1 -3000000 +if(sm<4) uniform 0 float4 -2 0 1 -3000000 +if(sm>=4) uniform 0 int4 -2 0 1 -3000000 todo(sm<6) draw quad -probe all rgba (-1.0, 0.0, 1.0, -3000000.0) +probe all rgba (-1.0, 0.0, 1.0, -3000000.0) 4 diff --git a/tests/hlsl/ldexp.shader_test b/tests/hlsl/ldexp.shader_test index f8ad40d8e..2d778e077 100644 --- a/tests/hlsl/ldexp.shader_test +++ b/tests/hlsl/ldexp.shader_test @@ -13,10 +13,8 @@ uniform 4 float4 0.0 -10.0 10.0 100.0 draw quad probe all rgba (2.0, 0.00292968750, 4096.0, 6.33825300e+030) 2
-[require] -shader model >= 4.0
-[pixel shader] +[pixel shader todo(sm<4)] uniform int4 x; uniform int4 y;
@@ -26,9 +24,11 @@ float4 main() : SV_TARGET }
[test] -uniform 0 int4 2 3 4 5 -uniform 4 int4 0 -10 10 100 -draw quad +if(sm<4) uniform 0 float4 2 3 4 5 +if(sm<4) uniform 4 float4 0 -10 10 100 +if(sm>=4) uniform 0 int4 2 3 4 5 +if(sm>=4) uniform 4 int4 0 -10 10 100 +todo(sm<4) draw quad probe all rgba (2.0, 0.00292968750, 4096.0, 6.33825300e+030) 2
diff --git a/tests/hlsl/lerp.shader_test b/tests/hlsl/lerp.shader_test index 15e90cef9..901857dfd 100644 --- a/tests/hlsl/lerp.shader_test +++ b/tests/hlsl/lerp.shader_test @@ -15,10 +15,8 @@ uniform 8 float4 0.0 1.0 -1.0 0.75 draw quad probe all rgba (2.0, -10.0, -2.0, 76.25)
-[require] -shader model >= 4.0
-[pixel shader] +[pixel shader todo(sm<4)] uniform int4 x; uniform int4 y; uniform int4 s; @@ -29,10 +27,13 @@ float4 main() : SV_TARGET }
[test] -uniform 0 int4 2 3 4 0 -uniform 4 int4 0 -10 10 1000000 -uniform 8 int4 0 1 -1 1000000 -draw quad +if(sm<4) uniform 0 float4 2 3 4 0 +if(sm<4) uniform 4 float4 0 -10 10 1000000 +if(sm<4) uniform 8 float4 0 1 -1 1000000 +if(sm>=4) uniform 0 int4 2 3 4 0 +if(sm>=4) uniform 4 int4 0 -10 10 1000000 +if(sm>=4) uniform 8 int4 0 1 -1 1000000 +todo(sm<4) draw quad probe all rgba (2.0, -10.0, -2.0, 1e12)
diff --git a/tests/hlsl/sign.shader_test b/tests/hlsl/sign.shader_test index 6ec5a571d..5d1c18486 100644 --- a/tests/hlsl/sign.shader_test +++ b/tests/hlsl/sign.shader_test @@ -17,6 +17,7 @@ uniform 0 float4 0.0 0.0 0.0 0.0 todo(sm<4) draw quad probe all rgba (0.0, 0.0, 0.0, 0.0)
+ [pixel shader todo(sm<4)] uniform float4 f;
@@ -30,6 +31,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0 todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
+ [pixel shader todo(sm<4)] uniform float2x2 f;
@@ -44,9 +46,6 @@ uniform 4 float4 3.0 4.0 0.0 0.0 todo(sm<4) draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
-[require] -% SM1-3 doesn't support integral types -shader model >= 4.0
[pixel shader todo(sm<4)] uniform int f; @@ -57,16 +56,20 @@ float4 main() : sv_target }
[test] -uniform 0 int4 1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 int4 1 0 0 0 +todo(sm<4) draw quad probe all rgba (1, 1, 1, 1) -uniform 0 int4 -1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 -1 0 0 0 +if(sm>=4) uniform 0 int4 -1 0 0 0 +todo(sm<4) draw quad probe all rgba (-1, -1, -1, -1) -uniform 0 int4 0 0 0 0 -draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 int4 0 0 0 0 +todo(sm<4) draw quad probe all rgba (0, 0, 0, 0)
+ [pixel shader todo(sm<4)] uniform int4 f;
@@ -76,10 +79,12 @@ float4 main() : sv_target }
[test] -uniform 0 int4 1 2 3 4 -draw quad +if(sm<4) uniform 0 float4 1 2 3 4 +if(sm>=4) uniform 0 int4 1 2 3 4 +todo(sm<4) draw quad probe all rgba (1, 1, 1, 1)
+ [pixel shader todo(sm<4)] uniform int2x2 f;
@@ -89,7 +94,9 @@ float4 main() : sv_target }
[test] -uniform 0 int4 1 2 0 0 -uniform 4 int4 3 4 0 0 -draw quad +if(sm<4) uniform 0 float4 1 2 0 0 +if(sm<4) uniform 4 float4 3 4 0 0 +if(sm>=4) uniform 0 int4 1 2 0 0 +if(sm>=4) uniform 4 int4 3 4 0 0 +todo(sm<4) draw quad probe all rgba (1, 1, 1, 1) diff --git a/tests/hlsl/switch.shader_test b/tests/hlsl/switch.shader_test index 01624f97c..beed006df 100644 --- a/tests/hlsl/switch.shader_test +++ b/tests/hlsl/switch.shader_test @@ -1,7 +1,4 @@ -[require] -shader model >= 4.0 - -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -18,18 +15,22 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 3 0 0 0 -draw quad +if(sm<4) uniform 0 float4 3 0 0 0 +if(sm>=4) uniform 0 uint4 3 0 0 0 +todo(sm<4) draw quad probe all rgba (5.0, 5.0, 5.0, 5.0) -uniform 0 uint4 1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4) draw quad probe all rgba (4.0, 4.0, 4.0, 4.0) -uniform 0 uint4 0 0 0 0 -draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4) draw quad probe all rgba (3.0, 3.0, 3.0, 3.0)
+ % just a default case -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -42,16 +43,20 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 3 0 0 0 -draw quad +if(sm<4) uniform 0 float4 3 0 0 0 +if(sm>=4) uniform 0 uint4 3 0 0 0 +todo(sm<4) draw quad probe all rgba (5.0, 5.0, 5.0, 5.0) -uniform 0 uint4 1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4) draw quad probe all rgba (5.0, 5.0, 5.0, 5.0) -uniform 0 uint4 0 0 0 0 -draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4) draw quad probe all rgba (5.0, 5.0, 5.0, 5.0)
+ % completely empty [pixel shader fail] uint4 v; @@ -63,8 +68,9 @@ float4 main() : sv_target } }
+ % falling through is only supported for empty case statements -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -83,18 +89,22 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 2 0 0 0 -draw quad +if(sm<4) uniform 0 float4 2 0 0 0 +if(sm>=4) uniform 0 uint4 2 0 0 0 +todo(sm<4) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0) -uniform 0 uint4 1 0 0 0 -draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4) draw quad probe all rgba (1.1, 2.0, 3.0, 4.0) -uniform 0 uint4 0 0 0 0 -draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4) draw quad probe all rgba (1.1, 2.0, 3.0, 4.0)
+ % case value evaluation -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -115,15 +125,18 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 2 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 2 0 0 0 +if(sm>=4) uniform 0 uint4 2 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.1, 2.1, 3.1, 4.1) -uniform 0 uint4 1 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
+ % floats are accepted -[pixel shader fail(sm>=6)] +[pixel shader fail(sm>=6) todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -144,14 +157,16 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 2 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 2 0 0 0 +if(sm>=4) uniform 0 uint4 2 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.1, 2.1, 3.1, 4.1) -uniform 0 uint4 1 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
-[pixel shader fail(sm>=6)] +[pixel shader fail(sm<4 | sm>=6) todo(sm<4)] float4 v;
float4 main() : sv_target @@ -173,10 +188,10 @@ float4 main() : sv_target
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -todo(sm>=6) draw quad +todo(sm<4 | sm>=6) draw quad probe all rgba (1.1, 2.1, 3.1, 4.1) uniform 0 float4 1.0 0.0 0.0 0.0 -todo(sm>=6) draw quad +todo(sm<4 | sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader fail] @@ -347,7 +362,7 @@ float4 main() : sv_target }
% more complicated breaks -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -373,18 +388,21 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 2 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 2 0 0 0 +if(sm>=4) uniform 0 uint4 2 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.1, 2.1, 3.1, 4.1) -uniform 0 uint4 1 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 1 0 0 0 +if(sm>=4) uniform 0 uint4 1 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.2, 2.2, 3.2, 4.2) -uniform 0 uint4 0 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
% switch breaks within a loop -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -411,12 +429,14 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 2 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 2 0 0 0 +if(sm>=4) uniform 0 uint4 2 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (5.0, 6.0, 7.0, 8.0)
+ % default case placement -[pixel shader] +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -442,17 +462,21 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 0 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (4.0, 5.0, 6.0, 7.0) -uniform 0 uint4 2 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 2 0 0 0 +if(sm>=4) uniform 0 uint4 2 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (2.0, 3.0, 4.0, 5.0) -uniform 0 uint4 3 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 3 0 0 0 +if(sm>=4) uniform 0 uint4 3 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (4.0, 5.0, 6.0, 7.0)
-[pixel shader] + +[pixel shader todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -479,14 +503,17 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 3 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 3 0 0 0 +if(sm>=4) uniform 0 uint4 3 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0) -uniform 0 uint4 0 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 0 0 0 0 +if(sm>=4) uniform 0 uint4 0 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (4.0, 5.0, 6.0, 7.0) -uniform 0 uint4 5 0 0 0 -todo(sm>=6) draw quad +if(sm<4) uniform 0 float4 5 0 0 0 +if(sm>=4) uniform 0 uint4 5 0 0 0 +todo(sm<4 | sm>=6) draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
% 'continue' is not supported in switches @@ -515,7 +542,7 @@ float4 main() : sv_target return c; }
-[pixel shader] +[pixel shader fail(sm<4) todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -545,15 +572,17 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 0 0 3 1 +if(sm<4) uniform 0 float4 0 0 3 1 +if(sm>=4) uniform 0 uint4 0 0 3 1 todo(sm>=6) draw quad probe all rgba (10.0, 11.0, 12.0, 13.0) -uniform 0 uint4 1 0 3 1 +if(sm<4) uniform 0 float4 1 0 3 1 +if(sm>=4) uniform 0 uint4 1 0 3 1 todo(sm>=6) draw quad probe all rgba (7.0, 8.0, 9.0, 10.0)
% return from a switch nested in a loop -[pixel shader] +[pixel shader fail(sm<4) todo(sm<4)] uint4 v;
float4 main() : sv_target @@ -579,9 +608,11 @@ float4 main() : sv_target }
[test] -uniform 0 uint4 0 0 3 1 +if(sm<4) uniform 0 float4 0 0 3 1 +if(sm>=4) uniform 0 uint4 0 0 3 1 todo(sm>=6) draw quad probe all rgba (304.0, 305.0, 306.0, 307.0) -uniform 0 uint4 1 0 3 1 +if(sm<4) uniform 0 float4 1 0 3 1 +if(sm>=4) uniform 0 uint4 1 0 3 1 todo(sm>=6) draw quad probe all rgba (3.0, 4.0, 5.0, 6.0) diff --git a/tests/hlsl/trunc.shader_test b/tests/hlsl/trunc.shader_test index f1d23bf82..d57438641 100644 --- a/tests/hlsl/trunc.shader_test +++ b/tests/hlsl/trunc.shader_test @@ -30,10 +30,8 @@ uniform 0 float4 -0.5 6.5 7.5 3.4 todo(sm<4) draw quad probe all rgba (6.0, 7.0, 0.0, 3.0)
-[require] -shader model >= 4.0
-[pixel shader] +[pixel shader todo(sm<4)] uniform int4 u;
float4 main() : sv_target @@ -45,6 +43,7 @@ float4 main() : sv_target }
[test] -uniform 0 int4 -1 6 7 3 -draw quad +if(sm<4) uniform 0 float4 -1 6 7 3 +if(sm>=4) uniform 0 int4 -1 6 7 3 +todo(sm<4) draw quad probe all rgba (6.0, 7.0, -1.0, 3.0)
On Wed Jan 31 20:24:44 2024 +0000, Zebediah Figura wrote:
uniform has the whole register.``` We should just change the uniform layout then.
Since we will be passing ints using the "only" qualifier as Giovanni suggested, we can now just provide different offsets for the different shader models.
So something like this: ``` uniform 0 int -1 uniform 1 uint 3 uniform 2 int -2 uniform 3 float 0.5 ``` ends ups like this: ``` if(sm<4) uniform 0 float -1 if(sm<4) uniform 4 float 3 if(sm<4) uniform 8 float 1 if(sm<4) uniform 12 float 0.5 if(sm>=4) uniform 0 int -1 if(sm>=4) uniform 1 uint 3 if(sm>=4) uniform 2 int -2 if(sm>=4) uniform 3 float 0.5 ```
On Wed Jan 31 20:25:46 2024 +0000, Henri Verbeet wrote:
From 78ecef0ccf024fa728c952c13cf0c885c61b3a6f Mon Sep 17 00:00:00 2001 From: Francisco Casas <fcasas@codeweavers.com> Date: Mon, 29 Jan 2024 20:07:39 -0300 Subject: [PATCH 2/5] tests/shader-runner: Introduce "only" qualifier. When the "only" qualifier is added to a directive, the directive is skipped if the shader->minimum_shader_model is not included in the range. This can be used on the "probe" directives for tests that have different expected results on different shader models, without having to resort to [require] blocks.
I think most languages call that "if"? I.e.:
if(sm<6) probe ... if(sm>=6) probe ...
Not that I mind doing something different, but I suppose it might make things slightly harder to pick up for someone new to writing .shader_test's. Some possible alternatives:
probe(sm<6) ... probe(sm>=6) ...
cond (sm<6) probe ... (sm>=6) probe ...
Okay, I renamed the "only" qualifiers as "if". Hopefully we won't use these too enough to justify having to add conditional blocks.
I updated according to the suggestions.
There are two conflicting ideas of how to pass uniform values to the backend:
a) Allow the shader_runner to perform transformations of the input values according to the backend and the type provided (so it makes sense to add the "bool" type to the "uniform" directives)
b) Don't allow the shader_runner to perform these transformations, and instead pass the values as if they where binary data, needing the use of more "only" (now called "if") qualifiers.
The first version of this MR was doing (a) but the current one does (b). The disadvantage of (b) is that we have to add more "if" qualifiers, if you think these are too many I can revert to (a).
@@ -540,9 +540,12 @@ static void set_resource(struct shader_runner *runner, struct resource *resource static void set_uniforms(struct shader_runner *runner, size_t offset, size_t count, const void *uniforms) { + size_t initial_capacity = runner->uniform_capacity; + runner->uniform_count = align(max(runner->uniform_count, offset + count), 4); vkd3d_array_reserve((void **)&runner->uniforms, &runner->uniform_capacity, runner->uniform_count, sizeof(*runner->uniforms)); + memset(runner->uniforms + initial_capacity, 0, runner->uniform_capacity - initial_capacity); memcpy(runner->uniforms + offset, uniforms, count * sizeof(*runner->uniforms)); }
How does that work? Are we sending more than "uniform_count" uniforms to the shader anywhere? Or is this about the potential padding introduced by align? In the latter case, we need to clear a fair bit less than we do here. We may also want to consider clearing with a value other than zero.
The first version of this MR was doing (a) but the current one does (b). The disadvantage of (b) is that we have to add more "if" qualifiers, if you think these are too many I can revert to (a).
We could conceivably introduce additional types that do type conversion when targetting d3dbc if the current scheme becomes too cumbersome, but for the moment this seems fine.
How does that work? Are we sending more than "uniform_count" uniforms to the shader anywhere? Or is this about the potential padding introduced by align?
Both in SM1 or when we work with arrays we commonly declare uniforms leaving the padding uninitialized: ``` uniform 0 float 1.0 uniform 4 float 2.0 uniform 8 float 3.0 ``` so the aim is to initialize it, including the padding after the last uniform declared.
My idea was to initialize the new values in the array after a reallocation happens, before inserting the values provided at the offset position, to ensure that we initialize the padding.
In the latter case, we need to clear a fair bit less than we do here.
Ah, I see it now.
We may also want to consider clearing with a value other than zero.
Yep, I think it makes sense to initialize to a sentry value other than zero, maybe 127 ?
btw, I forgot to multiply the amount of bytes by the size of each uniform. So the final instruction should be: ``` memset(runner->uniforms + initial_count, 127, (runner->uniform_count - initial_count) * sizeof(*runner->uniforms)); ```