tests/hlsl: Test partial assignments due to lhs casts.

This commit is contained in:
Francisco Casas 2025-01-20 17:03:55 -03:00 committed by Henri Verbeet
parent 51db232368
commit 60f75cc542
Notes: Henri Verbeet 2025-01-22 15:04:09 +01:00
Approved-by: Elizabeth Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1350
2 changed files with 165 additions and 0 deletions

View File

@ -169,6 +169,7 @@ vkd3d_shader_tests = \
tests/hlsl/length.shader_test \
tests/hlsl/lerp.shader_test \
tests/hlsl/lhs-cast.shader_test \
tests/hlsl/lhs-partial-assignment.shader_test \
tests/hlsl/lit.shader_test \
tests/hlsl/load-level.shader_test \
tests/hlsl/log.shader_test \

View File

@ -0,0 +1,164 @@
% Partial assigments are possible if the cast is to a smaller type that fits
% in the destination variable's type.
[pixel shader todo fail(sm>=6)]
float4 a;
float4 main() : sv_target
{
float4 p = {-1, -2, -3, -4};
(float2) p = a.yz; // partial assignment to p.xy.
return p;
}
[test]
uniform 0 float4 1 2 3 4
todo draw quad
probe (0, 0) rgba(2, 3, -3, -4)
[pixel shader todo]
float4 main() : sv_target
{
float4 p = {-1, -2, -3, -4};
(float) p = 1; // partial assignment to p.x.
return p;
}
[test]
uniform 0 float4 1 2 3 4
todo(sm<6) draw quad
probe (0, 0) rgba(1, -2, -3, -4)
[pixel shader]
float4 main() : sv_target
{
float p[5] = {-1, -2, -3, -4, -5};
float r[2] = {1, 2};
(float[2]) p = r; // partial assignment to p[0] and p[1]
return float4(p[0], p[1], p[2], p[4]);
}
[test]
draw quad
todo(sm<6) probe (0, 0) rgba(1, 2, -3, -5)
[pixel shader]
float4 a;
float4 main() : sv_target
{
float4 p = {-1, -2, -3, -4};
(float2) p.yz = a.yz; // partial assignment to p.yz
return p;
}
[test]
uniform 0 float4 1 2 3 4
draw quad
probe (0, 0) rgba(-1, 2, 3, -4)
[pixel shader fail(sm>=4) todo]
float4 main() : sv_target
{
float4 p = {-1, -2, -3, -4};
(int2) p = int2(1, 2);
return p;
}
% Matrix partial assignment.
[pixel shader fail(sm>=6)]
float3x4 a;
float4 main() : sv_target
{
float4x4 g = 0;
(float2x3) g = a;
return 1000000*g[0] + 10000*g[1] + 100*g[2] + g[3];
}
[test]
uniform 0 float4 1 5 9 0
uniform 4 float4 2 6 10 0
uniform 8 float4 3 7 11 0
uniform 12 float4 4 8 12 0
draw quad
todo probe (0, 0) rgba(1050000, 2060000, 3070000, 0)
% Multiple cast partial assigment.
[pixel shader fail(sm>=6)]
float4 main() : sv_target
{
float4x4 g = 0;
(float2x2)(float2x3)g = float4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
return g._11_12_21_22;
}
[test]
draw quad
todo probe (0, 0) rgba(1, 2, 5, 6)
[pixel shader fail(sm>=4) todo]
float4 main() : sv_target
{
float4 p = 0;
(float2)(int4) p = float4(-1.1, -2.8, 3.7, 4.3);
return p;
}
[test]
todo draw quad
probe (0, 0) rgba(-1.1, -2.8, 0, 0)
[pixel shader fail(sm>=4) todo]
float4 main() : sv_target
{
float4 p = 0;
(float2)(int3) p = float4(1, 2, 3, 4);
return 0;
}
[pixel shader]
float4 main() : sv_target
{
float p[4][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
float r[2][2] = {10, 20, 30, 40};
(float[2][2]) p = r;
return float4(p[0][0], p[1][1], p[1][0], p[2][2]);
}
[test]
draw quad
todo(sm<6) probe (0, 0) rgba(10, 5, 40, 9)
% For some reason this acts as .z swizzle on the rhs.
[pixel shader todo fail(sm>=4)]
float4 main() : sv_target
{
float2 a = 0;
(int3)(float)a = float3(1.1, 2.1, 3.1);
return a.xyxy;
}
[test]
todo(sm<6) draw quad
probe (0, 0) rgba(3, 0, 3, 0)