Commit 53b9e9f7 authored by Rhys Perry's avatar Rhys Perry Committed by Erik Faye-Lund
Browse files

spirv: add vtn_emit_make_{visible,available}_barrier helpers


Signed-off-by: Rhys Perry's avatarRhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Boris Brezillon's avatarBoris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Jason Ekstrand's avatarJason Ekstrand <jason@jlekstrand.net>
Part-of: <mesa/mesa!6090>
parent b396d3bc
......@@ -2483,6 +2483,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)
......@@ -2598,13 +2622,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;
......@@ -2648,13 +2667,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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment