tests/shader-runner: Introduce "if" qualifier.

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.
This commit is contained in:
Francisco Casas 2024-01-29 20:07:39 -03:00 committed by Alexandre Julliard
parent faec42e8a1
commit 22c47e57f5
Notes: Alexandre Julliard 2024-02-13 23:11:43 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/616
6 changed files with 47 additions and 55 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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))