r600/sfn: factor out index loading for non-alu instructions

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21347>
This commit is contained in:
Gert Wollny
2023-04-16 09:52:06 +02:00
committed by Marge Bot
parent 9f39531743
commit 5da9f08657

View File

@@ -81,6 +81,8 @@ public:
PVirtualValue copy_src(r600_bytecode_alu_src& src, const VirtualValue& s);
EBufferIndexMode emit_index_reg(const VirtualValue& addr, unsigned idx);
EBufferIndexMode get_index_mode(const InstrWithResource& instr,
unsigned idx);
void emit_endif();
void emit_else();
@@ -479,11 +481,7 @@ AssamblerVisitor::visit(const TexInstr& tex_instr)
{
clear_states(sf_vtx | sf_alu);
auto addr = tex_instr.resource_offset();
EBufferIndexMode index_mode = bim_none;
if (addr)
index_mode = emit_index_reg(*addr, 1);
EBufferIndexMode index_mode = get_index_mode(tex_instr, 1);
if (tex_fetch_results.find(tex_instr.src().sel()) != tex_fetch_results.end()) {
m_bc->force_add_cf = 1;
@@ -686,11 +684,7 @@ AssamblerVisitor::visit(const FetchInstr& fetch_instr)
clear_states(clear_flags | sf_alu);
auto buffer_offset = fetch_instr.resource_offset();
EBufferIndexMode rat_index_mode = bim_none;
if (buffer_offset)
rat_index_mode = emit_index_reg(*buffer_offset, 0);
EBufferIndexMode index_mode = get_index_mode(fetch_instr, 0);
if (fetch_instr.has_fetch_flag(FetchInstr::wait_ack))
emit_wait_ack();
@@ -731,7 +725,7 @@ AssamblerVisitor::visit(const FetchInstr& fetch_instr)
vtx.num_format_all = fetch_instr.num_format(); /* NUM_FORMAT_SCALED */
vtx.format_comp_all = fetch_instr.has_fetch_flag(FetchInstr::format_comp_signed);
vtx.endian = fetch_instr.endian_swap();
vtx.buffer_index_mode = rat_index_mode;
vtx.buffer_index_mode = index_mode;
vtx.offset = fetch_instr.src_offset();
vtx.indexed = fetch_instr.has_fetch_flag(FetchInstr::indexed);
vtx.uncached = fetch_instr.has_fetch_flag(FetchInstr::uncached);
@@ -811,12 +805,10 @@ AssamblerVisitor::visit(const RatInstr& instr)
if (m_ack_suggested /*&& instr.has_instr_flag(Instr::ack_rat_return_write)*/)
emit_wait_ack();
int rat_idx = instr.resource_base();
EBufferIndexMode rat_index_mode = bim_none;
auto addr = instr.resource_offset();
if (addr)
rat_index_mode = emit_index_reg(*addr, 1);
EBufferIndexMode index_mode = get_index_mode(instr, 1);
int rat_idx = instr.resource_base();
memset(&gds, 0, sizeof(struct r600_bytecode_gds));
@@ -824,7 +816,7 @@ AssamblerVisitor::visit(const RatInstr& instr)
auto cf = m_bc->cf_last;
cf->rat.id = rat_idx + m_shader->rat_base;
cf->rat.inst = instr.rat_op();
cf->rat.index_mode = rat_index_mode;
cf->rat.index_mode = index_mode;
cf->output.type = instr.need_ack() ? 3 : 1;
cf->output.gpr = instr.data_gpr();
cf->output.index_gpr = instr.index_gpr();
@@ -977,19 +969,13 @@ AssamblerVisitor::visit(const GDSInstr& instr)
{
struct r600_bytecode_gds gds;
bool indirect = false;
auto addr = instr.resource_offset();
if (addr) {
indirect = true;
emit_index_reg(*addr, 1);
}
EBufferIndexMode index_mode = get_index_mode(instr, 0);
memset(&gds, 0, sizeof(struct r600_bytecode_gds));
gds.op = ds_opcode_map.at(instr.opcode());
gds.uav_id = instr.resource_base();
gds.uav_index_mode = indirect ? bim_one : bim_none;
gds.uav_index_mode = index_mode;
gds.src_gpr = instr.src().sel();
gds.src_sel_x = instr.src()[0]->chan() < 7 ? instr.src()[0]->chan() : 4;
@@ -1200,15 +1186,27 @@ AssamblerVisitor::copy_dst(r600_bytecode_alu_dst& dst, const Register& d, bool w
dst.sel = d.sel();
dst.chan = d.chan();
if (m_bc->index_reg[1] == dst.sel && m_bc->index_reg_chan[1] == dst.chan)
m_bc->index_loaded[1] = false;
if (m_bc->index_reg[0] == dst.sel && m_bc->index_reg_chan[0] == dst.chan)
m_bc->index_loaded[0] = false;
for (int i = 0; i < 2; ++i) {
/* Force emitting index register, if we didn't emit it yet, because
* the register value will change now */
if (dst.sel == m_bc->index_reg[i] && dst.chan == m_bc->index_reg_chan[i])
m_bc->index_loaded[i] = false;
}
return true;
}
EBufferIndexMode AssamblerVisitor::get_index_mode(const InstrWithResource& instr,
unsigned idx)
{
EBufferIndexMode index_mode = instr.buffer_index_mode();
if (index_mode == bim_none && instr.resource_offset())
index_mode = emit_index_reg(*instr.resource_offset(), idx);
return index_mode;
}
void
AssamblerVisitor::emit_wait_ack()
{