zink: move shared intrinsic offset adjustments to compiler passes

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13484>
This commit is contained in:
Mike Blumenkrantz 2021-10-20 10:19:26 -04:00 committed by Marge Bot
parent 6d31f4b7b0
commit 8a98e6fb97
2 changed files with 8 additions and 2 deletions

View file

@ -2179,7 +2179,7 @@ emit_load_shared(struct ntv_context *ctx, nir_intrinsic_instr *intr)
SpvId ptr_type = spirv_builder_type_pointer(&ctx->builder,
SpvStorageClassWorkgroup,
uint_type);
SpvId offset = emit_binop(ctx, SpvOpUDiv, uint_type, get_src(ctx, &intr->src[0]), emit_uint_const(ctx, 32, 4));
SpvId offset = get_src(ctx, &intr->src[0]);
SpvId constituents[NIR_MAX_VEC_COMPONENTS];
/* need to convert array -> vec */
for (unsigned i = 0; i < num_components; i++) {
@ -2209,7 +2209,7 @@ emit_store_shared(struct ntv_context *ctx, nir_intrinsic_instr *intr)
SpvId ptr_type = spirv_builder_type_pointer(&ctx->builder,
SpvStorageClassWorkgroup,
uint_type);
SpvId offset = emit_binop(ctx, SpvOpUDiv, uint_type, get_src(ctx, &intr->src[1]), emit_uint_const(ctx, 32, 4));
SpvId offset = get_src(ctx, &intr->src[1]);
for (unsigned i = 0; num_writes; i++) {
if ((wrmask >> i) & 1) {

View file

@ -675,6 +675,8 @@ rewrite_bo_access_instr(nir_builder *b, nir_instr *instr, void *data)
return true;
}
case nir_intrinsic_load_shared:
b->cursor = nir_before_instr(instr);
nir_instr_rewrite_src_ssa(instr, &intr->src[0], nir_udiv_imm(b, intr->src[0].ssa, nir_dest_bit_size(intr->dest) / 8));
/* if 64bit isn't supported, 64bit loads definitely aren't supported, so rewrite as 2x32 with cast and pray */
if (nir_dest_bit_size(intr->dest) == 64 && !has_int64) {
/* this is always scalarized */
@ -692,6 +694,10 @@ rewrite_bo_access_instr(nir_builder *b, nir_instr *instr, void *data)
b->cursor = nir_before_instr(instr);
nir_instr_rewrite_src_ssa(instr, &intr->src[2], nir_udiv_imm(b, intr->src[2].ssa, MIN2(nir_src_bit_size(intr->src[0]), 32) / 8));
return true;
case nir_intrinsic_store_shared:
b->cursor = nir_before_instr(instr);
nir_instr_rewrite_src_ssa(instr, &intr->src[1], nir_udiv_imm(b, intr->src[1].ssa, MIN2(nir_src_bit_size(intr->src[0]), 32) / 8));
return true;
default:
break;
}