r600/sfn: Use dependecies to order barriers and LDS/RAT instructions

This gives more freedom to schedule the group barrier and removes
the need to add blocks around a barrier to keep the scheduler in
check. This should avoid emitting some CF instructions.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11002

Fixes: fe881bf097
    r600/sfn: move kill handling fully to scheduling

v2: grammar fixes (lorn10)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28840>
This commit is contained in:
Gert Wollny 2024-04-19 21:47:02 +02:00 committed by Marge Bot
parent a61b658d5f
commit bf44ce61bb
2 changed files with 21 additions and 4 deletions

View file

@ -1344,6 +1344,22 @@ void Shader::InstructionChain::visit(AluInstr *instr)
}
}
}
if (instr->has_lds_access()) {
last_lds_access = instr;
if (last_group_barrier)
instr->add_required_instr(last_group_barrier);
}
if (!instr->has_alu_flag(alu_is_lds) &&
instr->opcode() == op0_group_barrier) {
last_group_barrier = instr;
if (last_lds_access)
instr->add_required_instr(last_group_barrier);
if (last_ssbo_instr)
instr->add_required_instr(last_ssbo_instr);
}
}
void
@ -1382,6 +1398,9 @@ Shader::InstructionChain::visit(RatInstr *instr)
if (last_kill_instr)
instr->add_required_instr(last_kill_instr);
if (last_group_barrier)
instr->add_required_instr(last_group_barrier);
}
void
@ -1444,13 +1463,9 @@ Shader::emit_group_barrier(nir_intrinsic_instr *intr)
{
assert(m_control_flow_depth == 0);
(void)intr;
/* Put barrier into it's own block, so that optimizers and the
* scheduler don't move code */
start_new_block(0);
auto op = new AluInstr(op0_group_barrier, 0);
op->set_alu_flag(alu_last_instr);
emit_instruction(op);
start_new_block(0);
return true;
}

View file

@ -393,6 +393,8 @@ private:
Instr *last_gds_instr{nullptr};
Instr *last_ssbo_instr{nullptr};
Instr *last_kill_instr{nullptr};
Instr *last_lds_access{nullptr};
Instr *last_group_barrier{nullptr};
std::unordered_map<int, Instr * > last_alu_with_indirect_reg;
bool prepare_mem_barrier{false};
};