wsi/common: Add function to modify present mode.
authorHans-Kristian Arntzen <post@arntzen-software.no>
Wed, 30 Nov 2022 16:17:39 +0000 (17:17 +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 a355967..36c53ac 100644 (file)
@@ -1232,12 +1232,18 @@ wsi_common_queue_present(const struct wsi_device *wsi,
       vk_find_struct_const(pPresentInfo->pNext, PRESENT_ID_KHR);
    const VkSwapchainPresentFenceInfoEXT *present_fence_info =
       vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_FENCE_INFO_EXT);
+   const VkSwapchainPresentModeInfoEXT *present_mode_info =
+      vk_find_struct_const(pPresentInfo->pNext, SWAPCHAIN_PRESENT_MODE_INFO_EXT);
 
    for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) {
       VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);
       uint32_t image_index = pPresentInfo->pImageIndices[i];
       VkResult result;
 
+      /* Update the present mode for this present and any subsequent present. */
+      if (present_mode_info && present_mode_info->pPresentModes && swapchain->set_present_mode)
+         swapchain->set_present_mode(swapchain, present_mode_info->pPresentModes[i]);
+
       if (swapchain->fences[image_index] == VK_NULL_HANDLE) {
          const VkFenceCreateInfo fence_info = {
             .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
index 148d6db..b31961a 100644 (file)
@@ -191,6 +191,8 @@ struct wsi_swapchain {
    VkResult (*release_images)(struct wsi_swapchain *swap_chain,
                               uint32_t count,
                               const uint32_t *indices);
+   void (*set_present_mode)(struct wsi_swapchain *swap_chain,
+                            VkPresentModeKHR mode);
 };
 
 bool