pan/mdg: Schedule based on liveness
[mesa.git] / src / panfrost / midgard / mir.c
index 0bb87c8fe004573098f97b331840d295dcb7262b..343c4bdb1d76a191fe7865603b6c8cf5e40e2fb0 100644 (file)
@@ -71,6 +71,10 @@ mir_rewrite_index_dst(compiler_context *ctx, unsigned old, unsigned new)
         mir_foreach_instr_global(ctx, ins) {
                 mir_rewrite_index_dst_single(ins, old, new);
         }
+
+        /* Implicitly written before the shader */
+        if (ctx->blend_input == old)
+                ctx->blend_input = new;
 }
 
 void
@@ -268,20 +272,6 @@ mir_bytemask_of_read_components_single(unsigned *swizzle, unsigned inmask, unsig
 uint16_t
 mir_bytemask_of_read_components_index(midgard_instruction *ins, unsigned i)
 {
-        if (ins->compact_branch && ins->writeout && (i == 0)) {
-                /* Non-ZS writeout uses all components */
-                if (!ins->writeout_depth && !ins->writeout_stencil)
-                        return 0xFFFF;
-
-                /* For ZS-writeout, if both Z and S are written we need two
-                 * components, otherwise we only need one.
-                 */
-                if (ins->writeout_depth && ins->writeout_stencil)
-                        return 0xFF;
-                else
-                        return 0xF;
-        }
-
         /* Conditional branches read one 32-bit component = 4 bytes (TODO: multi branch??) */
         if (ins->compact_branch && ins->branch.conditional && (i == 0))
                 return 0xF;
@@ -289,7 +279,7 @@ mir_bytemask_of_read_components_index(midgard_instruction *ins, unsigned i)
         /* ALU ops act componentwise so we need to pay attention to
          * their mask. Texture/ldst does not so we don't clamp source
          * readmasks based on the writemask */
-        unsigned qmask = (ins->type == TAG_ALU_4) ? ins->mask : ~0;
+        unsigned qmask = ~0;
 
         /* Handle dot products and things */
         if (ins->type == TAG_ALU_4 && !ins->compact_branch) {
@@ -299,6 +289,8 @@ mir_bytemask_of_read_components_index(midgard_instruction *ins, unsigned i)
 
                 if (channel_override)
                         qmask = mask_of(channel_override);
+                else
+                        qmask = ins->mask;
         }
 
         return mir_bytemask_of_read_components_single(ins->swizzle[i], qmask,
@@ -445,6 +437,10 @@ mir_flip(midgard_instruction *ins)
         ins->src_neg[0] = ins->src_neg[1];
         ins->src_neg[1] = temp;
 
+        temp = ins->src_invert[0];
+        ins->src_invert[0] = ins->src_invert[1];
+        ins->src_invert[1] = temp;
+
         unsigned temp_swizzle[16];
         memcpy(temp_swizzle, ins->swizzle[0], sizeof(ins->swizzle[0]));
         memcpy(ins->swizzle[0], ins->swizzle[1], sizeof(ins->swizzle[0]));