From c3c34bf4ca78caff285fbf5f24c5f355ca040bd1 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 29 Nov 2018 07:48:23 -0800 Subject: Add support for globallycoherent modifier (#732) The `globallycoherent` modifier indicates that resource might be read or written by threads outside of the current thread group, so that any memory barriers that affect it should guarantee coherency at the global memory scope, and not just thread-group scope. The equivalent GLSL modifier appears to be `coherent`. This change adds the front-end modifier, transforms it into an IR-level decoration during lowering, and then checks for the modifier during code emit. Note: this logic may not behave correctly when `globallycoherent` is added to a field in a `struct`, since the modifier would then need to be propagated to any variables created during type legalization. Checking up on that is left to future work. Note: it isn't entirely clear if `globallycoherent` should be treated as a declaration modifier or a type modifier. The point is moot for now because Slang doesn't have any support for type modifiers, but when we get around to that we will need to make a decision. --- source/slang/ir-serialize.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/slang/ir-serialize.cpp') diff --git a/source/slang/ir-serialize.cpp b/source/slang/ir-serialize.cpp index d8a01fb56..03e10c8e2 100644 --- a/source/slang/ir-serialize.cpp +++ b/source/slang/ir-serialize.cpp @@ -708,6 +708,7 @@ Result IRSerialWriter::write(IRModule* module, SourceManager* sourceManager, Opt case kIRDecorationOp_VulkanHitAttributes: case kIRDecorationOp_EarlyDepthStencil: case kIRDecorationOp_ReadNone: + case kIRDecorationOp_GloballyCoherent: { dstInst.m_payloadType = PayloadType::Empty; break; @@ -1574,6 +1575,12 @@ IRDecoration* IRSerialReader::_createDecoration(const Ser::Inst& srcInst) SLANG_ASSERT(srcInst.m_payloadType == PayloadType::Empty); return decor; } + case kIRDecorationOp_GloballyCoherent: + { + auto decor = createEmptyDecoration(m_module); + SLANG_ASSERT(srcInst.m_payloadType == PayloadType::Empty); + return decor; + } case kIRDecorationOp_VulkanHitAttributes: { auto decor = createEmptyDecoration(m_module); -- cgit v1.2.3