From ed4d2739fe078b2d7312bb9bcd38c7a2ea2548d0 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Wed, 8 Jul 2020 13:15:09 +1200 Subject: [PATCH] pan/mdg: Emit a tilebuffer wait loop when needed Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_compile.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index c312fcc5e49..a432fabc1aa 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -2478,7 +2478,7 @@ emit_fragment_epilogue(compiler_context *ctx, unsigned rt) } static midgard_block * -emit_block(compiler_context *ctx, nir_block *block) +emit_block_init(compiler_context *ctx) { midgard_block *this_block = ctx->after_block; ctx->after_block = NULL; @@ -2495,6 +2495,14 @@ emit_block(compiler_context *ctx, nir_block *block) list_inithead(&this_block->base.instructions); ctx->current_block = this_block; + return this_block; +} + +static midgard_block * +emit_block(compiler_context *ctx, nir_block *block) +{ + midgard_block *this_block = emit_block_init(ctx); + nir_foreach_instr(instr, block) { emit_instr(ctx, instr); ++ctx->instruction_count; @@ -2791,6 +2799,17 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b ctx->func = func; ctx->already_emitted = calloc(BITSET_WORDS(func->impl->ssa_alloc), sizeof(BITSET_WORD)); + if (nir->info.outputs_read && !is_blend) { + emit_block_init(ctx); + + struct midgard_instruction wait = v_branch(false, false); + wait.branch.target_type = TARGET_TILEBUF_WAIT; + + emit_mir_instruction(ctx, wait); + + ++ctx->instruction_count; + } + emit_cf_list(ctx, &func->impl->body); free(ctx->already_emitted); break; /* TODO: Multi-function shaders */ -- 2.30.2