spirv: add vtn_emit_make_{visible,available}_barrier helpers
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 18 Aug 2020 13:45:46 +0000 (14:45 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Sep 2020 17:15:22 +0000 (17:15 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6090>

src/compiler/spirv/vtn_variables.c

index a8dfcd8e933892f3b1ad1535383fdf47ebdd4d1a..b39483516708ce3424963c93146b9bb01949e603 100644 (file)
@@ -2500,6 +2500,30 @@ vtn_mode_to_memory_semantics(enum vtn_variable_mode mode)
    }
 }
 
+static void
+vtn_emit_make_visible_barrier(struct vtn_builder *b, SpvMemoryAccessMask access,
+                              SpvScope scope, enum vtn_variable_mode mode)
+{
+   if (!(access & SpvMemoryAccessMakePointerVisibleMask))
+      return;
+
+   vtn_emit_memory_barrier(b, scope, SpvMemorySemanticsMakeVisibleMask |
+                                     SpvMemorySemanticsAcquireMask |
+                                     vtn_mode_to_memory_semantics(mode));
+}
+
+static void
+vtn_emit_make_available_barrier(struct vtn_builder *b, SpvMemoryAccessMask access,
+                                SpvScope scope, enum vtn_variable_mode mode)
+{
+   if (!(access & SpvMemoryAccessMakePointerAvailableMask))
+      return;
+
+   vtn_emit_memory_barrier(b, scope, SpvMemorySemanticsMakeAvailableMask |
+                                     SpvMemorySemanticsReleaseMask |
+                                     vtn_mode_to_memory_semantics(mode));
+}
+
 void
 vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
                      const uint32_t *w, unsigned count)
@@ -2617,13 +2641,8 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       SpvMemoryAccessMask access;
       SpvScope scope;
       vtn_get_mem_operands(b, w, count, &idx, &access, &alignment, NULL, &scope);
-      if (access & SpvMemoryAccessMakePointerVisibleMask) {
-         SpvMemorySemanticsMask semantics =
-            SpvMemorySemanticsMakeVisibleMask |
-            SpvMemorySemanticsAcquireMask |
-            vtn_mode_to_memory_semantics(src->mode);
-         vtn_emit_memory_barrier(b, scope, semantics);
-      }
+
+      vtn_emit_make_visible_barrier(b, access, scope, src->mode);
 
       vtn_push_ssa_value(b, w[2], vtn_variable_load(b, src));
       break;
@@ -2667,13 +2686,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       struct vtn_ssa_value *src = vtn_ssa_value(b, w[2]);
       vtn_variable_store(b, src, dest);
 
-      if (access & SpvMemoryAccessMakePointerAvailableMask) {
-         SpvMemorySemanticsMask semantics =
-            SpvMemorySemanticsMakeAvailableMask |
-            SpvMemorySemanticsReleaseMask |
-            vtn_mode_to_memory_semantics(dest->mode);
-         vtn_emit_memory_barrier(b, scope, semantics);
-      }
+      vtn_emit_make_available_barrier(b, access, scope, dest->mode);
       break;
    }