<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 - Image corruption with vkCmdCopyImage into I915_FORMAT_MOD_Y_TILED_CCS-tiled swapchain image"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=111568">111568</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Image corruption with vkCmdCopyImage into I915_FORMAT_MOD_Y_TILED_CCS-tiled swapchain image
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>19.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>not set
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>not set
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/Vulkan/intel
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mesa@felixdoerre.de
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jason@jlekstrand.net
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=145271" name="attach_145271" title="Vulkan Api trace showing a wronly copied imaged.">attachment 145271</a> <a href="attachment.cgi?id=145271&action=edit" title="Vulkan Api trace showing a wronly copied imaged.">[details]</a></span>
Vulkan Api trace showing a wronly copied imaged.

I am using a laptop with: "Intel(R) HD Graphics P630 (Kaby Lake GT2)"

When using Vulkan with gonme-wayland the Xwayland server(version 1.20.4)
reports compatibility with all the DRM modifiers, implemented in mesa:
      DRM_FORMAT_MOD_LINEAR,
      I915_FORMAT_MOD_X_TILED,
      I915_FORMAT_MOD_Y_TILED,
      I915_FORMAT_MOD_Y_TILED_CCS,

The mesa intel vulkan driver reports the following two formats for support with
an X11-swapchain (created through xwayland):
 VK_FORMAT_B8G8R8A8_UNORM
 VK_FORMAT_B8G8R8A8_SRGB

In
<a href="https://gitlab.freedesktop.org/mesa/mesa/blob/master/src/intel/isl/isl_format.c">https://gitlab.freedesktop.org/mesa/mesa/blob/master/src/intel/isl/isl_format.c</a>
we can see that only the UNORM-format supports CCS compression on my hardware
(I have devinfo->gen=9)
   SF(  Y,   Y,   x,   Y,   Y,   Y,   Y,   x,  60,  70,   x,  90,  
B8G8R8A8_UNORM)
   SF(  Y,   Y,   x,   x,   Y,   Y,   x,   x,   x,   x,   x, 100,  
B8G8R8A8_UNORM_SRGB)

When the application now chooses "VK_FORMAT_B8G8R8A8_UNORM" as swapchain image
format, the WSI-part offers all 4 DRM-modifiers to anv_image.c which chooses
I915_FORMAT_MOD_Y_TILED_CCS based on this scoring function:
<a href="https://gitlab.freedesktop.org/mesa/mesa/blob/55c912883c9b3624ee060fe1a0232cf71e329d80/src/intel/vulkan/anv_image.c#L524">https://gitlab.freedesktop.org/mesa/mesa/blob/55c912883c9b3624ee060fe1a0232cf71e329d80/src/intel/vulkan/anv_image.c#L524</a>

The application creates a second (normal, LINEAR-tiled, same VkFormat (of
VK_FORMAT_B8G8R8A8_UNORM))-image with the same size as the swapchain-image and
loads data into it my memory-mapping it (I chose an all-white image).
Afterwards it copies the image data into the swapchain image with
`VkCmdCopyImage`.

When this picture is presented however it is corrupted. (I see only a few white
dots on black background). I presume this is caused by the code that does
`VkCmdCopyImage` not correctly handling conversion based on CCS-tiling.

I have created a small Java-LWJGL-Vulkan application that deterministically
reproduces the problem and recorded a Vulkan apitrace (attached). If you would
prefer the java-Application for testing I could provide 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>