zink: add util function for emitting ntv atomic ops

these all need specific memory params, but otherwise they're the same
as normal ops, so we can just make a helper function here to add in the memory
params

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8330>
This commit is contained in:
Mike Blumenkrantz 2020-08-04 14:27:36 -04:00 committed by Marge Bot
parent 621fb6a72a
commit 2fa1cf99b9

View file

@ -1054,6 +1054,25 @@ emit_so_outputs(struct ntv_context *ctx,
}
}
static SpvId
emit_atomic(struct ntv_context *ctx, SpvId op, SpvId type, SpvId src0, SpvId src1)
{
if (!type) //AtomicStore
return spirv_builder_emit_triop(&ctx->builder, op, src0,
emit_uint_const(ctx, 32, SpvScopeWorkgroup),
emit_uint_const(ctx, 32, SpvMemorySemanticsUniformMemoryMask | SpvMemorySemanticsReleaseMask),
src1);
if (src1)
return spirv_builder_emit_quadop(&ctx->builder, op, type, src0,
emit_uint_const(ctx, 32, SpvScopeWorkgroup),
emit_uint_const(ctx, 32, SpvMemorySemanticsUniformMemoryMask | SpvMemorySemanticsReleaseMask),
src1);
//AtomicLoad
return spirv_builder_emit_triop(&ctx->builder, op, type, src0,
emit_uint_const(ctx, 32, SpvScopeWorkgroup),
emit_uint_const(ctx, 32, SpvMemorySemanticsUniformMemoryMask | SpvMemorySemanticsAcquireMask));
}
static SpvId
emit_binop(struct ntv_context *ctx, SpvOp op, SpvId type,
SpvId src0, SpvId src1)