summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-07-24 13:36:30 -0700
committerGitHub <noreply@github.com>2025-07-24 20:36:30 +0000
commita9d1cc5daaf2cf72be88f7ebf4a2e3c3da68abc9 (patch)
tree1131e58dc88ea94b53784e7bc453458a1ba2d686 /tests
parent8ccd495d5eaa82cb831378c28dd190e657b6c999 (diff)
Add test for Metal pointer uniform parameter (#7850)
* Add test for Metal pointer uniform parameter * Update the test to include runtime result * Adding CUDA to the test * Adding -render-features argument-buffer-tier-2
Diffstat (limited to 'tests')
-rw-r--r--tests/metal/metal-pointer-uniform.slang33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/metal/metal-pointer-uniform.slang b/tests/metal/metal-pointer-uniform.slang
new file mode 100644
index 000000000..4a0ddb8fd
--- /dev/null
+++ b/tests/metal/metal-pointer-uniform.slang
@@ -0,0 +1,33 @@
+//TEST:SIMPLE(filecheck=CHECK_MTL): -target metal -stage compute -entry computeMain
+//TEST:SIMPLE(filecheck=CHECK_AIR): -target metallib -stage compute -entry computeMain
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -emit-spirv-directly
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -metal -render-features argument-buffer-tier-2
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -cuda
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu
+
+// This reproduces the specific case that was failing where uniform pointers
+// are used for buffer copy operations with array indexing targeting Metal.
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+//CHECK_MTL: int{{.*}}device{{ *\*}} src
+
+// "indirect_argument" means a pointer
+//CHECK_AIR: !"int", !"src{{[^"]*}}", !"air.indirect_argument"
+
+//TEST_INPUT: set src = ubuffer(data=[1 2 3 4 5 6 7 8],stride=4);
+uniform int* src;
+
+[shader("compute")]
+[numthreads(4,1,1)]
+void computeMain(uint3 threadID : SV_DispatchThreadID)
+{
+ let input = src[threadID.x];
+ outputBuffer[threadID.x] = input;
+}
+
+//CHECK:1
+//CHECK-NEXT:2
+//CHECK-NEXT:3
+//CHECK-NEXT:4