diff options
author | Michel Dänzer <mdaenzer@redhat.com> | 2020-12-21 15:30:11 +0100 |
---|---|---|
committer | Michel Dänzer <michel@daenzer.net> | 2021-01-07 15:00:45 +0100 |
commit | e8f50bd60087805aa89144ecdd6e5a9b4368b532 (patch) | |
tree | 898734ed05e6b3750fb454bad58b7a89b6d1c34f | |
parent | 4292fb2139282e6906d4ad2a8be2fd81ed7ca8af (diff) |
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 <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8197>
-rw-r--r-- | src/vulkan/wsi/wsi_common_x11.c | 20 |
1 files changed, 12 insertions, 8 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); + 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) + 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)); - 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; - /* 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 |