summaryrefslogtreecommitdiff
path: root/tests/language-feature/pointer/coherent-load-store-groupshared.slang
diff options
context:
space:
mode:
author16-Bit-Dog <67922228+16-Bit-Dog@users.noreply.github.com>2025-10-10 13:09:24 -0400
committerGitHub <noreply@github.com>2025-10-10 17:09:24 +0000
commit1e0908bd7107dfbdac912b693c3ab9bd6e1dc8b3 (patch)
treecc39d2e18abc954fb76f9a54b11a8d492685c6e2 /tests/language-feature/pointer/coherent-load-store-groupshared.slang
parentb4023f715885ada9a2777ea3b0d6d9739860b39b (diff)
Addition of `Load`/`Store` coherent operations (#8395)
Fixes: https://github.com/shader-slang/slang/issues/7634 Duplicate of PR https://github.com/shader-slang/slang/pull/8052 Primary Changes: * Added `storeCoherent` and `loadCoherent` for coherent load/store via pointers. This is backed by `IRMemoryScopeAttr` which is an `IRAttr` attached to `IRLoad` and `IRStore` * Logic in `source\slang\slang-emit-spirv.cpp` for load/store emitting has been reworked to be less messy and more maintainable * Add to `hlsl.meta.slang` coop vector and coop matrix coherent load/store operations Secondary Changes: * Added a missing load/store test for coop matrix: `tests\cooperative-matrix\load-store-pointer.slang` --------- Co-authored-by: ArielG-NV <aglasroth@nvidia.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Nathan V. Morrical <natemorrical@gmail.com>
Diffstat (limited to 'tests/language-feature/pointer/coherent-load-store-groupshared.slang')
-rw-r--r--tests/language-feature/pointer/coherent-load-store-groupshared.slang26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/language-feature/pointer/coherent-load-store-groupshared.slang b/tests/language-feature/pointer/coherent-load-store-groupshared.slang
new file mode 100644
index 000000000..2e537ef01
--- /dev/null
+++ b/tests/language-feature/pointer/coherent-load-store-groupshared.slang
@@ -0,0 +1,26 @@
+//TEST:SIMPLE(filecheck=SPIRV):-stage compute -entry computeMain -target spirv -capability vk_mem_model
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -emit-spirv-directly -capability vk_mem_model
+
+// Tests if we pass-through and handle groupshared address space pointers correctly.
+// Ensure SPIRV emits coherent operations here
+// SPIRV: MakePointerAvailable|NonPrivatePointer
+// SPIRV: MakePointerVisible|NonPrivatePointer
+
+// CHECK: 2
+// CHECK-NEXT: 1
+// CHECK-NEXT: 0
+
+//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+groupshared int[32] shared;
+
+#define THREAD_GROUP_SIZE 3
+[numthreads(THREAD_GROUP_SIZE, 1, 1)]
+void computeMain(uint3 group_thread_id: SV_GroupThreadID)
+{
+ Ptr<int, Access::ReadWrite, AddressSpace::GroupShared> ptr = __getAddress(shared[0]);
+ storeCoherent<4, MemoryScope::Workgroup>(ptr + group_thread_id.x, (int)group_thread_id.x);
+ AllMemoryBarrierWithGroupSync();
+ outputBuffer[group_thread_id.x] = loadCoherent<4, MemoryScope::Workgroup>(ptr + THREAD_GROUP_SIZE - group_thread_id.x - 1);
+} \ No newline at end of file