From 770d94f796c4871065f611b5ce63cc971a62a673 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 30 Mar 2018 17:59:57 +0200 Subject: [PATCH] [dxbc] Fix explicit memory barrier semantics This imitates glslang behaviour for barrier instructions and sets AcquireRelease semantics for all explicit memory barriers. --- src/dxbc/dxbc_compiler.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index b412c4358..9d557434e 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -2153,8 +2153,8 @@ namespace dxvk { // scope is defined by the operand control bits. const DxbcSyncFlags flags = ins.controls.syncFlags; - uint32_t executionScope = 0; - uint32_t memoryScope = 0; + uint32_t executionScope = spv::ScopeInvocation; + uint32_t memoryScope = spv::ScopeInvocation; uint32_t memorySemantics = 0; if (flags.test(DxbcSyncFlag::ThreadsInGroup)) @@ -2162,25 +2162,30 @@ namespace dxvk { if (flags.test(DxbcSyncFlag::ThreadGroupSharedMemory)) { memoryScope = spv::ScopeWorkgroup; - memorySemantics |= spv::MemorySemanticsWorkgroupMemoryMask; + memorySemantics |= spv::MemorySemanticsWorkgroupMemoryMask + | spv::MemorySemanticsAcquireReleaseMask; } if (flags.test(DxbcSyncFlag::UavMemoryGroup)) { memoryScope = spv::ScopeWorkgroup; - memorySemantics |= spv::MemorySemanticsUniformMemoryMask; + memorySemantics |= spv::MemorySemanticsImageMemoryMask + | spv::MemorySemanticsUniformMemoryMask + | spv::MemorySemanticsAcquireReleaseMask; } if (flags.test(DxbcSyncFlag::UavMemoryGlobal)) { memoryScope = spv::ScopeDevice; - memorySemantics |= spv::MemorySemanticsUniformMemoryMask; + memorySemantics |= spv::MemorySemanticsImageMemoryMask + | spv::MemorySemanticsUniformMemoryMask + | spv::MemorySemanticsAcquireReleaseMask; } - if (executionScope != 0) { + if (executionScope != spv::ScopeInvocation) { m_module.opControlBarrier( m_module.constu32(executionScope), m_module.constu32(memoryScope), m_module.constu32(memorySemantics)); - } else if (memorySemantics != spv::MemorySemanticsMaskNone) { + } else if (memoryScope != spv::ScopeInvocation) { m_module.opMemoryBarrier( m_module.constu32(memoryScope), m_module.constu32(memorySemantics));