summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-06-24 09:45:21 -0400
committerGitHub <noreply@github.com>2024-06-24 09:45:21 -0400
commitd832e33574ed772db1fa9b7ba184b37d0e3704cf (patch)
tree8a0a369757b7c7c37121d7d78bb870b10d6f6750 /tests
parentcf8d1ceffcfbbb64734e6180a2c0cebd033f5b2e (diff)
Added float2x2 cast to float4 (and vise versa) (#4432)
* added float4x4<->float4 casting (and related) Note: not adding `matrix<1,N>` and `matrix<N,1>` translations since this will bloat stdlib with many expensive to process `extension` operations. `matrix<N,1>` is already planned to be treated as vectors (which should solve this problem by proxy). * address review * explicit cast mat to vec
Diffstat (limited to 'tests')
-rw-r--r--tests/hlsl-intrinsic/matrix-cast-to-vector.slang25
1 files changed, 25 insertions, 0 deletions
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<int> 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
+}