pan/midgard: Ensure fragment writeout is in the final block
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 27 Aug 2019 19:20:06 +0000 (12:20 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 30 Aug 2019 22:50:24 +0000 (15:50 -0700)
This ensures the block only has exactly one branch, which makes
scheduling happy.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c

index e6b90e4aa48afad00a12bd9c0cee36b56159162e..7747764791f15985c75cb8e0ace954177644c096 100644 (file)
@@ -427,8 +427,9 @@ mir_exit_block(struct compiler_context *ctx)
         midgard_block *last = list_last_entry(&ctx->blocks,
                         struct midgard_block, link);
 
-        /* The last block must be empty (the exit block) */
-        assert(list_empty(&last->instructions));
+        /* The last block must be empty logically but contains branch writeout
+         * for fragment shaders */
+
         assert(last->nr_successors == 0);
 
         return last;
index 04d149f2b60afcae4eb64ffdf37ffc11c2c96983..eaa5816cc7e27bc0ebc97f6218e0e9fc59bb05f8 100644 (file)
@@ -2294,13 +2294,6 @@ emit_block(compiler_context *ctx, nir_block *block)
         midgard_opt_promote_fmov(ctx, ctx->current_block);
         embedded_to_inline_constant(ctx);
 
-        /* Append fragment shader epilogue (value writeout) */
-        if (ctx->stage == MESA_SHADER_FRAGMENT) {
-                if (block == nir_impl_last_block(ctx->func->impl)) {
-                        emit_fragment_epilogue(ctx);
-                }
-        }
-
         /* Allow the next control flow to access us retroactively, for
          * branching etc */
         ctx->current_block = this_block;
@@ -2582,6 +2575,9 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
                 struct midgard_block *end =
                         emit_block(ctx, func->impl->end_block);
 
+                if (ctx->stage == MESA_SHADER_FRAGMENT)
+                        emit_fragment_epilogue(ctx);
+
                 midgard_block_add_successor(semi_end, end);
 
                 break; /* TODO: Multi-function shaders */