From 1e0908bd7107dfbdac912b693c3ab9bd6e1dc8b3 Mon Sep 17 00:00:00 2001 From: 16-Bit-Dog <67922228+16-Bit-Dog@users.noreply.github.com> Date: Fri, 10 Oct 2025 13:09:24 -0400 Subject: 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 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 --- .../pointer/coherent-load-store-image.slang | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/language-feature/pointer/coherent-load-store-image.slang (limited to 'tests/language-feature/pointer/coherent-load-store-image.slang') diff --git a/tests/language-feature/pointer/coherent-load-store-image.slang b/tests/language-feature/pointer/coherent-load-store-image.slang new file mode 100644 index 000000000..359994a0e --- /dev/null +++ b/tests/language-feature/pointer/coherent-load-store-image.slang @@ -0,0 +1,29 @@ +//DISABLE_TEST:SIMPLE(filecheck=SPIRV):-stage compute -entry computeMain -target spirv -capability vk_mem_model +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly -profile spirv_1_3 -capability vk_mem_model +// These tests are expected to fail, pointers to texels are +// currently a broken feature and do not work. +// Additionally, we do not allow texel pointers with `__getAddress`. + + +// Ensure SPIRV emits coherent operations here +// SPIRV: MakeTexelAvailable +// SPIRV: MakeTexelVisible + +// CHECK: 0 +// CHECK-NEXT: 5 + +//TEST_INPUT: RWTexture1D(format=R32Uint, size=8, content = one, mipMaps = 1):name=texture +RWTexture1D texture; + +//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(32, 1, 1)] +void computeMain() +{ + Ptr ptrIn = __getAddress(texture[1]); + Ptr secondPtrIn = ptrIn; + + storeCoherent<4, MemoryScope::Device>(ptrIn, 5); + outputBuffer[0] = loadCoherent<4, MemoryScope::Device>(ptrIn); +} -- cgit v1.2.3