diff --git a/reference/opt/shaders/comp/barriers.comp b/reference/opt/shaders/comp/barriers.comp index a091497a..7dfde372 100644 --- a/reference/opt/shaders/comp/barriers.comp +++ b/reference/opt/shaders/comp/barriers.comp @@ -8,21 +8,15 @@ void main() memoryBarrierImage(); memoryBarrierBuffer(); groupMemoryBarrier(); - memoryBarrierShared(); barrier(); memoryBarrier(); - memoryBarrierShared(); barrier(); memoryBarrierImage(); - memoryBarrierShared(); barrier(); memoryBarrierBuffer(); - memoryBarrierShared(); barrier(); groupMemoryBarrier(); - memoryBarrierShared(); barrier(); - memoryBarrierShared(); barrier(); } diff --git a/reference/opt/shaders/comp/shared.comp b/reference/opt/shaders/comp/shared.comp index f95cb2b8..62cf4a4b 100644 --- a/reference/opt/shaders/comp/shared.comp +++ b/reference/opt/shaders/comp/shared.comp @@ -16,7 +16,6 @@ shared float sShared[4]; void main() { sShared[gl_LocalInvocationIndex] = _22.in_data[gl_GlobalInvocationID.x]; - memoryBarrierShared(); barrier(); _44.out_data[gl_GlobalInvocationID.x] = sShared[3u - gl_LocalInvocationIndex]; } diff --git a/reference/shaders/comp/barriers.comp b/reference/shaders/comp/barriers.comp index a1b975de..1102c91e 100644 --- a/reference/shaders/comp/barriers.comp +++ b/reference/shaders/comp/barriers.comp @@ -28,41 +28,35 @@ void group_barrier() void barrier_shared_exec() { - memoryBarrierShared(); barrier(); } void full_barrier_exec() { memoryBarrier(); - memoryBarrierShared(); barrier(); } void image_barrier_exec() { memoryBarrierImage(); - memoryBarrierShared(); barrier(); } void buffer_barrier_exec() { memoryBarrierBuffer(); - memoryBarrierShared(); barrier(); } void group_barrier_exec() { groupMemoryBarrier(); - memoryBarrierShared(); barrier(); } void exec_barrier() { - memoryBarrierShared(); barrier(); } diff --git a/reference/shaders/comp/shared.comp b/reference/shaders/comp/shared.comp index d0987a65..545ef22e 100644 --- a/reference/shaders/comp/shared.comp +++ b/reference/shaders/comp/shared.comp @@ -18,7 +18,6 @@ void main() uint ident = gl_GlobalInvocationID.x; float idata = _22.in_data[ident]; sShared[gl_LocalInvocationIndex] = idata; - memoryBarrierShared(); barrier(); _44.out_data[ident] = sShared[(4u - gl_LocalInvocationIndex) - 1u]; } diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index 5bfec075..4d8edba5 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -9892,7 +9892,12 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) if (memory == ScopeWorkgroup) // Only need to consider memory within a group { if (semantics == MemorySemanticsWorkgroupMemoryMask) - statement("memoryBarrierShared();"); + { + // OpControlBarrier implies a memory barrier for shared memory as well. + bool implies_shared_barrier = opcode == OpControlBarrier && execution_scope == ScopeWorkgroup; + if (!implies_shared_barrier) + statement("memoryBarrierShared();"); + } else if (semantics != 0) statement("groupMemoryBarrier();"); }