From 84148b80b167f5102e5f4813671b97bc1faeb5f0 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 13 Jun 2025 17:06:05 -0700 Subject: Fix a bug in empty array legalization. (#7444) --- tests/language-feature/0-array-2.slang | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/language-feature/0-array-2.slang (limited to 'tests/language-feature') 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 +{ + public uint3 thread_id; + public int[N] call_id; + + public ContextND<0> map(int) + { + return { thread_id }; + } + + public ContextND map(int[M] mapping) + { + ContextND 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 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 -- cgit v1.2.3