If we have a loop, instructions before the tex might be added as tex uses, and those may in fact dominate all other uses of the tex results. This however doesn't mean that we don't need a texbar after the tex. Only check if uses dominate each other if they either both dominate the tex, or are both dominated by the tex.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96565 Fixes: 7752bbc44 (gk104/ir: simplify and fool-proof texbar algorithm) Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu> Cc: "11.2 12.0" <mesa-sta...@lists.freedesktop.org> --- .../nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 71013eb..2aeae53 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -172,16 +172,25 @@ NVC0LegalizePostRA::addTexUse(std::list<TexUse> &uses, Instruction *usei, const Instruction *texi) { bool add = true; + bool dominated = insnDominatedBy(usei, texi); for (std::list<TexUse>::iterator it = uses.begin(); it != uses.end();) { - if (insnDominatedBy(usei, it->insn)) { - add = false; - break; + // Check if an existing use is on the "same side" of the tex instruction + // as the new use. If it is, then we can either discard the new use or + // remove the old one. Otherwise we have to keep both, since an earlier + // use may dominate a later one, but if the tex is in between, that + // doesn't matter. + if (dominated == insnDominatedBy(it->insn, texi)) { + if (insnDominatedBy(usei, it->insn)) { + add = false; + break; + } + if (insnDominatedBy(it->insn, usei)) { + it = uses.erase(it); + continue; + } } - if (insnDominatedBy(it->insn, usei)) - it = uses.erase(it); - else - ++it; + ++it; } if (add) uses.push_back(TexUse(usei, texi)); -- 2.7.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev