From 6d839addf953630afa52200d5e9922646227d84d Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 2 Mar 2020 13:56:50 +0000 Subject: [PATCH] spirv: improve creation of memory_barrier It shouldn't check for atomic counters or return in case we also need to create a TCS output barrier. Reviewed-by: Caio Marcelo de Oliveira Filho Part-of: --- src/compiler/spirv/spirv_to_nir.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 5ee75877e8b..9403a314b52 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -3605,9 +3605,14 @@ vtn_emit_memory_barrier(struct vtn_builder *b, SpvScope scope, /* There's only two scopes thing left */ vtn_assert(scope == SpvScopeInvocation || scope == SpvScopeDevice); - if ((semantics & all_memory_semantics) == all_memory_semantics) { - vtn_emit_barrier(b, nir_intrinsic_memory_barrier); - return; + /* Map the GLSL memoryBarrier() construct to the corresponding NIR one. */ + static const SpvMemorySemanticsMask glsl_memory_barrier = + SpvMemorySemanticsUniformMemoryMask | + SpvMemorySemanticsWorkgroupMemoryMask | + SpvMemorySemanticsImageMemoryMask; + if ((semantics & glsl_memory_barrier) == glsl_memory_barrier) { + vtn_emit_barrier(b, nir_intrinsic_memory_barrier); + semantics &= ~(glsl_memory_barrier | SpvMemorySemanticsAtomicCounterMemoryMask); } /* Issue a bunch of more specific barriers */ -- 2.30.2