tests/shader_runner: Test versions where the compilation result changes.

Adjust the algorithm for deciding for which profiles to test compilation.

We first ensure that if the compilation result changes (most often as the result
of a feature introduced in a specific version), we test the versions immediately
on either side of the change, to validate that vkd3d-shader is emulating the
same version behaviour.

We then ensure that we are testing at least one version from each set of sm1,
sm4, and sm6.
This commit is contained in:
Elizabeth Figura 2024-12-11 23:15:59 -06:00 committed by Henri Verbeet
parent 067e6deee4
commit 8fcbbfb8b1
Notes: Henri Verbeet 2024-12-17 16:52:41 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1318
12 changed files with 60 additions and 31 deletions

View File

@ -797,7 +797,7 @@ float4 main() : sv_target
return 0;
}
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
cbuffer buffer
{
float4 foo : packoffset(c0);

View File

@ -123,7 +123,10 @@ todo draw quad
todo probe (0,0) rgba (416.0, 416.0, 416.0, 111.0)
[pixel shader todo fail(sm>=6)]
% Fails in sm6 because it uses a uniform parameter.
% Fails in sm5.1 apparently because of a compiler bug:
% error X4609: Overflow of resource binding range
[pixel shader fail(sm>=5.1) todo]
Texture2D tex;
struct apple
@ -167,7 +170,11 @@ filter point point point
address clamp clamp clamp
[pixel shader todo fail(sm>=6)]
% Fails in sm6 because it uses a uniform parameter.
% Fails in sm5.1 apparently because of a compiler bug (different from the above!):
% error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Sampler s3 already declared. Opcode #5 (count is 1-based).
% error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Can't continue validation - aborting.
[pixel shader fail(sm>=5.1) todo]
Texture2D tex;
sampler sam0; // must reserve s3

View File

@ -138,7 +138,7 @@ todo(msl) draw quad
probe (0, 0) rgba (2132, 2132, 2132, 1111)
[pixel shader fail(sm<6)]
[pixel shader fail(sm<6) todo(sm>=5.1)]
Texture2D tex[3];
uniform int n;
@ -158,8 +158,7 @@ float4 main() : sv_target
}
[pixel shader fail(sm<6)]
// Note: Only valid in shader model 5.1
[pixel shader fail(sm<5.1) todo(sm>=5.1)]
Texture2D tex[3];
uniform int n;
@ -169,8 +168,7 @@ float4 main() : sv_target
}
[pixel shader fail(sm<6)]
// Note: Only valid in shader model 5.1
[pixel shader fail(sm<5.1) todo(sm>=5.1)]
RWTexture2D<float4> tex[3];
uniform int n;

View File

@ -154,7 +154,7 @@ probe (0, 0) rgba (2, 2, 2, 99)
% reservation is given, but if two different reservations are given it instead
% just picks the last one, without regard to version.
[pixel shader todo]
[pixel shader fail(sm>=5.0 & sm<5.1) todo]
Texture2D tex1 : register(ps, t1) : register(ps_5_0, t2);
float4 main() : sv_target
@ -168,7 +168,7 @@ if(sm>=6) probe (0,0) rgba (2, 2, 2, 99)
if(sm<6) probe (0,0) rgba (1, 1, 1, 99)
[pixel shader fail(sm<6) todo]
[pixel shader fail(sm<4.1) todo]
Texture2D tex1 : register(ps, t1) : register(ps_4_0, t2);
float4 main() : sv_target
@ -181,7 +181,7 @@ draw quad
probe (0, 0) rgba (2, 2, 2, 99)
[pixel shader fail(sm<6) todo]
[pixel shader fail(sm<4.1) todo]
Texture2D tex1 : register(ps_4_0, t1) : register(ps, t2);
float4 main() : sv_target
@ -207,7 +207,7 @@ draw quad
probe (0, 0) rgba (2, 2, 2, 99)
[pixel shader fail todo]
[pixel shader fail(sm<4.1 | sm>=6) todo]
Texture2D tex1 : register(ps_4_0, t1) : register(t2);
float4 main() : sv_target

View File

@ -99,7 +99,7 @@ shader model >= 4.0
% Register reservation with incorrect register type.
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler2D unused : register(t0);
Texture2D tex;

View File

@ -47,7 +47,7 @@ todo(sm<4) probe (0, 0) rgba(0.0, 0.0, 10.0, 0.0)
shader model >= 3.0
options: backcompat
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler s;
float bias;

View File

@ -15,7 +15,7 @@ levels 2
0.0 0.0 1.0 0.0
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler s;
float4 grad;
@ -35,7 +35,7 @@ uniform 0 float4 2.0 2.0 2.0 2.0
todo(msl) draw quad
probe (0,0) rgba (0.0, 0.0, 1.0, 0.0)
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler s;
float4 grad;

View File

