diff options
author | Boris Brezillon <[email protected]> | 2020-05-05 10:31:02 +0200 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-06-03 07:39:52 +0000 |
commit | 3ed2123d77d50ccb984fccdcc1cfa936a18819bf (patch) | |
tree | e08ed0e1a3c7db2c028d321e132daddcd5a62157 /src/compiler/spirv | |
parent | 689acc73989987667ad744026647acc35305839b (diff) |
spirv: Use scoped barriers for SpvOpControlBarrier
If use_scoped_barrier is set to true, we don't have to split the control
and memory barriers.
Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4900>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r-- | src/compiler/spirv/spirv_to_nir.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 7f8b1f07e02..92ccc10654c 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2126,6 +2126,26 @@ vtn_scope_to_nir_scope(struct vtn_builder *b, SpvScope 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) { @@ -3673,10 +3693,15 @@ vtn_handle_barrier(struct vtn_builder *b, SpvOp opcode, 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; } |