pan/midgard: Fix scheduling issue with csel + render target reference
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 3 Feb 2020 13:19:41 +0000 (08:19 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 5 Feb 2020 15:41:55 +0000 (15:41 +0000)
Fixes dEQP-GLES3.functional.shaders.fragdepth.write.dynamic_conditional_write

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3697>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3697>

src/panfrost/midgard/midgard_schedule.c

index 1697f086390c81d540cca1eea9f650ae0b79538b..84a4281f7ff22fb789caecab1ef47c8fdd53d7d7 100644 (file)
@@ -858,6 +858,24 @@ mir_schedule_alu(
                         unreachable("Bad condition");
         }
 
+        /* If we have a render target reference, schedule a move for it. Since
+         * this will be in sadd, we boost this to prevent scheduling csel into
+         * smul */
+
+        if (writeout && (branch->constants.u32[0] || ctx->is_blend)) {
+                sadd = ralloc(ctx, midgard_instruction);
+                *sadd = v_mov(~0, make_compiler_temp(ctx));
+                sadd->unit = UNIT_SADD;
+                sadd->mask = 0x1;
+                sadd->has_inline_constant = true;
+                sadd->inline_constant = branch->constants.u32[0];
+                branch->src[1] = sadd->dest;
+
+                /* Mask off any conditionals. Could be optimized to just scalar
+                 * conditionals TODO */
+                predicate.no_cond = true;
+        }
+
         mir_choose_alu(&smul, instructions, worklist, len, &predicate, UNIT_SMUL);
 
         if (!writeout) {
@@ -913,18 +931,6 @@ mir_schedule_alu(
                         unreachable("Bad condition");
         }
 
-        /* If we have a render target reference, schedule a move for it */
-
-        if (writeout && (branch->constants.u32[0] || ctx->is_blend)) {
-                sadd = ralloc(ctx, midgard_instruction);
-                *sadd = v_mov(~0, make_compiler_temp(ctx));
-                sadd->unit = UNIT_SADD;
-                sadd->mask = 0x1;
-                sadd->has_inline_constant = true;
-                sadd->inline_constant = branch->constants.u32[0];
-                branch->src[1] = sadd->dest;
-        }
-
         /* Stage 2, let's schedule sadd before vmul for writeout */
         mir_choose_alu(&sadd, instructions, worklist, len, &predicate, UNIT_SADD);