From e01d1a9f16da86788c1bdc47d84fb630f46218eb Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 18 Aug 2020 14:45:46 +0100 Subject: [PATCH] spirv: add vtn_emit_make_{visible,available}_barrier helpers Signed-off-by: Rhys Perry Reviewed-by: Boris Brezillon Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/spirv/vtn_variables.c | 41 ++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index a8dfcd8e933..b3948351670 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -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; } -- 2.30.2