<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - PhiMovesPass in register allocator broken"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=90887">90887</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>PhiMovesPass in register allocator broken
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/nouveau
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>nouveau@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>j-r@online.de
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>nouveau@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=116339" name="attach_116339" title="Candidate Fix for nv50 PhiMovesPass">attachment 116339</a> <a href="attachment.cgi?id=116339&action=edit" title="Candidate Fix for nv50 PhiMovesPass">[details]</a></span>
Candidate Fix for nv50 PhiMovesPass

The PhiMovesPass depends on strict correspondence between phi argument and
incoming flow edge order. Unfortunately it destroys this correspondence itself
in the needNewElseBlock case resulting in the wrong (potentially uninitialized)
registers being copied.

The attached patch fixes problems in the following games on NVA5 (Debian
Jessie, wine git): Costume Quest (with FXAA option), Lifeless Planet, and
Eidolon. These are not present when using the LLVMPIPE driver.

I have analyzed the situation starting with Lifeless Planet (but simplifying
the shader until I could handle the problem): the postprocessing shader
modifies part of the rendered image with a shader like this

 1. sample the vincinity of the current position
 2. sample the current position
 2. compute something based on all of these pixels
 3. if some condition is reached
 4.     do some more computations (including TEXL)
 5.     replace current position value sampled above by computed value
 6. return current position value or computed value (see if)

The PhiMovesPass detects needNewElseBlock conditions and splits the 'else' edge
incoming from the if thereby switching the order of incoming edges leading to
adding copies from the sampled value to the if branch (discarding the computed
values) and copies from the (unitialized) computed values to the new else block
corrupting the result for all pixels except the ones where the condition is
true (where it produces the originally sampled value).

The fix slightly modifies the needNewElseBlock logic to not detach/attach the
incoming edge. Costume Quest (with FXAA) and Eidolon look correct with this
fix. Lifeless Planet is much better but still somewhat bad, but that may be
intended (it looks similarly crappy with LLVMPIPE). The latter may also be a
problem with wine).

NB: This might be related to <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [NVE0+] Failure to insert texbar under some circumstances (causing bad colors in Terasology)"
   href="show_bug.cgi?id=90347">bug #90347</a>. The shader code given there looks like
it could trigger this case, but I haven't tried it.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>