summaryrefslogtreecommitdiff
path: root/tests/compute/groupshared.slang
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-04-18 17:22:44 -0700
committerGitHub <noreply@github.com>2018-04-18 17:22:44 -0700
commit17fa424a195ed562e0c9d87cee57577c90c1fc37 (patch)
tree710d045b7b4228d750dd989689d5a1a63044bb93 /tests/compute/groupshared.slang
parentc3a27c0e5a5b36b5a14566394d1694419632b76c (diff)
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<X>`. 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.
Diffstat (limited to 'tests/compute/groupshared.slang')
-rw-r--r--tests/compute/groupshared.slang39
1 files changed, 39 insertions, 0 deletions
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<int> 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