From 17fa424a195ed562e0c9d87cee57577c90c1fc37 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 18 Apr 2018 17:22:44 -0700 Subject: Fix output of `groupshared` with IR type system (#492) The basic problem was that the lowering logic was constructing (more or less) `Ptr<@GroupShared X>` instead of `@GroupShared Ptr`. There were also problems with passes not propagating through rates that should have been (e.g., legalization). I've added a test case to actually validate `groupshared` support. --- tests/compute/groupshared.slang | 39 ++++++++++++++++++++++++++++ tests/compute/groupshared.slang.expected.txt | 4 +++ 2 files changed, 43 insertions(+) create mode 100644 tests/compute/groupshared.slang create mode 100644 tests/compute/groupshared.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/groupshared.slang b/tests/compute/groupshared.slang new file mode 100644 index 000000000..e471e6148 --- /dev/null +++ b/tests/compute/groupshared.slang @@ -0,0 +1,39 @@ +// groupshared.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +#define THREAD_COUNT 4 + +groupshared int gA[THREAD_COUNT]; +int test(int val) +{ + gA[val] = val; + GroupMemoryBarrierWithGroupSync(); + val = gA[val ^ 1]; + +/* TODO: once function-scope `static` works + static groupshared int gB[THREAD_COUNT]; + + gB[val] = val; + GroupMemoryBarrierWithGroupSync(); + val = gB[val ^ 2]; +*/ + + return val; +} + +RWStructuredBuffer gBuffer; + +[numthreads(THREAD_COUNT, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int val = int(tid); + val = test(val); + gBuffer[tid] = val; +} \ No newline at end of file diff --git a/tests/compute/groupshared.slang.expected.txt b/tests/compute/groupshared.slang.expected.txt new file mode 100644 index 000000000..8a5d99f5b --- /dev/null +++ b/tests/compute/groupshared.slang.expected.txt @@ -0,0 +1,4 @@ +1 +0 +3 +2 -- cgit v1.2.3