diff options
author | Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | 2021-10-20 10:19:26 -0400 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-10-27 17:13:26 +0000 |
commit | 8a98e6fb97cb264e822d1b1b3ba6c333fb727a81 (patch) | |
tree | b7abe434f2ccf07d70ff732c6c406765e61b4b38 | |
parent | 6d31f4b7b0776e3f97b88007853ae0eb36233933 (diff) |
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>
-rw-r--r-- | src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/zink/zink_compiler.c | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index 6a615bdb880..3b6eb9f6ace 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -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) { diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 6f5d4f8f57e..1847e341a58 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -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; } |