spirv: improve creation of memory_barrier
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 2 Mar 2020 13:56:50 +0000 (13:56 +0000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 3 Mar 2020 11:49:40 +0000 (11:49 +0000)
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 <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4003>

src/compiler/spirv/spirv_to_nir.c

index 5ee75877e8b10f9f2d583e17d4cd3f951899bc68..9403a314b52c705ae2e5ae91257e0f2423788b1e 100644 (file)
@@ -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 */