wsi/common: Add common implementation of vkReleaseSwapchainImagesEXT.
authorHans-Kristian Arntzen <post@arntzen-software.no>
Thu, 8 Dec 2022 16:07:52 +0000 (17:07 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 3 Mar 2023 03:59:13 +0000 (03:59 +0000)
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Reviewed-by: Joshua Ashton <joshua@froggi.es>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20235>

src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common_private.h

index a9895d9..52d5526 100644 (file)
@@ -987,6 +987,29 @@ wsi_DestroySwapchainKHR(VkDevice _device,
    swapchain->destroy(swapchain, alloc);
 }
 
+VKAPI_ATTR VkResult VKAPI_CALL
+wsi_ReleaseSwapchainImagesEXT(VkDevice _device,
+                              const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo)
+{
+   VK_FROM_HANDLE(wsi_swapchain, swapchain, pReleaseInfo->swapchain);
+   VkResult result = swapchain->release_images(swapchain,
+                                               pReleaseInfo->imageIndexCount,
+                                               pReleaseInfo->pImageIndices);
+
+   if (result != VK_SUCCESS)
+      return result;
+
+   if (swapchain->wsi->set_memory_ownership) {
+      for (uint32_t i = 0; i < pReleaseInfo->imageIndexCount; i++) {
+         uint32_t image_index = pReleaseInfo->pImageIndices[i];
+         VkDeviceMemory mem = swapchain->get_wsi_image(swapchain, image_index)->memory;
+         swapchain->wsi->set_memory_ownership(swapchain->device, mem, false);
+      }
+   }
+
+   return VK_SUCCESS;
+}
+
 VkResult
 wsi_common_get_images(VkSwapchainKHR _swapchain,
                       uint32_t *pSwapchainImageCount,
index 308fb57..148d6db 100644 (file)
@@ -188,6 +188,9 @@ struct wsi_swapchain {
    VkResult (*wait_for_present)(struct wsi_swapchain *swap_chain,
                                 uint64_t present_id,
                                 uint64_t timeout);
+   VkResult (*release_images)(struct wsi_swapchain *swap_chain,
+                              uint32_t count,
+                              const uint32_t *indices);
 };
 
 bool