summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-06-13 17:06:05 -0700
committerGitHub <noreply@github.com>2025-06-13 17:06:05 -0700
commit84148b80b167f5102e5f4813671b97bc1faeb5f0 (patch)
tree46efe753a0e87cb9c826cd55b85c36cb766fccc8 /tests/language-feature
parent1d8f6f86d1a6d33ff6e6429206b94d72457e1378 (diff)
Fix a bug in empty array legalization. (#7444)
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/0-array-2.slang40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/language-feature/0-array-2.slang b/tests/language-feature/0-array-2.slang
new file mode 100644
index 000000000..37d576d89
--- /dev/null
+++ b/tests/language-feature/0-array-2.slang
@@ -0,0 +1,40 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk
+
+public struct ContextND<let N: int>
+{
+ public uint3 thread_id;
+ public int[N] call_id;
+
+ public ContextND<0> map(int)
+ {
+ return { thread_id };
+ }
+
+ public ContextND<M> map<let M : int>(int[M] mapping)
+ {
+ ContextND<M> result;
+ result.thread_id = thread_id;
+ for (int i = 0; i < M; ++i)
+ result.call_id[i] = call_id[mapping[i]];
+ return result;
+ }
+}
+
+typealias Context = ContextND<0>;
+
+//TEST_INPUT: set value = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<int> value;
+
+void store(Context context, in int v) { value[0] = v; }
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ Context context = {dispatchThreadID};
+ int c = 1;
+ int m_c = 0;
+ // CHECK: 1
+ store(context.map(m_c), c);
+} \ No newline at end of file