From 9293acfeb561fced8e05e2d08e3bd70fb5de8fff Mon Sep 17 00:00:00 2001
From: Philip Rebohle <philip.rebohle@tu-dortmund.de>
Date: Fri, 3 Aug 2018 15:15:18 +0200
Subject: [PATCH] [dxbc] Work around OpControlBarrier issue on radv 18.2-git

---
 src/dxbc/dxbc_compiler.cpp | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp
index 347b802b..5bf808f6 100644
--- a/src/dxbc/dxbc_compiler.cpp
+++ b/src/dxbc/dxbc_compiler.cpp
@@ -2319,17 +2319,20 @@ namespace dxvk {
                       |  spv::MemorySemanticsAcquireReleaseMask;
     }
     
+    // According to the SPIR-V spec, OpControlBarrier should
+    // also act as a memory barrier if the memory semantics
+    // are not 'none', but this is currently broken on RADV.
+    if (memoryScope != spv::ScopeInvocation) {
+      m_module.opMemoryBarrier(
+        m_module.constu32(memoryScope),
+        m_module.constu32(memorySemantics));
+    }
+
     if (executionScope != spv::ScopeInvocation) {
       m_module.opControlBarrier(
         m_module.constu32(executionScope),
         m_module.constu32(memoryScope),
         m_module.constu32(memorySemantics));
-    } else if (memoryScope != spv::ScopeInvocation) {
-      m_module.opMemoryBarrier(
-        m_module.constu32(memoryScope),
-        m_module.constu32(memorySemantics));
-    } else {
-      Logger::warn("DxbcCompiler: sync instruction has no effect");
     }
   }