zink: use SpvScopeDevice over SpvScopeWorkgroup for atomic shader ops

Workgroup is only allowed in compute shaders, and Device should be more
in line with the intended use here

the alternative would be to keep using Workgroup for compute and use Device
otherwise, but this would effectively make atomic ops non-atomic, which seems
like it isn't desirable

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14690>
This commit is contained in:
Mike Blumenkrantz 2022-01-18 10:39:25 -05:00 committed by Marge Bot
parent 2361c52b5e
commit 6f38ea4ac7
1 changed files with 4 additions and 4 deletions

View File

@ -1419,16 +1419,16 @@ static SpvId
emit_atomic(struct ntv_context *ctx, SpvId op, SpvId type, SpvId src0, SpvId src1, SpvId src2)
{
if (op == SpvOpAtomicLoad)
return spirv_builder_emit_triop(&ctx->builder, op, type, src0, emit_uint_const(ctx, 32, SpvScopeWorkgroup),
return spirv_builder_emit_triop(&ctx->builder, op, type, src0, emit_uint_const(ctx, 32, SpvScopeDevice),
emit_uint_const(ctx, 32, 0));
if (op == SpvOpAtomicCompareExchange)
return spirv_builder_emit_hexop(&ctx->builder, op, type, src0, emit_uint_const(ctx, 32, SpvScopeWorkgroup),
return spirv_builder_emit_hexop(&ctx->builder, op, type, src0, emit_uint_const(ctx, 32, SpvScopeDevice),
emit_uint_const(ctx, 32, 0),
emit_uint_const(ctx, 32, 0),
/* these params are intentionally swapped */
src2, src1);
return spirv_builder_emit_quadop(&ctx->builder, op, type, src0, emit_uint_const(ctx, 32, SpvScopeWorkgroup),
return spirv_builder_emit_quadop(&ctx->builder, op, type, src0, emit_uint_const(ctx, 32, SpvScopeDevice),
emit_uint_const(ctx, 32, 0), src1);
}
@ -2051,7 +2051,7 @@ emit_store_deref(struct ntv_context *ctx, nir_intrinsic_instr *intr)
} else
result = emit_bitcast(ctx, type, src);
if (nir_intrinsic_access(intr) & ACCESS_COHERENT)
spirv_builder_emit_atomic_store(&ctx->builder, ptr, SpvScopeWorkgroup, 0, result);
spirv_builder_emit_atomic_store(&ctx->builder, ptr, SpvScopeDevice, 0, result);
else
spirv_builder_emit_store(&ctx->builder, ptr, result);
}