From c4a3e8981d5a72c62fbaf8d03df259d5103bbbf0 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 11 Aug 2025 23:35:57 +0200 Subject: [PATCH] r600/sfn: rework testing readport config for more than one source When checking the readport config for a number of sources that would be used in a multi-slot instruction, then return the index of the source for which readport allocation fails. With that we can later add a mov instruction to change the source channels configuration. In addition pass a std::array instead of a C-array to make the interface more c++-like and prepare for the next patch. Signed-off-by: Gert Wollny Part-of: --- .../r600/sfn/sfn_alu_readport_validation.cpp | 9 ++++++--- .../drivers/r600/sfn/sfn_alu_readport_validation.h | 4 +++- src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp | 8 ++++---- src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp | 13 ++++++++----- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.cpp b/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.cpp index 91d348971ae..0f0e2895f03 100644 --- a/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.cpp @@ -71,8 +71,8 @@ public: void visit(const UniformValue& value) override; }; -bool -AluReadportReservation::schedule_vec_src(PVirtualValue src[3], +unsigned +AluReadportReservation::schedule_vec_src(const std::array& src, int nsrc, AluBankSwizzle swz) { @@ -90,9 +90,12 @@ AluReadportReservation::schedule_vec_src(PVirtualValue src[3], visitor.cycle = cycle_vec(swz, i); visitor.isrc = i; src[i]->accept(visitor); + if (!visitor.success) { + return i; + } } - return visitor.success; + return nsrc; } bool diff --git a/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.h b/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.h index 1654951faa0..982b212efe6 100644 --- a/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.h +++ b/src/gallium/drivers/r600/sfn/sfn_alu_readport_validation.h @@ -17,7 +17,9 @@ public: AluReadportReservation(const AluReadportReservation& orig) = default; AluReadportReservation& operator=(const AluReadportReservation& orig) = default; - bool schedule_vec_src(PVirtualValue src[3], int nsrc, AluBankSwizzle swz); + unsigned schedule_vec_src(const std::array& src, + int nsrc, + AluBankSwizzle swz); bool schedule_vec_instruction(const AluInstr& alu, AluBankSwizzle swz); bool schedule_trans_instruction(const AluInstr& alu, AluBankSwizzle swz); diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp b/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp index 5fda5ada7da..72ba5f70f79 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instr_alu.cpp @@ -711,7 +711,7 @@ AluInstr::check_readport_validation(PRegister old_src, PVirtualValue new_src) co assert(nsrc * m_alu_slots == m_src.size()); for (int s = 0; s < m_alu_slots && success; ++s) { - PVirtualValue src[3]; + std::array src; auto ireg = m_src.begin() + s * nsrc; for (unsigned i = 0; i < nsrc; ++i, ++ireg) @@ -720,7 +720,7 @@ AluInstr::check_readport_validation(PRegister old_src, PVirtualValue new_src) co AluBankSwizzle bs = alu_vec_012; while (bs != alu_vec_unknown) { AluReadportReservation rpr = rpr_sum; - if (rpr.schedule_vec_src(src, nsrc, bs)) { + if (rpr.schedule_vec_src(src, nsrc, bs) == nsrc) { rpr_sum = rpr; break; } @@ -877,7 +877,7 @@ AluInstr::split(ValueFactory& vf, AluGroup& group) assert(nsrc * m_alu_slots == m_src.size()); for (int s = 0; s < m_alu_slots; ++s) { - PVirtualValue src[3]; + std::array src; auto ireg = m_src.begin() + s * nsrc; for (unsigned i = 0; i < nsrc; ++i, ++ireg) @@ -886,7 +886,7 @@ AluInstr::split(ValueFactory& vf, AluGroup& group) AluBankSwizzle bs = alu_vec_012; while (bs != alu_vec_unknown) { AluReadportReservation rpr = rr; - if (rpr.schedule_vec_src(src, nsrc, bs)) { + if (rpr.schedule_vec_src(src, nsrc, bs) == nsrc) { rr = rpr; break; } diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp b/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp index 925240bf77b..6c456b5dfe0 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp @@ -327,16 +327,19 @@ bool AluGroup::replace_source(PRegister old_src, PVirtualValue new_src) auto& srcs = m_slots[slot]->sources(); - PVirtualValue test_src[3]; - std::transform(srcs.begin(), srcs.end(), test_src, + std::array test_src; + std::transform(srcs.begin(), + srcs.end(), + test_src.begin(), [old_src, new_src](PVirtualValue s) { - return old_src->equal_to(*s) ? new_src : s; - }); + return old_src->equal_to(*s) ? new_src : s; + }); AluBankSwizzle bs = alu_vec_012; while (bs != alu_vec_unknown) { AluReadportReservation rpr = rpr_sum; - if (rpr.schedule_vec_src(test_src,srcs.size(), bs)) { + unsigned nsrc = srcs.size(); + if (rpr.schedule_vec_src(test_src, nsrc, bs) == nsrc) { rpr_sum = rpr; break; }