pan/bi: Export helper termination analysis
authorAlyssa Rosenzweig <alyssa@collabora.com>
Fri, 20 May 2022 13:31:29 +0000 (09:31 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 1 Jun 2022 16:14:38 +0000 (16:14 +0000)
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@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16804>

src/panfrost/bifrost/bi_helper_invocations.c
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/bifrost/compiler.h

index c4e8dcd..cd0daac 100644 (file)
@@ -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) {
index 870b73a..f5c0865 100644 (file)
@@ -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)
index 1a2b365..71d2475 100644 (file)
@@ -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);