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

spirv: implement Volatile memory semantic


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 aa748494
......@@ -2077,7 +2077,8 @@ vtn_split_barrier_semantics(struct vtn_builder *b,
SpvMemorySemanticsOutputMemoryMask);
const SpvMemorySemanticsMask other_semantics =
semantics & ~(order_semantics | av_vis_semantics | storage_semantics);
semantics & ~(order_semantics | av_vis_semantics | storage_semantics |
SpvMemorySemanticsVolatileMask);
if (other_semantics)
vtn_warn("Ignoring unhandled memory semantics: %u\n", other_semantics);
......@@ -3029,6 +3030,9 @@ vtn_handle_image(struct vtn_builder *b, SpvOp opcode,
vtn_fail_with_opcode("Invalid image opcode", opcode);
}
if (semantics & SpvMemorySemanticsVolatileMask)
access |= ACCESS_VOLATILE;
nir_intrinsic_op op;
switch (opcode) {
#define OP(S, N) case SpvOp##S: op = nir_intrinsic_image_deref_##N; break;
......@@ -3324,6 +3328,7 @@ vtn_handle_atomics(struct vtn_builder *b, SpvOp opcode,
SpvScope scope = SpvScopeInvocation;
SpvMemorySemanticsMask semantics = 0;
enum gl_access_qualifier access = 0;
switch (opcode) {
case SpvOpAtomicLoad:
......@@ -3356,6 +3361,9 @@ vtn_handle_atomics(struct vtn_builder *b, SpvOp opcode,
vtn_fail_with_opcode("Invalid SPIR-V atomic", opcode);
}
if (semantics & SpvMemorySemanticsVolatileMask)
access |= ACCESS_VOLATILE;
/* uniform as "atomic counter uniform" */
if (ptr->mode == vtn_variable_mode_atomic_counter) {
nir_deref_instr *deref = vtn_pointer_to_deref(b, ptr);
......@@ -3411,6 +3419,8 @@ vtn_handle_atomics(struct vtn_builder *b, SpvOp opcode,
nir_intrinsic_op op = get_ssbo_nir_atomic_op(b, opcode);
atomic = nir_intrinsic_instr_create(b->nb.shader, op);
nir_intrinsic_set_access(atomic, access | ACCESS_COHERENT);
int src = 0;
switch (opcode) {
case SpvOpAtomicLoad:
......@@ -3461,6 +3471,11 @@ vtn_handle_atomics(struct vtn_builder *b, SpvOp opcode,
atomic = nir_intrinsic_instr_create(b->nb.shader, op);
atomic->src[0] = nir_src_for_ssa(&deref->dest.ssa);
if (ptr->mode != vtn_variable_mode_workgroup)
access |= ACCESS_COHERENT;
nir_intrinsic_set_access(atomic, access);
switch (opcode) {
case SpvOpAtomicLoad:
atomic->num_components = glsl_get_vector_elements(deref_type);
......
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