From c82672c9c146f215314a40afb696164bad080746 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 8 Aug 2019 09:16:05 -0700 Subject: [PATCH] pan/midgard: Account for swizzle/mask in st_vary Register allocation for varying stores is a bit different, since the instructions ignore the writemask (varyings are normalized packed/vectorized..) Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/midgard_ra.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index cf8c7b617e4..6d8f32e4480 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -771,8 +771,20 @@ install_registers_instr( ins->load_store.reg = src.reg - 26; - /* TODO: swizzle/mask */ - } else { + unsigned shift = __builtin_ctz(src.mask); + unsigned adjusted_mask = src.mask >> shift; + assert(((adjusted_mask + 1) & adjusted_mask) == 0); + + unsigned new_swizzle = 0; + for (unsigned q = 0; q < 4; ++q) { + unsigned c = (ins->load_store.swizzle >> (2*q)) & 3; + new_swizzle |= (c + shift) << (2*q); + } + + ins->load_store.swizzle = compose_swizzle( + new_swizzle, src.mask, + default_phys_reg(0), src); + } else { unsigned r = encodes_src ? args.src[0] : args.dest; -- 2.30.2