pan/midgard: Compute destination override
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 13 Nov 2019 12:58:48 +0000 (07:58 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 25 Dec 2019 00:23:02 +0000 (19:23 -0500)
We shift over the mask in this case.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/midgard_emit.c

index bda01acce8baa5bdc9404b68b50fe65d1782adc2..2be6ecedc14e7125c6544881397c7a702227eff9 100644 (file)
@@ -152,6 +152,30 @@ mir_pack_swizzle_64(unsigned *swizzle, unsigned max_component)
         return packed;
 }
 
+static void
+mir_pack_mask_alu(midgard_instruction *ins)
+{
+        unsigned effective = ins->mask;
+
+        /* If we have a destination override, we need to figure out whether to
+         * override to the lower or upper half, shifting the effective mask in
+         * the latter, so AAAA.... becomes AAAA */
+
+        unsigned upper_shift = mir_upper_override(ins);
+
+        if (upper_shift) {
+                effective >>= upper_shift;
+                ins->alu.dest_override = midgard_dest_override_upper;
+        }
+
+        if (ins->alu.reg_mode == midgard_reg_mode_32)
+                ins->alu.mask = expand_writemask(effective, 4);
+        else if (ins->alu.reg_mode == midgard_reg_mode_64)
+                ins->alu.mask = expand_writemask(effective, 2);
+        else
+                ins->alu.mask = effective;
+}
+
 static void
 mir_pack_swizzle_alu(midgard_instruction *ins)
 {
@@ -321,13 +345,7 @@ emit_alu_bundle(compiler_context *ctx,
                 midgard_scalar_alu scalarized;
 
                 if (ins->unit & UNITS_ANY_VECTOR) {
-                        if (ins->alu.reg_mode == midgard_reg_mode_64)
-                                ins->alu.mask = expand_writemask(ins->mask, 2);
-                        else if (ins->alu.reg_mode == midgard_reg_mode_32)
-                                ins->alu.mask = expand_writemask(ins->mask, 4);
-                        else
-                                ins->alu.mask = ins->mask;
-
+                        mir_pack_mask_alu(ins);
                         mir_pack_swizzle_alu(ins);
                         size = sizeof(midgard_vector_alu);
                         source = &ins->alu;