<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 - 0 Color write masks with multiple render targets redirects color outputs to wrong attachment"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=102634">102634</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>0 Color write masks with multiple render targets redirects color outputs to wrong attachment
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>17.1
          </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=134107" name="attach_134107" title="Expected output">attachment 134107</a> <a href="attachment.cgi?id=134107&action=edit" title="Expected output">[details]</a></span>
Expected output

Hardware: RX 470
Mesa: 17.1.8
OS: Arch Linux

I have a deferred shader which emits color data to 4 attachments. When
colorWriteMask of all attachments are 0xf, this works as expected, but when I
try to mask out writes to layout(location = 0), it is almost as if all the
attachments are reshuffled so that location = 1 writes to attachment 0,
location = 2 writes to attachment = 1 ... and so on.

Here is the current workaround I must apply:
<a href="https://github.com/Themaister/Granite/blob/master/assets/shaders/inc/render_target.h#L8">https://github.com/Themaister/Granite/blob/master/assets/shaders/inc/render_target.h#L8</a>

The scenario which fails:
- 4 color attachments in a subpass
- Color masks are {0, 0xf, 0xf, 0xf}
- The shader does not declare layout(location = 0) output

To reproduce:
Build Granite: <a href="https://github.com/Themaister/Granite">https://github.com/Themaister/Granite</a>
Run Suzanne model: ./granite/tests/gltf-viewer
~/git/glTF-Sample-Models/2.0/Suzanne/glTF/Suzanne.gltf

Fiddle with WORKAROUND_RADV define mentioned above:</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>