spirv: Memory semantics is optional for OpControlBarrier
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 5 Jun 2020 22:58:32 +0000 (15:58 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 8 Jun 2020 15:49:24 +0000 (15:49 +0000)
Fixes: 3ed2123d77d ("spirv: Use scoped barriers for SpvOpControlBarrier")
Reviewed-by: Jordan Justen <jordan.l.justen@intel.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/5365>

src/compiler/spirv/spirv_to_nir.c

index 92ccc10654cde4d0fcf9d6db7993cd3f258db29b..cfe180c048912a4c2af711e4ab4f2f6ecae4e3a5 100644 (file)
@@ -2130,18 +2130,18 @@ vtn_emit_scoped_control_barrier(struct vtn_builder *b, SpvScope exec_scope,
                                 SpvScope mem_scope,
                                 SpvMemorySemanticsMask semantics)
 {
-   nir_memory_semantics nir_semantics;
-   nir_variable_mode modes;
-
-   nir_semantics = vtn_mem_semantics_to_nir_mem_semantics(b, semantics);
-   modes = vtn_mem_sematics_to_nir_var_modes(b, semantics);
+   nir_memory_semantics nir_semantics =
+      vtn_mem_semantics_to_nir_mem_semantics(b, semantics);
+   nir_variable_mode modes = vtn_mem_sematics_to_nir_var_modes(b, semantics);
+   nir_scope nir_exec_scope = vtn_scope_to_nir_scope(b, exec_scope);
 
-   /* No barrier to add. */
+   /* Memory semantics is optional for OpControlBarrier. */
+   nir_scope nir_mem_scope;
    if (nir_semantics == 0 || modes == 0)
-      return;
+      nir_mem_scope = NIR_SCOPE_NONE;
+   else
+      nir_mem_scope = vtn_scope_to_nir_scope(b, mem_scope);
 
-   nir_scope nir_exec_scope = vtn_scope_to_nir_scope(b, exec_scope);
-   nir_scope nir_mem_scope = vtn_scope_to_nir_scope(b, mem_scope);
    nir_scoped_barrier(&b->nb, nir_exec_scope, nir_mem_scope, nir_semantics, modes);
 }