From 4a1f230e35759d7e01a307b6a6c27fd437ffb631 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 22 Dec 2019 02:58:39 +0100 Subject: [PATCH] vulkan/wsi/x11: return VK_SUBOPTIMAL_KHR on mismatched swapchain If the swapchain already does not match the current geometry at the time of creation, set the initial status to VK_SUBOPTIMAL_KHR as a way to inform clients to please resize the swapchain. This solves a race condition where users have no way of knowing if the surface extent changed in between the user querying the current extent and creating the swapchain, and might end up missing a resize event because of it, since XCB_PRESENT_CONFIGURE_NOTIFY is not yet being handled. Reviewed-by: Adam Jackson Part-of: --- src/vulkan/wsi/wsi_common_x11.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 8750fd9f2e8..610270b0539 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -1591,6 +1591,8 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, if (geometry == NULL) return VK_ERROR_SURFACE_LOST_KHR; const uint32_t bit_depth = geometry->depth; + const uint16_t cur_width = geometry->width; + const uint16_t cur_height = geometry->height; free(geometry); size_t size = sizeof(*chain) + num_images * sizeof(chain->images[0]); @@ -1622,6 +1624,9 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, chain->status = VK_SUCCESS; chain->has_dri3_modifiers = wsi_conn->has_dri3_modifiers; + if (chain->extent.width != cur_width || chain->extent.height != cur_height) + chain->status = VK_SUBOPTIMAL_KHR; + /* If we are reallocating from an old swapchain, then we inherit its * last completion mode, to ensure we don't get into reallocation * cycles. If we are starting anew, we set 'COPY', as that is the only