From e8f50bd60087805aa89144ecdd6e5a9b4368b532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Mon, 21 Dec 2020 15:30:11 +0100 Subject: [PATCH] wsi/x11: Treat IMMEDIATE present mode the same as MAILBOX for Xwayland Two main reasons: As described in the previous commit, sending buffers to the Wayland compositor as quickly as possible effectively results in mailbox behaviour. Also, doing the same as for MAILBOX present mode provides the following benefits: * We use more images in the swapchain, which avoids stalls on the client side if the Wayland compositor directly uses the client buffers for scanout. * We wait for fences to signal before submitting a new buffer, which avoids missing frames in the Wayland compositor due to fences not signalling in time for a flip. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3673 Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/vulkan/wsi/wsi_common_x11.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 5da44dfc270..dcad48ca612 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -1551,20 +1551,22 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR); - unsigned num_images = pCreateInfo->minImageCount; - if (wsi_device->x11.strict_imageCount) - num_images = pCreateInfo->minImageCount; - else if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) - num_images = MAX2(num_images, 5); - else if (wsi_device->x11.ensure_minImageCount) - num_images = MAX2(num_images, x11_get_min_image_count(wsi_device)); - xcb_connection_t *conn = x11_surface_get_connection(icd_surface); struct wsi_x11_connection *wsi_conn = wsi_x11_get_connection(wsi_device, conn); if (!wsi_conn) return VK_ERROR_OUT_OF_HOST_MEMORY; + unsigned num_images = pCreateInfo->minImageCount; + if (wsi_device->x11.strict_imageCount) + num_images = pCreateInfo->minImageCount; + else if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR || + (present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR && + wsi_conn->is_xwayland)) + num_images = MAX2(num_images, 5); + else if (wsi_device->x11.ensure_minImageCount) + num_images = MAX2(num_images, x11_get_min_image_count(wsi_device)); + /* Check for whether or not we have a window up-front */ xcb_window_t window = x11_surface_get_window(icd_surface); xcb_get_geometry_reply_t *geometry = @@ -1667,7 +1669,9 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, if ((chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR || chain->base.present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR || - chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR) && !chain->base.wsi->sw) { + chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR || + (chain->base.present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR && + wsi_conn->is_xwayland)) && !chain->base.wsi->sw) { chain->has_present_queue = true; /* Initialize our queues. We make them base.image_count + 1 because we will