summaryrefslogtreecommitdiffstats
path: root/tests/spirv/static-array-spv-asm.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-11 15:49:41 -0700
committerGitHub <noreply@github.com>2024-06-11 15:49:41 -0700
commit5da06d43bb0997455211ca56597c4302b09909ab (patch)
tree66897108a3cff9175ed025bedd05b705706a7606 /tests/spirv/static-array-spv-asm.slang
parent7e796692065060dea34b9e5b7eb224be444f5dee (diff)
Fix global value inlining for spirv_asm blocks. (#4339)
Diffstat (limited to 'tests/spirv/static-array-spv-asm.slang')
-rw-r--r--tests/spirv/static-array-spv-asm.slang22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/spirv/static-array-spv-asm.slang b/tests/spirv/static-array-spv-asm.slang
new file mode 100644
index 000000000..a543b4eb2
--- /dev/null
+++ b/tests/spirv/static-array-spv-asm.slang
@@ -0,0 +1,22 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// Test that we can use intrinsics in global scope constant array, which causes
+// the spirv_asm to be inlined in global module scope.
+// Our global value inlining pass should be able to clean up the global scope spirv_asm
+// blocks and inlining them to use sites.
+
+// CHECK: %main = OpFunction
+// CHECK: OpStore
+
+static const uint staticArr[] = {
+ uint((((uint)round(saturate(1) * 255) << 24) | ((uint)round(saturate(0) * 255) << 16) | ((uint)round(saturate(0) * 255) << 8) | 0xff)),
+ uint((((uint)round(saturate(1) * 255) << 24) | ((uint)round(saturate(0) * 255) << 16) | ((uint)round(saturate(1) * 255) << 8) | 0xff))
+};
+
+RWStructuredBuffer<int> buffer;
+
+[numthreads(1,1,1)]
+void main(int i : SV_DispatchThreadID)
+{
+ buffer[0] = staticArr[i] + staticArr[1];
+}