Fix erroneous behaviour in error cases
authorIason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Thu, 26 Nov 2020 18:00:05 +0000 (18:00 +0000)
committerIason Paraskevopoulos <iason.paraskevopoulos@arm.com>
Thu, 3 Dec 2020 10:24:05 +0000 (10:24 +0000)
Corrects error handling when image creation fails and fixes
shutdown behaviour in error cases.

Change-Id: I29b9fbd237b90f6007e4731d9019efb6b4c256ff
Signed-off-by: Iason Paraskevopoulos <iason.paraskevopoulos@arm.com>
wsi/headless/swapchain.cpp
wsi/swapchain_base.cpp

index 4f09886..a12f29b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019 Arm Limited.
+ * Copyright (c) 2017-2020 Arm Limited.
  *
  * SPDX-License-Identifier: MIT
  *
@@ -61,7 +61,10 @@ VkResult swapchain::create_image(const VkImageCreateInfo &image_create, wsi::swa
 {
    VkResult res = VK_SUCCESS;
    res = m_device_data.disp.CreateImage(m_device, &image_create, nullptr, &image.image);
-   assert(VK_SUCCESS == res);
+   if (res != VK_SUCCESS)
+   {
+      return res;
+   }
 
    VkMemoryRequirements memory_requirements;
    m_device_data.disp.GetImageMemoryRequirements(m_device, image.image, &memory_requirements);
index 737dc5b..be50e36 100644 (file)
@@ -322,11 +322,17 @@ void swapchain_base::teardown()
    }
 
    /* If descendant started presenting, there is no pending buffer in the swapchain. */
-   if (descendent_started_presenting == false)
+   if (m_is_valid && descendent_started_presenting == false)
    {
       wait_for_pending_buffers();
    }
 
+   if (m_queue != VK_NULL_HANDLE)
+   {
+      /* Make sure the vkFences are done signaling. */
+      vkQueueWaitIdle(m_queue);
+   }
+
    /* Make sure the vkFences are done signaling. */
    m_device_data.disp.QueueWaitIdle(m_queue);