Mesa (master): wsi/x11: Treat IMMEDIATE present mode the same as MAILBOX for Xwayland

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 7 14:32:50 UTC 2021


Module: Mesa
Branch: master
Commit: e8f50bd60087805aa89144ecdd6e5a9b4368b532
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8f50bd60087805aa89144ecdd6e5a9b4368b532

Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Mon Dec 21 15:30:11 2020 +0100

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 at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8197>

---

 src/vulkan/wsi/wsi_common_x11.c | 20 ++++++++++++--------
 1 file 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



More information about the mesa-commit mailing list