Mesa (main): pan/bi: Create a nop clause when the shader starts with ATEST

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 13 12:45:26 UTC 2021


Module: Mesa
Branch: main
Commit: 4531de487e35ff4047f305de43824d158ad27be2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4531de487e35ff4047f305de43824d158ad27be2

Author: Icecream95 <ixn at disroot.org>
Date:   Tue Jul 13 20:01:07 2021 +1200

pan/bi: Create a nop clause when the shader starts with ATEST

Otherwise there would be no clause with the dependencies needed for
ATEST set, so the GPU would get stuck.

Not needed on v7, as there shader_wait_dependency in the RSD will wait
for the dependencies before the shader starts.

Explicitly create a NOP instruction, as it is assumed that clauses
have a non-zero count of instructions in various places.

Fixes GPU timeouts in many applications, such as SuperTuxKart and
GZDoom.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11842>

---

 src/panfrost/bifrost/bi_schedule.c | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c
index 624a002bf29..225eeab5fa6 100644
--- a/src/panfrost/bifrost/bi_schedule.c
+++ b/src/panfrost/bifrost/bi_schedule.c
@@ -1882,6 +1882,45 @@ bi_lower_fau(bi_context *ctx)
         }
 }
 
+/* On v6, ATEST cannot be the first clause of a shader, add a NOP if needed */
+
+static void
+bi_add_nop_for_atest(bi_context *ctx)
+{
+        /* Only needed on v6 */
+        if (ctx->arch >= 7)
+                return;
+
+        if (list_is_empty(&ctx->blocks))
+                return;
+
+        /* Fetch the first clause of the shader */
+        pan_block *block = list_first_entry(&ctx->blocks, pan_block, link);
+        bi_clause *clause = bi_next_clause(ctx, block, NULL);
+
+        if (!clause || clause->message_type != BIFROST_MESSAGE_ATEST)
+                return;
+
+        /* Add a NOP so we can wait for the dependencies required for ATEST to
+         * execute */
+
+        bi_instr *I = rzalloc(ctx, bi_instr);
+        I->op = BI_OPCODE_NOP_I32;
+        I->dest[0] = bi_null();
+
+        bi_clause *new_clause = ralloc(ctx, bi_clause);
+        *new_clause = (bi_clause) {
+                .flow_control = BIFROST_FLOW_NBTB,
+                .next_clause_prefetch = true,
+                .block = clause->block,
+
+                .tuple_count = 1,
+                .tuples[0] = { .fma = I, },
+        };
+
+        list_add(&new_clause->link, &clause->block->clauses);
+}
+
 void
 bi_schedule(bi_context *ctx)
 {
@@ -1894,6 +1933,7 @@ bi_schedule(bi_context *ctx)
         }
 
         bi_opt_dce_post_ra(ctx);
+        bi_add_nop_for_atest(ctx);
 }
 
 #ifndef NDEBUG



More information about the mesa-commit mailing list