pan/bi: Ignore swizzle in unwritten component
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 27 Mar 2020 18:40:30 +0000 (14:40 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 31 Mar 2020 01:12:26 +0000 (01:12 +0000)
Otherwise we can trip the assert for no good reason.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4382>

src/panfrost/bifrost/bi_ra.c
src/panfrost/bifrost/bir.c
src/panfrost/bifrost/compiler.h

index f7feec222bd9a4551c158fe6d74ff38889cf10a9..6533d66b7df99cdc05d96d668fe4e65e6d007800 100644 (file)
@@ -128,6 +128,10 @@ bi_adjust_src_ra(bi_instruction *ins, struct lcra_state *l, unsigned src)
                 unsigned components = bi_get_component_count(ins, src);
 
                 for (unsigned i = 0; i < components; ++i) {
+                        /* If we're not writing the component, who cares? */
+                        if (!bi_writes_component(ins, i))
+                                continue;
+
                         unsigned off = ins->swizzle[src][i] / comps_per_reg;
                         off *= 4; /* 32-bit registers */
 
index cb24f4590961c08d96c1e8f0318dfe19025b30e5..8256c45a7806169d93e528db29daf04b83d29cf2 100644 (file)
@@ -144,3 +144,11 @@ bi_get_immediate(bi_instruction *ins, unsigned index)
         unsigned shift = index & ~BIR_INDEX_CONSTANT;
         return ins->constant.u64 >> shift;
 }
+
+bool
+bi_writes_component(bi_instruction *ins, unsigned comp)
+{
+        nir_alu_type T = ins->dest_type;
+        unsigned size = nir_alu_type_get_type_size(T);
+        return ins->writemask & (0xF << (comp * (size / 8)));
+}
index 3a895c2a6d116d666b118b256ac03f86175f6a10..554cd4e93d730bb2029a9df4f27b1d09632be792 100644 (file)
@@ -539,6 +539,7 @@ unsigned bi_get_component_count(bi_instruction *ins, unsigned s);
 unsigned bi_load32_components(bi_instruction *ins);
 uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node);
 uint64_t bi_get_immediate(bi_instruction *ins, unsigned index);
+bool bi_writes_component(bi_instruction *ins, unsigned comp);
 
 /* BIR passes */