From d832e33574ed772db1fa9b7ba184b37d0e3704cf Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:45:21 -0400 Subject: Added float2x2 cast to float4 (and vise versa) (#4432) * added float4x4<->float4 casting (and related) Note: not adding `matrix<1,N>` and `matrix` translations since this will bloat stdlib with many expensive to process `extension` operations. `matrix` is already planned to be treated as vectors (which should solve this problem by proxy). * address review * explicit cast mat to vec --- tests/hlsl-intrinsic/matrix-cast-to-vector.slang | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/hlsl-intrinsic/matrix-cast-to-vector.slang (limited to 'tests') diff --git a/tests/hlsl-intrinsic/matrix-cast-to-vector.slang b/tests/hlsl-intrinsic/matrix-cast-to-vector.slang new file mode 100644 index 000000000..1ae064f26 --- /dev/null +++ b/tests/hlsl-intrinsic/matrix-cast-to-vector.slang @@ -0,0 +1,25 @@ +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -use-dxil -shaderobj -xslang -matrix-layout-row-major +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-slang -compute -dx12 -use-dxil -shaderobj -xslang -matrix-layout-column-major +//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj -xslang -matrix-layout-row-major +//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -shaderobj -xslang -matrix-layout-column-major + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + float2x2 matrix2x2_1 = float2x2(1, 2, 3, 4); + float4 vector4_1 = (float4)matrix2x2_1; + + float4 vector4_2 = float4(1, 2, 3, 4); + float2x2 matrix2x2_2 = (float2x2)vector4_2; + + outputBuffer[0] = uint(true + && all(vector4_1 == float4(1, 2, 3, 4)) + + && all(matrix2x2_2[0] == float2(1,2)) + && all(matrix2x2_2[1] == float2(3,4)) + ); + //BUF: 1 +} -- cgit v1.2.3