wsi/common: Set VK_IMAGE_CREATE_ALIAS_BIT
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 9 Aug 2021 15:23:18 +0000 (10:23 -0500)
committerMarge Bot <emma+marge@anholt.net>
Mon, 31 Jan 2022 19:46:55 +0000 (19:46 +0000)
With Vulkan 1.1, we have a VkImageSwapchainCreateInfoKHR struct which
lets you create a new VkImage which aliases a swapchain image.  However,
there is no corresponding swapchain create flag so we have to set
VK_IMAGE_CREATE_ALIAS_BIT all the time.

We need to do a bit of work in ANV to prevent it from asserting the
moment it sees one of these.  Fortunately, they're already safe because
WSI images go through a different bind path for
VkBindImageMemorySwapchainInfoKHR.

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12031>

src/intel/vulkan/anv_image.c
src/intel/vulkan/anv_private.h
src/vulkan/wsi/wsi_common.c

index c368d50..c67d111 100644 (file)
@@ -903,9 +903,10 @@ check_memory_bindings(const struct anv_device *device,
          : ANV_IMAGE_MEMORY_BINDING_MAIN;
 
       /* Aliasing is incompatible with the private binding because it does not
-       * live in a VkDeviceMemory.
+       * live in a VkDeviceMemory.  The one exception is swapchain images.
        */
       assert(!(image->vk.create_flags & VK_IMAGE_CREATE_ALIAS_BIT) ||
+             image->from_wsi ||
              image->bindings[ANV_IMAGE_MEMORY_BINDING_PRIVATE].memory_range.size == 0);
 
       /* Check primary surface */
index d54c6c0..82e814f 100644 (file)
@@ -3873,6 +3873,11 @@ struct anv_image {
    bool disjoint;
 
    /**
+    * Image is a WSI image
+    */
+   bool from_wsi;
+
+   /**
     * Image was imported from an struct AHardwareBuffer.  We have to delay
     * final image creation until bind time.
     */
index 725239b..afd634b 100644 (file)
@@ -373,7 +373,7 @@ wsi_configure_image(const struct wsi_swapchain *chain,
 
    info->create = (VkImageCreateInfo) {
       .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
-      .flags = 0,
+      .flags = VK_IMAGE_CREATE_ALIAS_BIT,
       .imageType = VK_IMAGE_TYPE_2D,
       .format = pCreateInfo->imageFormat,
       .extent = {