summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
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 /source/slang/slang-ir.cpp
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 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 7b7d5ec17..8371d6ef5 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -5212,18 +5212,20 @@ IRInst* IRBuilder::emitLoad(IRType* type, IRInst* ptr, IRInst* align)
return inst;
}
-IRInst* IRBuilder::emitLoad(IRType* type, IRInst* ptr, IRAlignedAttr* align)
+IRInst* IRBuilder::emitLoad(IRType* type, IRInst* ptr, ArrayView<IRInst*> attributes)
{
- if (align)
- {
- auto inst = createInst<IRLoad>(this, kIROp_Load, type, ptr, align);
- addInst(inst);
- return inst;
- }
- else
- {
- return emitLoad(type, ptr);
- }
+ ShortList<IRInst*> params;
+ params.add(ptr);
+ params.addRange(attributes);
+ auto inst = createInst<IRLoad>(
+ this,
+ kIROp_Load,
+ type,
+ params.getCount(),
+ params.getArrayView().getBuffer());
+
+ addInst(inst);
+ return inst;
}
IRInst* IRBuilder::emitLoad(IRInst* ptr)
@@ -5279,6 +5281,21 @@ IRInst* IRBuilder::emitStore(IRInst* dstPtr, IRInst* srcVal, IRInst* align)
return inst;
}
+IRInst* IRBuilder::emitStore(IRInst* dstPtr, IRInst* srcVal, IRInst* align, IRInst* memoryScope)
+{
+ auto inst = createInst<IRStore>(
+ this,
+ kIROp_Store,
+ nullptr,
+ dstPtr,
+ srcVal,
+ getAttr(kIROp_AlignedAttr, align),
+ getAttr(kIROp_MemoryScopeAttr, memoryScope));
+
+ addInst(inst);
+ return inst;
+}
+
IRInst* IRBuilder::emitAtomicStore(IRInst* dstPtr, IRInst* srcVal, IRInst* memoryOrder)
{
auto inst = createInst<IRAtomicStore>(