tests: Test default values for uniform variables.

This commit is contained in:
Francisco Casas 2024-04-10 20:18:24 -04:00 committed by Alexandre Julliard
parent 9e57039fce
commit 499b44a193
Notes: Alexandre Julliard 2024-05-15 23:03:23 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/839
2 changed files with 144 additions and 0 deletions

View File

@ -89,6 +89,7 @@ vkd3d_shader_tests = \
tests/hlsl/cross.shader_test \
tests/hlsl/d3dcolor-to-ubyte4.shader_test \
tests/hlsl/ddxddy.shader_test \
tests/hlsl/default-values.shader_test \
tests/hlsl/depth-out.shader_test \
tests/hlsl/determinant.shader_test \
tests/hlsl/discard.shader_test \

View File

@ -0,0 +1,143 @@
% Note that, except for effects, default values do not affect the execution.
% The default values are intended to be obtained using reflection.
[pixel shader todo]
float2 a = {1, 2};
float4x2 b = {1, 2, 3, 4, 5, 6, 7, 8};
float4 main() : sv_target
{
return float4(a, b[2]);
}
[test]
if(sm<4) uniform 0 float4 10 30 50 70
if(sm<4) uniform 4 float4 20 40 60 80
if(sm<4) uniform 8 float4 10 20 0 0
if(sm>=4) uniform 0 float4 10 20 0 0
if(sm>=4) uniform 4 float4 10 30 50 70
if(sm>=4) uniform 8 float4 20 40 60 80
todo(sm<6) draw quad
probe all rgba (10, 20, 50, 60)
[pixel shader fail(sm<6) todo]
float a = 7;
float4 b = a; // initial value must be a literal expression.
float4 main() : sv_target { return 0; }
[pixel shader fail(sm<6) todo]
float a = 7;
float4 b = {1, 2, a, 4}; // initial value must be a literal expression.
float4 main() : sv_target { return 0; }
[pixel shader fail]
Texture2D tex;
struct
{
Texture2D t;
float a;
} apple = {tex, 4}; // initial value must be a literal expression.
float4 main() : sv_target
{
return 0;
}
[pixel shader todo]
static const float a = 7;
float4 b = {1, 2, a, 4}; // static constant values are allowed on the initializer.
float4 main() : sv_target { return b; }
[test]
uniform 0 float4 10.0 20.0 30.0 40.0
todo(sm<6) draw quad
probe all rgba (10, 20, 30, 40)
[pixel shader todo]
float4 a = {3, 5, float2(4, 4)}; // numeric type initializers are allowed.
float4 main() : sv_target
{
return 2 * a;
}
[test]
uniform 0 float4 10.0 20.0 30.0 40.0
todo(sm<6) draw quad
probe all rgba (20, 40, 60, 80)
[pixel shader todo]
int4 a[2] = {10, 20, float3x2(1, 2, 3, 4, 5, 6)}; // matrix numeric type initializers are allowed.
float4 main() : sv_target
{
return 2 * a[1];
}
[test]
if(sm<4) uniform 0 float4 10 20 30 40
if(sm<4) uniform 4 float4 50 60 70 80
if(sm>=4) uniform 0 int4 10 20 30 40
if(sm>=4) uniform 4 int4 50 60 70 80
todo(sm<6) draw quad
probe all rgba (100, 120, 140, 160)
[pixel shader todo]
struct apple
{
float3 a[2];
int2x2 b;
} ap = {1, 2, 3, 4, 5, 6, 7.5, 8, 9, 10};
float4 main() : sv_target
{
return float4(ap.b);
}
[test]
uniform 0 float4 10 20 30 0
uniform 4 float4 40 50 60 0
if(sm<4) uniform 8 float4 70 90 0 0
if(sm<4) uniform 12 float4 80 100 0 0
if(sm>=4) uniform 8 int4 70 90 0 0
if(sm>=4) uniform 12 int4 80 100 0 0
todo(sm<6) draw quad
probe all rgba (70, 80, 90, 100)
[require]
shader model >= 5.0
% Default values for doubles don't seem to be saved properly.
[pixel shader todo]
double2 m = {1, 2};
// double2 m; // Offset: 0 Size: 16
// = 0x00000000 0x00000000 0x40000000 0x00000000
float4 main() : sv_target
{
return m.y;
}
[pixel shader todo]
static const float3x2 mat = {10, 20, 30, 40, 50, 60};
static const float4 array[2] = {1, 2, 3, 4, 5, 6, 7, 8};
static const int idx = 1;
float3 u = {array[idx].xwwz.xy, mat._m21_m01.x}; // = {5, 8, 60}
float4 main() : sv_target
{
return u.y;
}