From 9b7452c5e6f140797cfa8c06d49df716d99b83ac Mon Sep 17 00:00:00 2001 From: Danylo Piliaiev Date: Mon, 24 Apr 2023 16:39:44 +0200 Subject: [PATCH] ir3/a7xx: insert lock/unlock at the end of every compute shader Add (ss)(sy) in all cases until. TODO: Set sync flags depending on real need. Signed-off-by: Danylo Piliaiev Part-of: --- src/freedreno/ir3/ir3_compiler_nir.c | 12 ++++++++++++ src/freedreno/ir3/ir3_dce.c | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 7b211e3454c..e096041c8a6 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -5004,6 +5004,18 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, } } + if (ctx->compiler->gen >= 7 && so->type == MESA_SHADER_COMPUTE) { + struct ir3_instruction *end = find_end(so->ir); + struct ir3_instruction *lock = + ir3_instr_create(ctx->block, OPC_LOCK, 0, 0); + /* TODO: This flags should be set by scheduler only when needed */ + lock->flags = IR3_INSTR_SS | IR3_INSTR_SY | IR3_INSTR_JP; + ir3_instr_move_before(lock, end); + struct ir3_instruction *unlock = + ir3_instr_create(ctx->block, OPC_UNLOCK, 0, 0); + ir3_instr_move_before(unlock, end); + } + so->branchstack = ctx->max_stack; so->pvtmem_size = ALIGN(so->pvtmem_size, compiler->pvtmem_per_fiber_align); diff --git a/src/freedreno/ir3/ir3_dce.c b/src/freedreno/ir3/ir3_dce.c index 6e0654ce96c..66a4c4c48ab 100644 --- a/src/freedreno/ir3/ir3_dce.c +++ b/src/freedreno/ir3/ir3_dce.c @@ -72,7 +72,8 @@ remove_unused_by_block(struct ir3_block *block) bool progress = false; foreach_instr_safe (instr, &block->instr_list) { if (instr->opc == OPC_END || instr->opc == OPC_CHSH || - instr->opc == OPC_CHMASK) + instr->opc == OPC_CHMASK || instr->opc == OPC_LOCK || + instr->opc == OPC_UNLOCK) continue; if (instr->flags & IR3_INSTR_UNUSED) { if (instr->opc == OPC_META_SPLIT) {