return nir_scope;
}
+static void
+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);
+
+ /* No barrier to add. */
+ if (nir_semantics == 0 || modes == 0)
+ return;
+
+ 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);
+}
+
static void
vtn_emit_scoped_memory_barrier(struct vtn_builder *b, SpvScope scope,
SpvMemorySemanticsMask semantics)
SpvMemorySemanticsOutputMemoryMask;
}
- vtn_emit_memory_barrier(b, memory_scope, memory_semantics);
+ if (b->shader->options->use_scoped_barrier) {
+ vtn_emit_scoped_control_barrier(b, execution_scope, memory_scope,
+ memory_semantics);
+ } else {
+ vtn_emit_memory_barrier(b, memory_scope, memory_semantics);
- if (execution_scope == SpvScopeWorkgroup)
- vtn_emit_barrier(b, nir_intrinsic_control_barrier);
+ if (execution_scope == SpvScopeWorkgroup)
+ vtn_emit_barrier(b, nir_intrinsic_control_barrier);
+ }
break;
}