From 4bd0e1d0971a8350559bc4ef6c293ac137fa8dfe Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 3 Mar 2023 15:25:42 -0500 Subject: [PATCH] agx/lower_address: Handle 8-bit load/store Should work ok with the implicit up-conversion that the backend does. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_nir_lower_address.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/asahi/compiler/agx_nir_lower_address.c b/src/asahi/compiler/agx_nir_lower_address.c index 7622c502aa9..4a69c4820d1 100644 --- a/src/asahi/compiler/agx_nir_lower_address.c +++ b/src/asahi/compiler/agx_nir_lower_address.c @@ -164,6 +164,21 @@ match_address(nir_builder *b, nir_ssa_scalar base, int8_t format_shift) return match; } +static enum pipe_format +format_for_bitsize(unsigned bitsize) +{ + switch (bitsize) { + case 8: + return PIPE_FORMAT_R8_UINT; + case 16: + return PIPE_FORMAT_R16_UINT; + case 32: + return PIPE_FORMAT_R32_UINT; + default: + unreachable("should have been lowered"); + } +} + static bool pass(struct nir_builder *b, nir_instr *instr, UNUSED void *data) { @@ -181,12 +196,7 @@ pass(struct nir_builder *b, nir_instr *instr, UNUSED void *data) unsigned bitsize = intr->intrinsic == nir_intrinsic_store_global ? nir_src_bit_size(intr->src[0]) : nir_dest_bit_size(intr->dest); - - /* TODO: Handle more sizes */ - assert(bitsize == 16 || bitsize == 32); - enum pipe_format format = - bitsize == 32 ? PIPE_FORMAT_R32_UINT : PIPE_FORMAT_R16_UINT; - + enum pipe_format format = format_for_bitsize(bitsize); unsigned format_shift = util_logbase2(util_format_get_blocksize(format)); nir_src *orig_offset = nir_get_io_offset_src(intr);