<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 - Breaking out of loop creates broken code on RADV"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=108275">108275</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Breaking out of loop creates broken code on RADV
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>18.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </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/Vulkan/radeon
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>maister@archlinux.us
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>mesa-dev@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=141940" name="attach_141940" title="Fossilize dump">attachment 141940</a> <a href="attachment.cgi?id=141940&action=edit" title="Fossilize dump">[details]</a></span>
Fossilize dump

I have a test case where adding a break to a loop creates broken code, and
Vulkan renders something complete bogus.

The code comes from spirv-opt and works fine on all other implementations I've
tested.

The original GLSL looks like this:
<a href="https://github.com/Themaister/Granite/blob/master/assets/shaders/ocean/cull_blocks.comp">https://github.com/Themaister/Granite/blob/master/assets/shaders/ocean/cull_blocks.comp</a>
To workaround the issue, I removed the "break" on line 54, which for some
reason fixed the issue.

My hunch is that the SelectionMerge inside the loop is merging to the loop's
continue block, and this is causing some weirdness.

To build Fossilize for repro:

git clone git://github.com/Themaister/Fossilize
cd Fossilize
git submodule update --init
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j16

To disassemble the failing SPIR-V pipeline:

GLSL (SPIRV-Cross):
./cli/fossilize-disasm fossilize.json --compute-pipeline 3 --target glsl
SPIR-V asm:
... --target asm
AMD ISA (VK_AMD_shader_info):
... --target amd

For the workaround case, use --compute-pipeline 29 instead.</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>