From 34163e19f7a64621a7995b92fa2f79a0f933393d Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Thu, 22 Jun 2023 23:03:40 +0200 Subject: [PATCH] r600/sfn: Don't clear clear group flag on vec4 that comes from TEX or FETCH If we consider clearing the group flag of a vec4 register that is used as source for some instruction we have to take into account that the parent of the register element may also be part of a group in the parent instruction. In this case we must not clear the group flag. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9118 Fixes: f3415cb26a (r600/sfn: copy propagate register load chains) Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/sfn/sfn_optimizer.cpp | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp index d445fa3..eff6007 100644 --- a/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_optimizer.cpp @@ -740,6 +740,36 @@ public: bool progress; }; +class HasVecDestVisitor : public ConstInstrVisitor { +public: + HasVecDestVisitor(): + has_group_dest(false) + { + } + + void visit(const AluInstr& instr) override { (void)instr; } + void visit(const AluGroup& instr) override { (void)instr; } + void visit(const TexInstr& instr) override { (void)instr; has_group_dest = true; }; + void visit(const ExportInstr& instr) override { (void)instr; } + void visit(const FetchInstr& instr) override { (void)instr; has_group_dest = true; }; + void visit(const Block& instr) override { (void)instr; }; + void visit(const ControlFlowInstr& instr) override{ (void)instr; } + void visit(const IfInstr& instr) override{ (void)instr; } + void visit(const ScratchIOInstr& instr) override { (void)instr; }; + void visit(const StreamOutInstr& instr) override { (void)instr; } + void visit(const MemRingOutInstr& instr) override { (void)instr; } + void visit(const EmitVertexInstr& instr) override { (void)instr; } + void visit(const GDSInstr& instr) override { (void)instr; } + void visit(const WriteTFInstr& instr) override { (void)instr; }; + void visit(const LDSAtomicInstr& instr) override { (void)instr; }; + void visit(const LDSReadInstr& instr) override { (void)instr; }; + void visit(const RatInstr& instr) override { (void)instr; }; + + bool has_group_dest; +}; + + + bool simplify_source_vectors(Shader& sh) { @@ -765,6 +795,16 @@ SimplifySourceVecVisitor::visit(TexInstr *instr) if (nvals == 1) { for (int i = 0; i < 4; ++i) if (src[i]->chan() < 4) { + HasVecDestVisitor check_dests; + for (auto p : src[i]->parents()) { + p->accept(check_dests); + if (check_dests.has_group_dest) + break; + } + + if (check_dests.has_group_dest) + break; + if (src[i]->pin() == pin_group) src[i]->set_pin(pin_free); else if (src[i]->pin() == pin_chgr) -- 2.7.4