From 5b754410dac8ce951374bd3ef29ccbd7d883ce08 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 4 Oct 2023 11:25:36 -0400 Subject: [PATCH] agx: Require 32-bit alignment for EOT offset Fixes piles of brokenness. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 17 +++++++++++------ src/asahi/compiler/agx_pack.c | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index afa915e9cf3..b88bee797d4 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -653,16 +653,21 @@ agx_emit_block_image_store(agx_builder *b, nir_intrinsic_instr *instr) bool array = nir_intrinsic_image_array(instr); enum agx_dim dim = agx_tex_dim(nir_intrinsic_image_dim(instr), array); + /* 32-bit source physically, 16-bit in NIR, top half ignored but needed + * logically to ensure alignment. + */ + offset = agx_vec2(b, offset, agx_undef(AGX_SIZE_16)); + offset.size = AGX_SIZE_32; + /* Modified coordinate descriptor */ agx_index coords; if (array) { coords = agx_temp(b->shader, AGX_SIZE_32); - agx_emit_collect_to( - b, coords, 2, - (agx_index[]){ - ms ? agx_mov_imm(b, 16, 0) : layer, - ms ? layer : agx_mov_imm(b, 16, 0xFFFF) /* TODO: Why can't zero? */, - }); + agx_emit_collect_to(b, coords, 2, + (agx_index[]){ + ms ? agx_mov_imm(b, 16, 0) : layer, + ms ? layer : agx_undef(AGX_SIZE_16), + }); } else { coords = agx_null(); } diff --git a/src/asahi/compiler/agx_pack.c b/src/asahi/compiler/agx_pack.c index 48c102a1a62..283ce8eba5d 100644 --- a/src/asahi/compiler/agx_pack.c +++ b/src/asahi/compiler/agx_pack.c @@ -895,8 +895,8 @@ agx_pack_instr(struct util_dynarray *emission, struct util_dynarray *fixups, unsigned C = I->src[2].value; agx_index offset = I->src[1]; - assert(offset.type == AGX_INDEX_REGISTER); - assert(offset.size == AGX_SIZE_16); + assert(offset.size == AGX_SIZE_32); + assert_register_is_aligned(offset); unsigned R = offset.value; bool unk1 = true;