From 9605993af3ffe637f36fab2859bd5df7bebeb9c9 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 10 Aug 2023 09:27:57 +0200 Subject: [PATCH] tests: Add some tests for "if" statement attributes. Signed-off-by: Nikolay Sivov --- tests/hlsl/conditional.shader_test | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/hlsl/conditional.shader_test b/tests/hlsl/conditional.shader_test index d83596fc..2d2ba2e9 100644 --- a/tests/hlsl/conditional.shader_test +++ b/tests/hlsl/conditional.shader_test @@ -14,3 +14,71 @@ probe all rgba (0.9, 0.8, 0.7, 0.6) uniform 0 float4 0.1 0.0 0.0 0.0 draw quad probe all rgba (0.1, 0.2, 0.3, 0.4) + +[pixel shader todo] +float4 main(uniform float4 u) : sv_target +{ + [attr1] + if (u.x > 0.0) + return float4(0.1, 0.2, 0.3, 0.4); + else + return float4(0.9, 0.8, 0.7, 0.6); +} + +[pixel shader todo] +float4 main(uniform float4 u) : sv_target +{ + [flatten] + if (u.x > 0.0) + return float4(0.1, 0.2, 0.3, 0.4); + else + return float4(0.9, 0.8, 0.7, 0.6); +} + +[test] +uniform 0 float4 0.0 0.0 0.0 0.0 +todo draw quad +todo probe all rgba (0.9, 0.8, 0.7, 0.6) + +[pixel shader fail] +float4 u; + +float main() : sv_target +{ + [branch] [branch] + if (u.x > 0.0) + return float4(0.1, 0.2, 0.3, 0.4); + else + return float4(0.9, 0.8, 0.7, 0.6); +} + +[pixel shader fail] +float4 u; + +float main() : sv_target +{ + [branch] [flatten] + if (u.x > 0.0) + return float4(0.1, 0.2, 0.3, 0.4); + else + return float4(0.9, 0.8, 0.7, 0.6); +} + +% Using older profiles fails to compile with forced control flow instruction +[require] +shader model >= 3.0 + +[pixel shader todo] +float4 main(uniform float4 u) : sv_target +{ + [branch] + if (u.x > 0.0) + return float4(0.1, 0.2, 0.3, 0.4); + else + return float4(0.9, 0.8, 0.7, 0.6); +} + +[test] +uniform 0 float4 0.0 0.0 0.0 0.0 +todo draw quad +todo probe all rgba (0.9, 0.8, 0.7, 0.6)