@ -39,7 +39,7 @@ probe (0, 0) rgba (0.0, 0.0, 1.0, 0.0)
shader model >= 3.0
options: backcompat
[pixel shader todo(sm<4) fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm<4 | sm>=5.1)]
sampler s;
float level;

View File

@ -2,7 +2,7 @@
options: backcompat
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler2D sam = sampler_state
{
texture = NULL;
@ -54,7 +54,7 @@ float4 main(): sv_target
}
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler sam[2] =
{
sampler_state
@ -106,7 +106,7 @@ float4 main(): sv_target
}
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler sam = sampler_state
{
texture = NULL;
@ -121,7 +121,7 @@ float4 main(): sv_target
}
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler sam = sampler_state
{
foo = BAR;
@ -135,7 +135,7 @@ float4 main(): sv_target
}
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
// default value initializers make it more permissive but if types don't match
// then the whole initializer is discarded.
float4 f = {
@ -208,7 +208,7 @@ float4 main(): sv_target
shader model >= 5.0
options: backcompat
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
// Default values and sample_state work.
// Requires sm5.

View File

@ -53,7 +53,7 @@ float4 main() : sv_target
[require]
options: backcompat
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
samplerCUBE s;
float4 main() : sv_target
@ -61,7 +61,7 @@ float4 main() : sv_target
return texCUBE(s, float3(0.0, 0.0, 0.0));
}
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler1D s;
float4 main() : sv_target
@ -119,7 +119,7 @@ size (2d, 1, 1)
5.0 5.0 5.0 1.0
[pixel shader fail(sm>=6)]
[pixel shader fail(sm>=5.1) todo(sm>=5.1)]
sampler samA;
sampler samB[2];
sampler samC[3];

View File

@ -237,7 +237,7 @@ float4 main() : sv_target { return 0; }
% The number of state blocks in the state block list must match the number of components.
[pixel shader fail(sm<6)]
[pixel shader fail(sm<5.1) todo(sm>=5.1)]
sampler sams[2]
{
{
@ -246,7 +246,7 @@ sampler sams[2]
float4 main() : sv_target { return 0; }
[pixel shader fail(sm<6)]
[pixel shader fail(sm<6) todo(sm>=5.1)]
sampler sams[2][2]
{
{

View File

@ -1679,6 +1679,13 @@ static void compile_shader(struct shader_runner *runner, const char *source,
[SHADER_MODEL_5_0] = "5_0",
};
/* We can let this go through D3DCompile() with the invalid shader model
* string, but it returns a unique error code. Just skip it. */
if (model < SHADER_MODEL_4_0 && type != SHADER_TYPE_VS && type != SHADER_TYPE_PS && type != SHADER_TYPE_FX)
return;
if (model < SHADER_MODEL_5_0 && (type == SHADER_TYPE_HS || type == SHADER_TYPE_DS))
return;
if (use_dxcompiler)
{
assert(runner->dxc_compiler);
@ -2011,17 +2018,34 @@ void run_shader_tests(struct shader_runner *runner, const struct shader_runner_c
* formats, often with different HLSL semantics, so
* where possible try to test one version from each set. */
static const uint32_t sm1_mask = (1u << SHADER_MODEL_4_0) - 1;
static const uint32_t sm4_mask = ((1u << SHADER_MODEL_6_0) - 1) & ~sm1_mask;
uint32_t model_mask = 0;
if (runner->minimum_shader_model <= SHADER_MODEL_3_0)
if (runner->hlsl_hrs[runner->minimum_shader_model] == S_OK)
bitmap_set(&model_mask, runner->minimum_shader_model);
if (runner->minimum_shader_model <= SHADER_MODEL_5_1
for (unsigned int j = SHADER_MODEL_MIN + 1; j <= SHADER_MODEL_MAX; ++j)
{
if (runner->hlsl_hrs[j - 1] != runner->hlsl_hrs[j])
{
/* Behaviour changes here; test both versions. */
bitmap_set(&model_mask, j - 1);
bitmap_set(&model_mask, j);
}
}
if (!(model_mask & sm1_mask) && runner->minimum_shader_model <= SHADER_MODEL_3_0)
bitmap_set(&model_mask, runner->minimum_shader_model);
if (!(model_mask & sm4_mask)
&& runner->minimum_shader_model <= SHADER_MODEL_5_1
&& runner->maximum_shader_model >= SHADER_MODEL_4_0)
bitmap_set(&model_mask, max(runner->minimum_shader_model, SHADER_MODEL_4_0));
if (runner->maximum_shader_model >= SHADER_MODEL_6_0)
bitmap_set(&model_mask, max(runner->minimum_shader_model, SHADER_MODEL_6_0));
for (enum shader_model model = SHADER_MODEL_MIN; model <= SHADER_MODEL_MAX; ++model)
for (enum shader_model model = runner->minimum_shader_model;
model <= runner->maximum_shader_model; ++model)
{
if (!bitmap_is_set(&model_mask, model))
continue;