<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 - Adding a redundant single-iteration do-while loop causes different image to be rendered"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=110953">110953</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Adding a redundant single-iteration do-while loop causes different image to be rendered
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (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>glsl-compiler
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>abelbriggs1@hotmail.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=144602" name="attach_144602" title="piglit shader tests, images, diff">attachment 144602</a> <a href="attachment.cgi?id=144602&action=edit" title="piglit shader tests, images, diff">[details]</a></span>
piglit shader tests, images, diff

Similar bug reproduced with Intel i965 that was resolved as fixed:
<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Adding a single, meaningless if-else to a shader source leads to different image"
   href="show_bug.cgi?id=100303">https://bugs.freedesktop.org/show_bug.cgi?id=100303</a>

I'm unsure if the error reproduced with the enclosed shaders occur on AMD/Intel
- please feel free to move this if it can't be reproduced.

The attached archive contains two shaders, a reference shader and a variant
shader, that by construction should render the same image. On the build and PC
specified below, however, these shaders render different images. Images of the
shaders’ output are also supplied in the archive, as well as the minor diff
between the source code of the two shaders.

The difference between the two shaders is that the variant wraps a
single-iteration do-while loop around existing code.

46c46
<       do
---
<span class="quote">>        if(doSwap)</span >
48,53c48,50
<        if(doSwap)
<         {
<             float temp = data[i];
<             data[i] = data[j];
<             data[j] = temp;
<         }
---
<span class="quote">>        float temp = data[i];
>        data[i] = data[j];
>        data[j] = temp;</span >
55d51
<      while(false);

Steps to reproduce:
-------------------------------------------------------------------------------
1. Obtain and build piglit, the Mesa OpenGL test suite runner:
<a href="https://gitlab.freedesktop.org/mesa/piglit">https://gitlab.freedesktop.org/mesa/piglit</a>
2. Download the attached archive.
3. From a terminal, execute the supplied tests with the piglit GLES3 shader
runner: 
$ bin/shader_runner_gles3 reference.shader_test
$ bin/shader_runner_gles3 variant.shader_test

Expected results:
-------------------------------------------------------------------------------
Both images should produce an image like reference.png, and so both tests
should pass. If both fail, it’s likely due to floating point errors that can
affect the precise color values - if this is the case, please manually observe
that the shader images have significant differences that are not limited to
minor floating point variation.

Actual results:
-------------------------------------------------------------------------------
The variant produces a different image (and fails the test) even though it
should run exactly the same as the reference shader. This is because the only
difference between the reference and variant shaders is that the variant shader
wraps a single-iteration do-while loop around existing code, which makes no
semantic difference between the two shaders.

Build & PC specs:
-------------------------------------------------------------------------------
CPU: Intel Core i7-5820k 
GPU: nVIDIA GTX 970

OS: Ubuntu 19.04
libdrm: git-5db0f7692d1fdf05f9f6c0c02ffa5a5f4379c1f3 (most recent as of this
writing)
Mesa: git-9c19d07b1cdcd22ced0f4e1c147e496b6ff5cf23 (most recent as of this
writing)
Xf86-video-nouveau: 1.0.16
Linux kernel version: 5.0.0-16-generic

This bug was found with GraphicsFuzz: <a href="https://github.com/google/graphicsfuzz">https://github.com/google/graphicsfuzz</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>