tests: Test how constant folding works on SM1.

This commit is contained in:
Giovanni Mascellani 2024-02-23 10:53:49 +01:00 committed by Alexandre Julliard
parent 0914561f85
commit 500b61c383
Notes: Alexandre Julliard 2024-02-26 23:11:14 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Francisco Casas (@fcasas)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/674
2 changed files with 147 additions and 0 deletions

View File

@ -170,6 +170,7 @@ vkd3d_shader_tests = \
tests/hlsl/side-effects.shader_test \
tests/hlsl/sign.shader_test \
tests/hlsl/single-numeric-initializer.shader_test \
tests/hlsl/sm1-const-folding.shader_test \
tests/hlsl/sm6-ternary.shader_test \
tests/hlsl/sm6-uav-rwtexture.shader_test \
tests/hlsl/smoothstep.shader_test \

View File

@ -0,0 +1,146 @@
% Test the interaction between integer constant folding and the fact
% that integers are secretly considered floats in SM1-3
[pixel shader]
float4 main() : SV_TARGET
{
uint x = 3000000000u;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
probe all rgba (3.0e+009, 0.0, 0.0, 0.0)
% The uint value is never casted to int on SM1-3, just casted to float and treated as such
[pixel shader]
float4 main() : SV_TARGET
{
int x = 3000000000u;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
if(sm<4) todo probe all rgba (3.0e+009, 0.0, 0.0, 0.0)
if(sm>=4) probe all rgba (-1.29496730e+009, 0.0, 0.0, 0.0)
% On SM1-5 (FXC) the literal is considered signed independently of its value and casted to uint;
% on SM1-3 compilation fails because the uint would be negative
[pixel shader fail(sm<4) todo(sm<4)]
float4 main() : SV_TARGET
{
uint x = 3000000000;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
if(sm>=4) probe all rgba (3.0e+009, 0.0, 0.0, 0.0)
[pixel shader]
float4 main() : SV_TARGET
{
int x = 3000000000;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
probe all rgba (-1.29496730e+009, 0.0, 0.0, 0.0)
[pixel shader]
float4 main() : SV_TARGET
{
return float4(3000000000u, 0.0, 0.0, 0.0);
}
[test]
draw quad
probe all rgba (3.0e+009, 0.0, 0.0, 0.0)
% Unsuffixed literals can instead be considered unsigned on SM6
[pixel shader]
float4 main() : SV_TARGET
{
return float4(3000000000, 0.0, 0.0, 0.0);
}
[test]
draw quad
if(sm<6) probe all rgba (-1.29496730e+009, 0.0, 0.0, 0.0)
if(sm>=6) probe all rgba (3.0e+009, 0.0, 0.0, 0.0)
% Constant folding is done with uint semantics before converting to float;
% so constant folding seems to happen before converting integer operations to floats
[pixel shader]
float4 main() : SV_TARGET
{
uint x = 3000000000u + 3000000000u;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
probe all rgba (1.70503270e+009, 0.0, 0.0, 0.0)
% SM1-3 complains that uint values must be positive, but it's not clear why this is a problem here:
% the sum should be done before casting to uint, and the result of the int sum should be positive,
% so it seems that the declared type of x means something on how constant folding is done.
% I'm not sure what's happening for SM4 anyway
[pixel shader fail(sm<4) todo(sm<4)]
float4 main() : SV_TARGET
{
uint x = 3000000000 + 3000000000;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
todo probe all rgba (2.14748365e+009, 0.0, 0.0, 0.0)
% Again, no idea of what's happening here
[pixel shader]
float4 main() : SV_TARGET
{
int x = 3000000000 + 3000000000;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
todo probe all rgba (-2.14748365e+009, 0.0, 0.0, 0.0)
% This makes sense
[pixel shader]
float4 main() : SV_TARGET
{
return float4(3000000000u + 3000000000u, 0.0, 0.0, 0.0);
}
[test]
draw quad
probe all rgba (1.70503270e+009, 0.0, 0.0, 0.0)
% This does not again
[pixel shader]
float4 main() : SV_TARGET
{
return float4(3000000000 + 3000000000, 0.0, 0.0, 0.0);
}
[test]
draw quad
todo probe all rgba (-2.14748365e+009, 0.0, 0.0, 0.0)
% Explicit float literals use float semantics, at least
[pixel shader]
float4 main() : SV_TARGET
{
float x = 3000000000.0 + 3000000000.0;
return float4(x, 0.0, 0.0, 0.0);
}
[test]
draw quad
probe all rgba (6.0e+009, 0.0, 0.0, 0.0)