From: Francisco Casas fcasas@codeweavers.com
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. --- 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..2e0dc5661 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) +only(sm<6) probe all rgba (-2147483648.0, -2147483648.0, -2147483648.0, -2147483648.0) +only(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..812c0ddd5 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) +only(sm<6) probe all rgba (0.1, 0.2, 0.3, 0.4) +only(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..f220fe607 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. +only(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..ab112a546 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 +only(sm<6) probe all rgba (-1294967296.0, 3000000000.0, 0.0, 0.0) 4 +only(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..e788caeeb 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 +only(sm<4) todo probe all rgba (1.0, 1.0, 1.0, 1.0) +only(sm>=4 & sm<6) todo probe all rgba (4.0, 4.0, 4.0, 4.0) +only(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 6c5c1dba3..23a6ddd3e 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -642,14 +642,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, "only", &line, runner->minimum_shader_model)) + { + match = true; + } + else if (line != line_ini) + { + /* Matched "only" 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))