Mesa (10.3): nvc0/ir: clarify recursion fix to finding first tex uses

Emil Velikov evelikov at kemper.freedesktop.org
Mon Sep 8 16:20:47 UTC 2014


Module: Mesa
Branch: 10.3
Commit: bb06f2cd93e8e16798bd59b458abd8d33a8e4658
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb06f2cd93e8e16798bd59b458abd8d33a8e4658

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Sat Sep  6 01:36:48 2014 +0200

nvc0/ir: clarify recursion fix to finding first tex uses

This is a simple shader for reproducing the case mentioned:

FRAG
DCL IN[0], GENERIC[0], PERSPECTIVE
DCL OUT[0], COLOR
DCL SAMP[0]
DCL CONST[0]
DCL TEMP[0..1], LOCAL
IMM[0] FLT32 {    0.0000,    -1.0000,     1.0000,     0.0000}
  0: MOV TEMP[0].x, CONST[0].wwww
  1: MOV TEMP[1].x, CONST[0].wwww
  2: BGNLOOP
  3:   IF TEMP[0].xxxx
  4:     BRK
  5:   ENDIF
  6:   ADD TEMP[0].x, TEMP[0], IMM[0].zzzz
  7:   IF CONST[0].xxxx
  8:     TEX TEMP[1].x, CONST[0], SAMP[0], 2D
  9:   ENDIF
 10:   IF CONST[0].zzzz
 11:     MOV TEMP[1].x, CONST[0].zzzz
 12:   ENDIF
 13: ENDLOOP
 14: MOV OUT[0], TEMP[1].xxxx
 15: END

Cc: "10.2 10.3" <mesa-stable at lists.freedesktop.org>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
(cherry picked from commit ca9ab05d45ebf407485af2daa3742b897ff99162)

---

 .../drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp  |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 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 92f9a15..b3e1e69 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
@@ -185,15 +185,13 @@ NVC0LegalizePostRA::findFirstUses(
       for (Value::UseIterator u = v->uses.begin(); u != v->uses.end(); ++u) {
          Instruction *usei = (*u)->getInsn();
 
-         /* XXX HACK ALERT XXX
-          *
-          * This shouldn't have to be here, we should always be making forward
-          * progress by looking at the uses. However this somehow does not
-          * appear to be the case. Probably because this is being done right
-          * after RA, when the defs/uses lists have been messed with by node
-          * merging. This should probably be moved to being done right before
-          * RA. But this will do for now.
-          */
+         // NOTE: In case of a loop that overwrites a value but never uses
+         // it, it can happen that we have a cycle of uses that consists only
+         // of phis and no-op moves and will thus cause an infinite loop here
+         // since these are not considered actual uses.
+         // The most obvious (and perhaps the only) way to prevent this is to
+         // remember which instructions we've already visited.
+
          if (visited.find(usei) != visited.end())
             continue;
 




More information about the mesa-commit mailing list