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 <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23813>
(cherry picked from commit 34163e19f7)
This commit is contained in:
Gert Wollny 2023-06-22 23:03:40 +02:00 committed by Eric Engestrom
parent 4a288b1dd5
commit 2ac642c5f9
2 changed files with 41 additions and 1 deletions

View file

@ -1102,7 +1102,7 @@
"description": "r600/sfn: Don't clear clear group flag on vec4 that comes from TEX or FETCH",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "f3415cb26a62289fed9cb5f202088168add43cfd"
},

View file

@ -733,6 +733,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)
{
@ -758,6 +788,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)