<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 single-iteration do-while loop in a GLSL shader leads to a different image"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101648">101648</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Adding a single-iteration do-while loop in a GLSL shader leads to a different image
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>17.1
          </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>Mesa core
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>h.evrard@imperial.ac.uk
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://github.com/mc-imperial/shader-compiler-bugs/issues/75">https://github.com/mc-imperial/shader-compiler-bugs/issues/75</a>

Steps to Reproduce:
-------------------------------

0. This is reproducable with Mesa version 17.1.3, on Intel intergated GPUs.

1. Obtain and build the latest release of get-image-glsl, a simple tool
   that creates a .png image from a fragment shader. We need the
   `get_image_glfw` executable.
   <a href="https://github.com/graphicsfuzz/get-image-glsl">https://github.com/graphicsfuzz/get-image-glsl</a>

2. From a terminal, execute (this must be done in the directory where
   both .frag and .json files are):

   `/path/to/get_image_glfw original.frag`

   This will create output.png, which should look like original.png

3. From a terminal, execute (same remark as above):

   `/path/to/get_image_glfw variant.frag`

   This will create output.png, which should look like variant.png

Expected Results:
-------------------------------

Both shaders should render an image that looks like original.png.  This
is because the only difference between the .frag files is a 'do-while'
loop that should execute only once:

```
$ diff -u original.frag variant.frag
--- original.frag       2017-06-28 11:04:21.278754777 +0100
+++ variant.frag        2017-06-28 11:23:16.925591708 +0100
@@ -42,10 +42,12 @@
                 {
                     s += _FLOAT_CONST[2];
                 }
+            do {
             if(float(i) >= limit)
                 {
                     return s;
                 }
+            } while(gl_FragCoord.x < 0.0);
         }
     return s;
 }
```

Actual Results:
-------------------------------
The shaders render completely different images, which they should not.

Mesa code coverage:
-------------------------------
Unzip the `coverage.html.zip` file to get a web page that present the
comparative coverage of Mesa source code between the execution of the
original and the variant shader.

Additional Information:
-------------------------------
Some info on the system where the bug was found:

CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
GPU: "2nd Generation Core Processor Family Integrated Graphics Controller"
OS: Linux 4.8.0-56-generic #61~16.04.1-Ubuntu SMP
Mesa version: 17.1.3</pre>
        </div>
      </p>


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

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