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