From 2fc32c3d1da8c0794d5f6309f324e3238e05f9c4 Mon Sep 17 00:00:00 2001 From: Conor McCarthy Date: Sat, 27 Apr 2024 20:35:07 +1000 Subject: [PATCH] tests/hlsl: Add a test for constexpr pointer cast. --- Makefile.am | 1 + tests/hlsl/pointer-cast.shader_test | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/hlsl/pointer-cast.shader_test diff --git a/Makefile.am b/Makefile.am index 50a5e8b3..5820a8b1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -163,6 +163,7 @@ vkd3d_shader_tests = \ tests/hlsl/object-field-offsets.shader_test \ tests/hlsl/object-parameters.shader_test \ tests/hlsl/object-references.shader_test \ + tests/hlsl/pointer-cast.shader_test \ tests/hlsl/pow.shader_test \ tests/hlsl/precise-modifier.shader_test \ tests/hlsl/rasteriser-ordered-views.shader_test \ diff --git a/tests/hlsl/pointer-cast.shader_test b/tests/hlsl/pointer-cast.shader_test new file mode 100644 index 00000000..7cbcfc8f --- /dev/null +++ b/tests/hlsl/pointer-cast.shader_test @@ -0,0 +1,23 @@ +[require] +shader model >= 6.0 + +[pixel shader] +uint u, v, w; + +static float foo[3] = {0.25, 0.5, 0.75}; + +float4 main(float4 pos : SV_Position) : SV_Target +{ + // Compiles to a constexpr uint pointer cast of foo for a store instruction. + if (v) + foo[1] = asfloat(w); + return float4(foo[u], foo[u + 1], 0.0, 1.0); +} + +[test] +uniform 0 uint4 0 1 0x3e000000 0 +todo draw quad +probe all rgba (0.25, 0.125, 0.0, 1.0) +uniform 0 uint4 1 0 0x3e000000 0 +todo draw quad +probe all rgba (0.5, 0.75, 0.0, 1.0)