diff --git a/tests/hlsl/arithmetic-int.shader_test b/tests/hlsl/arithmetic-int.shader_test index 46b64181..7a64894d 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 bf1d9c1b..87f56495 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 25cd1564..e1182599 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 617b6740..1b41dfb5 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 ba60367f..aed33092 100644 --- a/tests/hlsl/non-const-indexing.shader_test +++ b/tests/hlsl/non-const-indexing.shader_test @@ -236,9 +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 @@ -246,32 +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 -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 -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 866fd5d4..a683866c 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -657,14 +657,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))