Mesa (main): pan/bi: Export helper termination analysis

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 1 16:29:30 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Fri May 20 09:31:29 2022 -0400

pan/bi: Export helper termination analysis

The current helper termination analysis code is hardwired for clauses, so it
won't work for Valhall. However, the bulk of it is dataflow analysis which is
portable between Bifrost and Valhall. Export the interesting bits so we can
reuse them on Valhall.

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

---

 src/panfrost/bifrost/bi_helper_invocations.c | 11 +++++++++--
 src/panfrost/bifrost/bifrost_compile.c       |  5 +++--
 src/panfrost/bifrost/compiler.h              |  4 ++++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/panfrost/bifrost/bi_helper_invocations.c b/src/panfrost/bifrost/bi_helper_invocations.c
index c4e8dcd7a9d..cd0daac2d1d 100644
--- a/src/panfrost/bifrost/bi_helper_invocations.c
+++ b/src/panfrost/bifrost/bi_helper_invocations.c
@@ -83,7 +83,7 @@ bi_has_skip_bit(enum bi_opcode op)
  * reads from other subgroup lanes)? This only applies to fragment shaders.
  * Other shader stages do not have a notion of helper threads. */
 
-static bool
+bool
 bi_instr_uses_helpers(bi_instr *I)
 {
         switch (I->op) {
@@ -120,7 +120,7 @@ bi_block_uses_helpers(bi_block *block)
         return false;
 }
 
-static bool
+bool
 bi_block_terminates_helpers(bi_block *block)
 {
         /* Can't terminate if a successor needs helpers */
@@ -169,6 +169,13 @@ bi_analyze_helper_terminate(bi_context *ctx)
                 if (block->pass_flags == 0 && bi_block_uses_helpers(block))
                         bi_propagate_pass_flag(block);
         }
+}
+
+void
+bi_mark_clauses_td(bi_context *ctx)
+{
+        if (ctx->stage != MESA_SHADER_FRAGMENT || ctx->inputs->is_blend)
+                return;
 
         /* Finally, mark clauses requiring helpers */
         bi_foreach_block(ctx, block) {
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 870b73a83fc..f5c0865393d 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -5080,10 +5080,11 @@ bi_compile_variant_nir(nir_shader *nir,
                 bi_assign_scoreboard(ctx);
 
                 /* Analyze after scheduling since we depend on instruction
-                 * order. This routine assumes the IR is using clauses, so it is
-                 * Bifrost only.
+                 * order. Valhall calls as part of va_insert_flow_control_nops,
+                 * as the handling for clauses differs from instructions.
                  */
                 bi_analyze_helper_terminate(ctx);
+                bi_mark_clauses_td(ctx);
         }
 
         if (bifrost_debug & BIFROST_DBG_SHADERS && !skip_internal)
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 1a2b365f5b8..71d24750d37 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -1074,7 +1074,11 @@ void bi_print_shader(bi_context *ctx, FILE *fp);
 
 /* BIR passes */
 
+bool bi_instr_uses_helpers(bi_instr *I);
+bool bi_block_terminates_helpers(bi_block *block);
 void bi_analyze_helper_terminate(bi_context *ctx);
+void bi_mark_clauses_td(bi_context *ctx);
+
 void bi_analyze_helper_requirements(bi_context *ctx);
 void bi_opt_copy_prop(bi_context *ctx);
 void bi_opt_cse(bi_context *ctx);



More information about the mesa-commit mailing list