From 51db2323688a28150cdf806113c477bc26207a0f Mon Sep 17 00:00:00 2001 From: Francisco Casas Date: Fri, 17 Jan 2025 20:30:05 -0300 Subject: [PATCH] tests/hlsl: Add lhs cast tests. --- Makefile.am | 1 + tests/hlsl/lhs-cast.shader_test | 111 ++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 tests/hlsl/lhs-cast.shader_test diff --git a/Makefile.am b/Makefile.am index da9bf880..e3330644 100644 --- a/Makefile.am +++ b/Makefile.am @@ -168,6 +168,7 @@ vkd3d_shader_tests = \ tests/hlsl/ldexp.shader_test \ tests/hlsl/length.shader_test \ tests/hlsl/lerp.shader_test \ + tests/hlsl/lhs-cast.shader_test \ tests/hlsl/lit.shader_test \ tests/hlsl/load-level.shader_test \ tests/hlsl/log.shader_test \ diff --git a/tests/hlsl/lhs-cast.shader_test b/tests/hlsl/lhs-cast.shader_test new file mode 100644 index 00000000..ee24998d --- /dev/null +++ b/tests/hlsl/lhs-cast.shader_test @@ -0,0 +1,111 @@ +% lhs casts to the same type don't have effect. +[pixel shader] +float4 main() : sv_target +{ + float4 p = 0; + + (float4) p = float4(1, 2, 3, 4); + return p; +} + +[test] +draw quad +probe (0, 0) rgba(1, 2, 3, 4) + + +% Casts with base type changes are only valid on SM1. +[pixel shader fail(sm>=4) todo] +float4 main() : sv_target +{ + float4 p = 0; + + (int4) p = float4(-1.5, -2.3, 4.7, 0.4); + return p; +} + +[test] +todo draw quad +probe (0, 0) rgba(-1, -2, 4, 0) + + +% Casts don't actually perform base type changes, only the outtermost one, which +% I suspect is because the implicit cast on the assignment and not the cast itself. +[pixel shader fail(sm>=4) todo(sm>=4)] +float4 main() : sv_target +{ + float4 f = 0; + + (float2x2)(int4)(half4) f = float4(1.3, -2.4, 3.3, 4.7); + return f; +} + +[test] +todo(sm>=4) draw quad +todo probe (0, 0) rgba(1.3, -2.4, 3.3, 4.7) + + +[pixel shader fail(sm>=4) todo] +float4 main() : sv_target +{ + float4 f = 0; + + (int4)(float4)(half4) f = float4(1.3, -2.4, 3.3, 4.7); + return f; +} + +[test] +todo draw quad +probe (0, 0) rgba(1, -2, 3, 4) + + +[pixel shader fail] +float4 main() : sv_target +{ + float p[5] = {-1, -2, -3, -4, -5}; + float arr[5] = {1.5, 2.5, 3.5, 4.5, 5.5}; + + (int[5]) p = arr; + return 0; +} + + +[pixel shader fail(sm>=6)] +float4 main() : sv_target +{ + float4 f = 0; + + (float2x2) f = float3x2(1, 2, 3, 4, 5, 6); + return f; +} + +[test] +draw quad +todo probe (0, 0) rgba(1, 2, 3, 4) + + +[pixel shader fail(sm>=4) todo] +float4 main() : sv_target +{ + float4 f = 0; + + ((int4) f).xy = float2(1.4, 3.8); + return f; +} + +[test] +todo draw quad +probe (0, 0) rgba(1, 3, 0, 0); + + +[pixel shader fail(sm>=4) todo] +float4 main() : sv_target +{ + float4 f = 0; + + ((float3)((int4) f).xyz).xy = float2(1.4, 2.8); + return f; +} + +[test] +todo draw quad +probe (0, 0) rgba(1.4, 2.8, 0, 0);