From 0aba2c604e0f1ed9cff76368c94775df2fa20f26 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 11 May 2022 19:13:48 +0100 Subject: [PATCH] vulkan/wsi: Add stub interface for VK_KHR_present_wait Signed-off-by: Daniel Stone Co-authored-by: Hans-Kristian Arntzen Signed-off-by: Hans-Kristian Arntzen Reviewed-by: Joshua Ashton Part-of: --- src/vulkan/wsi/wsi_common.c | 17 ++++++++++++++++- src/vulkan/wsi/wsi_common_display.c | 1 + src/vulkan/wsi/wsi_common_private.h | 4 ++++ src/vulkan/wsi/wsi_common_wayland.c | 1 + src/vulkan/wsi/wsi_common_win32.c | 5 +++-- src/vulkan/wsi/wsi_common_x11.c | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 5532c44..710d0c9 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -1080,6 +1080,8 @@ wsi_common_queue_present(const struct wsi_device *wsi, const VkPresentRegionsKHR *regions = vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR); + const VkPresentIdKHR *present_ids = + vk_find_struct_const(pPresentInfo->pNext, PRESENT_ID_KHR); for (uint32_t i = 0; i < pPresentInfo->swapchainCount; i++) { VK_FROM_HANDLE(wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]); @@ -1227,7 +1229,11 @@ wsi_common_queue_present(const struct wsi_device *wsi, if (regions && regions->pRegions) region = ®ions->pRegions[i]; - result = swapchain->queue_present(swapchain, image_index, region); + uint64_t present_id = 0; + if (present_ids && present_ids->pPresentIds) + present_id = present_ids->pPresentIds[i]; + + result = swapchain->queue_present(swapchain, image_index, present_id, region); if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) goto fail_present; @@ -1789,3 +1795,12 @@ wsi_configure_cpu_image(const struct wsi_swapchain *chain, return VK_SUCCESS; } + +VKAPI_ATTR VkResult VKAPI_CALL +wsi_WaitForPresentKHR(VkDevice device, VkSwapchainKHR _swapchain, + uint64_t presentId, uint64_t timeout) +{ + VK_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain); + assert(swapchain->wait_for_present); + return swapchain->wait_for_present(swapchain, presentId, timeout); +} diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index a41fabe..8dd9727 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -1910,6 +1910,7 @@ _wsi_display_queue_next(struct wsi_swapchain *drv_chain) static VkResult wsi_display_queue_present(struct wsi_swapchain *drv_chain, uint32_t image_index, + uint64_t present_id, const VkPresentRegionKHR *damage) { struct wsi_display_swapchain *chain = diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index fe3e855..483b313 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -162,7 +162,11 @@ struct wsi_swapchain { uint32_t *image_index); VkResult (*queue_present)(struct wsi_swapchain *swap_chain, uint32_t image_index, + uint64_t present_id, const VkPresentRegionKHR *damage); + VkResult (*wait_for_present)(struct wsi_swapchain *swap_chain, + uint64_t present_id, + uint64_t timeout); }; bool diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index dc5a383..6a337fc 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -1545,6 +1545,7 @@ static const struct wl_callback_listener frame_listener = { static VkResult wsi_wl_swapchain_queue_present(struct wsi_swapchain *wsi_chain, uint32_t image_index, + uint64_t present_id, const VkPresentRegionKHR *damage) { struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain; diff --git a/src/vulkan/wsi/wsi_common_win32.c b/src/vulkan/wsi/wsi_common_win32.c index bef8102..d2227fc 100644 --- a/src/vulkan/wsi/wsi_common_win32.c +++ b/src/vulkan/wsi/wsi_common_win32.c @@ -400,8 +400,9 @@ wsi_win32_acquire_next_image(struct wsi_swapchain *drv_chain, static VkResult wsi_win32_queue_present(struct wsi_swapchain *drv_chain, - uint32_t image_index, - const VkPresentRegionKHR *damage) + uint32_t image_index, + uint64_t present_id, + const VkPresentRegionKHR *damage) { struct wsi_win32_swapchain *chain = (struct wsi_win32_swapchain *) drv_chain; assert(image_index < chain->base.image_count); diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index a3c4538..edd47cb 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -1426,6 +1426,7 @@ x11_acquire_next_image(struct wsi_swapchain *anv_chain, static VkResult x11_queue_present(struct wsi_swapchain *anv_chain, uint32_t image_index, + uint64_t present_id, const VkPresentRegionKHR *damage) { struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain; -- 2.7.4