From: Zebediah Figura zfigura@codeweavers.com
--- tests/hlsl/ternary.shader_test | 254 +++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+)
diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index 587b3d556..5a73084cf 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -14,6 +14,7 @@ uniform 0 float4 0.0 10.0 11.0 12.0 todo(sm>=6) draw quad probe all rgba (-1.0, 9.0, 10.0, 11.0)
+ [pixel shader] uniform float4 x;
@@ -32,6 +33,7 @@ uniform 0 float4 1.1 3.0 4.0 5.0 todo(sm>=6) draw quad probe all rgba (1.1, 2.0, 0.0, 0.0)
+ [pixel shader] float4 f;
@@ -47,6 +49,7 @@ uniform 0 float4 1.0 0.0 0.0 0.0 todo(sm>=6) draw quad probe all rgba (0.5, 0.6, 0.7, 0.0)
+ [pixel shader fail(sm>=6)] float4 x, y, z;
@@ -61,3 +64,254 @@ uniform 4 float4 1.0 2.0 3.0 4.0 uniform 8 float4 5.0 6.0 7.0 8.0 draw quad probe all rgba (5.0, 2.0, 7.0, 4.0) + + +% The usual type conversion is applied to the first and second expression, as +% long as they are numeric. + +[pixel shader fail] + +uniform float2x4 a; +uniform float3x2 b; + +float4 main() : sv_target +{ + 0 ? a : b; + return 0; +} + + +[pixel shader] + +uniform float3x3 a; +uniform float2x2 b; + +float4 main() : sv_target +{ + return float4(0 ? a : b); +} + + +[pixel shader] + +uniform float3 a; +uniform float4 b; + +float4 main() : sv_target +{ + return float4(0 ? a : b, 1.0); +} + + +% The condition is more restrictive. Either: +% * the class and dimensions must match exactly; +% * one of the two is scalar; +% * one is a typeN and the other is a type1xN + +[pixel shader fail todo] + +uniform float4 cond; +uniform float2x2 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a : b); +} + + +[pixel shader fail todo] + +uniform float2x2 cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a : b); +} + + +[pixel shader] + +uniform float2x2 cond; +uniform float2x2 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a : b); +} + + +[pixel shader fail todo] + +uniform float3 cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + (cond ? a : b); + return 0; +} + + +[pixel shader fail todo] + +uniform float4 cond; +uniform float4x1 a, b; + +float4 main() : sv_target +{ + (cond ? a : b); + return 0; +} + + +% As may be expected, this yields the type of the arguments, not the conditional. + +[pixel shader] + +uniform float4 cond; +uniform float1x4 a, b; + +float4 main() : sv_target +{ + return (cond ? a : b)[0]; +} + + +[pixel shader todo] + +uniform float1x4 cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + return (cond ? a : b)[0]; +} + + +[pixel shader fail] + +uniform float1x4 cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + return (cond ? a : b)[0][0]; +} + + +[pixel shader] + +uniform float1 cond; +uniform float1x1 a, b; + +float4 main() : sv_target +{ + return (cond ? a : b)[0][0]; +} + + +[pixel shader] + +uniform float cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a : b); +} + +[test] +uniform 0 float4 1.0 0.0 0.0 0.0 +uniform 4 float4 1.0 2.0 3.0 4.0 +uniform 8 float4 5.0 6.0 7.0 8.0 +draw quad +probe all rgba (1.0, 2.0, 3.0, 4.0) + + +[pixel shader todo] + +// "scalar" can mean any 1-component numeric type. +uniform float1x1 cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a : b); +} + + +[pixel shader todo] + +uniform float4 cond; +uniform float4 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a.x : b.x); +} + +[test] +uniform 0 float4 1.0 0.0 1.0 0.0 +uniform 4 float4 1.0 2.0 3.0 4.0 +uniform 8 float4 5.0 6.0 7.0 8.0 +todo draw quad +probe all rgba (1.0, 5.0, 1.0, 5.0) + + +[pixel shader todo] + +// "scalar" can mean any 1-component numeric type. +uniform float4 cond; +uniform float1x1 a, b; + +float4 main() : sv_target +{ + return float4(cond ? a : b); +} + + +% Objects can be used, but their types have to be identical. + +[pixel shader todo] +Texture2D t; + +float4 main() : sv_target +{ + Texture2D tmp = 0 ? t : t; + return 0; +} + + +[pixel shader fail todo] +Texture2D t; +float4 f; + +float4 main() : sv_target +{ + f ? t : t; + return 0; +} + + +[pixel shader fail] +Texture2D t; +Texture3D u; + +float4 main() : sv_target +{ + 0 ? t : u; + return 0; +} + + +% Of course objects cannot be used as the condition. + +[pixel shader fail todo] +Texture2D t; + +float4 main() : sv_target +{ + t ? 0 : 1; + return 0; +}