Ensure that swapchain is not passed to the ICD when creating images
authorNormunds Rieksts <normunds.rieksts@arm.com>
Wed, 27 Oct 2021 14:47:08 +0000 (15:47 +0100)
committerRosen Zhelev <rosen.zhelev@arm.com>
Mon, 8 Nov 2021 14:17:34 +0000 (14:17 +0000)
Ensures that all images created from a headless swapchain use the
same vkImageCreate info.

This ensures that when calling vkCreateImage with a swapchain that
is owned by the layer the VkImageSwapchainCreateInfoKHR is not
passed further down the chain to ICD on headless implementation.

Change-Id: I1bd723589e52577b98fd53ec1ec769e5594a0838
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
wsi/headless/swapchain.cpp
wsi/headless/swapchain.hpp

index b1033e9..1005809 100644 (file)
@@ -49,6 +49,7 @@ struct image_data
 
 swapchain::swapchain(layer::device_private_data &dev_data, const VkAllocationCallbacks *pAllocator)
    : wsi::swapchain_base(dev_data, pAllocator)
+   , m_image_create_info()
 {
 }
 
@@ -60,7 +61,7 @@ swapchain::~swapchain()
 
 VkResult swapchain::create_aliased_image_handle(const VkImageCreateInfo *image_create_info, VkImage *image)
 {
-   return m_device_data.disp.CreateImage(m_device, image_create_info, get_allocation_callbacks(), image);
+   return m_device_data.disp.CreateImage(m_device, &m_image_create_info, get_allocation_callbacks(), image);
 }
 
 VkResult swapchain::create_and_bind_swapchain_image(VkImageCreateInfo image_create, wsi::swapchain_image &image)
@@ -68,6 +69,7 @@ VkResult swapchain::create_and_bind_swapchain_image(VkImageCreateInfo image_crea
    VkResult res = VK_SUCCESS;
    const std::lock_guard<std::recursive_mutex> lock(m_image_status_mutex);
 
+   m_image_create_info = image_create;
    res = m_device_data.disp.CreateImage(m_device, &image_create, get_allocation_callbacks(), &image.image);
    if (res != VK_SUCCESS)
    {
index cdaf792..fb663b9 100644 (file)
@@ -119,6 +119,12 @@ protected:
     */
    VkResult bind_swapchain_image(VkDevice &device, const VkBindImageMemoryInfo *bind_image_mem_info,
                                  const VkBindImageMemorySwapchainInfoKHR *bind_sc_info) override;
+
+private:
+   /**
+    * @brief Image creation info used for all swapchain images.
+    */
+   VkImageCreateInfo m_image_create_info;
 };
 
 } /* namespace headless */