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>
(cherry picked from commit bf44ce61bb)
This commit is contained in:
Gert Wollny 2024-04-19 21:47:02 +02:00 committed by Eric Engestrom
parent 9bcd937968
commit 93ce419991
3 changed files with 22 additions and 5 deletions

View file

@ -34,7 +34,7 @@
"description": "r600/sfn: Use dependecies to order barriers and LDS/RAT instructions",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "fe881bf0976cf5799afba52911cdf6df45e8641f",
"notes": null

View file

@ -1364,6 +1364,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
@ -1402,6 +1418,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
@ -1464,13 +1483,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

@ -413,6 +413,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};
};