From d475d19f097f6c6d65cf5cc5ef149ebfbddd80e9 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 11 May 2020 15:58:58 -0400 Subject: [PATCH] pan/mdg: Only combine 16-bit constants to lower half We can't swizzle both halves simultaneously. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_schedule.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 93e7e9bb87a..18c36a8d290 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -351,7 +351,8 @@ static bool mir_adjust_constant(midgard_instruction *ins, unsigned src, unsigned *bundle_constant_mask, unsigned *comp_mapping, - uint8_t *bundle_constants) + uint8_t *bundle_constants, + bool upper) { unsigned type_size = nir_alu_type_get_type_size(ins->src_types[src]) / 8; unsigned max_comp = 16 / type_size; @@ -361,6 +362,15 @@ mir_adjust_constant(midgard_instruction *ins, unsigned src, type_size * 8); unsigned type_mask = (1 << type_size) - 1; + /* Upper only makes sense for 16-bit */ + if (type_size != 16 && upper) + return false; + + /* For 16-bit, we need to stay on either upper or lower halves to avoid + * disrupting the swizzle */ + unsigned start = upper ? 8 : 0; + unsigned length = (type_size == 2) ? 8 : 16; + for (unsigned comp = 0; comp < max_comp; comp++) { if (!(comp_mask & (1 << comp))) continue; @@ -370,7 +380,7 @@ mir_adjust_constant(midgard_instruction *ins, unsigned src, signed best_place = -1; unsigned i, j; - for (i = 0; i < 16; i += type_size) { + for (i = start; i < (start + length); i += type_size) { unsigned reuse_bytes = 0; for (j = 0; j < type_size; j++) { @@ -378,6 +388,8 @@ mir_adjust_constant(midgard_instruction *ins, unsigned src, continue; if (constantp[j] != bundle_constants[i + j]) break; + if ((i + j) > (start + length)) + break; reuse_bytes++; } @@ -445,7 +457,7 @@ mir_adjust_constants(midgard_instruction *ins, continue; if (!mir_adjust_constant(ins, src, &bundle_constant_mask, - comp_mapping[src], bundle_constants)) + comp_mapping[src], bundle_constants, false)) return false; } -- 2.30.2