summaryrefslogtreecommitdiffstats
path: root/tests/compute
diff options
context:
space:
mode:
authorGangzheng Tong <tonggangzheng@gmail.com>2025-07-29 12:12:40 -0700
committerGitHub <noreply@github.com>2025-07-29 19:12:40 +0000
commit48efc60380aa79e8c4aba13976cc2015f38a659e (patch)
treecc13517501c1b7dcdca55fce61a7d19f59a64b43 /tests/compute
parent2db6ac97ad62f28c246e8176df52a104bb7c4be9 (diff)
Fix Metal invalid as_type cast for 64-bit RWByteAddressBuffer.Store values (#7843)
* Fix 64-bit val lowering for metal * Add ByteAddressBuffer load/store 64-bit tests * Handle Store/Load ptr types * Use bitcast for non-pointer typers * format code (#7966) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tests/compute')
-rw-r--r--tests/compute/byte-address-buffer-64bit.slang32
-rw-r--r--tests/compute/byte-address-buffer-64bit.slang.expected.txt8
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/compute/byte-address-buffer-64bit.slang b/tests/compute/byte-address-buffer-64bit.slang
new file mode 100644
index 000000000..e8d6a42f2
--- /dev/null
+++ b/tests/compute/byte-address-buffer-64bit.slang
@@ -0,0 +1,32 @@
+// byte-address-buffer.slang
+
+//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
+//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -shaderobj -profile cs_6_0 -use-dxil
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3]):name=inputBuffer
+RWByteAddressBuffer inputBuffer;
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0]):out,name=outputBuffer
+RWByteAddressBuffer outputBuffer;
+
+void testInt64(uint val)
+{
+ // Load a 32-bit value from the input buffer
+ uint tmp = inputBuffer.Load(uint(val * 4));
+
+ // Cast to uint64_t
+ uint64_t tmp64 = uint64_t(tmp) + 1;
+
+ // Store the result back as uint64_t
+ outputBuffer.Store(uint(val * 8), tmp64);
+}
+
+[numthreads(4, 1, 1)]
+[shader("compute")]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ testInt64(tid);
+}
diff --git a/tests/compute/byte-address-buffer-64bit.slang.expected.txt b/tests/compute/byte-address-buffer-64bit.slang.expected.txt
new file mode 100644
index 000000000..ac5027985
--- /dev/null
+++ b/tests/compute/byte-address-buffer-64bit.slang.expected.txt
@@ -0,0 +1,8 @@
+1
+0
+2
+0
+3
+0
+4
+0 \ No newline at end of file