diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index d8d77ce8d2f..03a4405d4de 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -857,6 +857,7 @@ static const driOptionDescription radv_dri_options[] = { DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0) DRI_CONF_VK_X11_STRICT_IMAGE_COUNT(false) DRI_CONF_VK_X11_ENSURE_MIN_IMAGE_COUNT(false) + DRI_CONF_VK_XWAYLAND_WAIT_READY(true) DRI_CONF_RADV_REPORT_LLVM9_VERSION_STRING(false) DRI_CONF_RADV_ENABLE_MRT_OUTPUT_NAN_FIXUP(false) DRI_CONF_RADV_DISABLE_SHRINK_IMAGE_STORE(false) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 9afc5927fad..6ff8e2b38df 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -63,6 +63,7 @@ static const driOptionDescription anv_dri_options[] = { DRI_CONF_SECTION_PERFORMANCE DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0) DRI_CONF_VK_X11_STRICT_IMAGE_COUNT(false) + DRI_CONF_VK_XWAYLAND_WAIT_READY(true) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG diff --git a/src/util/driconf.h b/src/util/driconf.h index 0b6434acf85..35f1941a8d2 100644 --- a/src/util/driconf.h +++ b/src/util/driconf.h @@ -333,6 +333,10 @@ DRI_CONF_OPT_B(vk_x11_ensure_min_image_count, def, \ "Force the X11 WSI to create at least the number of image specified by the driver in VkSurfaceCapabilitiesKHR::minImageCount") +#define DRI_CONF_VK_XWAYLAND_WAIT_READY(def) \ + DRI_CONF_OPT_B(vk_xwayland_wait_ready, def, \ + "Wait for fences before submitting buffers to Xwayland") + #define DRI_CONF_MESA_GLTHREAD(def) \ DRI_CONF_OPT_B(mesa_glthread, def, \ "Enable offloading GL driver work to a separate thread") diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index adf275e8d48..473efcc16a4 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -121,6 +121,11 @@ struct wsi_device { * driver in VkSurfaceCapabilitiesKHR::minImageCount. */ bool ensure_minImageCount; + + /* Wait for fences before submitting buffers to Xwayland. Defaults to + * true. + */ + bool xwaylandWaitReady; } x11; bool sw; diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index fcda05d2d42..aac45b38553 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -39,6 +39,7 @@ #include #include "drm-uapi/drm_fourcc.h" #include "util/hash_table.h" +#include "util/u_debug.h" #include "util/u_thread.h" #include "util/xmlconfig.h" @@ -1262,6 +1263,25 @@ x11_queue_present(struct wsi_swapchain *anv_chain, } } +static bool +x11_needs_wait_for_fences(const struct wsi_device *wsi_device, + struct wsi_x11_connection *wsi_conn, + VkPresentModeKHR present_mode) +{ + if (wsi_conn->is_xwayland && !wsi_device->x11.xwaylandWaitReady) { + return false; + } + + switch (present_mode) { + case VK_PRESENT_MODE_MAILBOX_KHR: + return true; + case VK_PRESENT_MODE_IMMEDIATE_KHR: + return wsi_conn->is_xwayland; + default: + return false; + } +} + static void * x11_manage_fifo_queues(void *state) { @@ -1291,9 +1311,8 @@ x11_manage_fifo_queues(void *state) return NULL; } - if (chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR || - (chain->base.present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR && - wsi_conn->is_xwayland)) { + if (x11_needs_wait_for_fences(chain->base.wsi, wsi_conn, + chain->base.present_mode)) { result = chain->base.wsi->WaitForFences(chain->base.device, 1, &chain->base.fences[image_index], true, UINT64_MAX); @@ -1679,9 +1698,7 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface, 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)) + else if (x11_needs_wait_for_fences(wsi_device, wsi_conn, present_mode)) 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)); @@ -1791,10 +1808,10 @@ 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.present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR && - wsi_conn->is_xwayland)) && !chain->base.wsi->sw) { + chain->base.present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR || + x11_needs_wait_for_fences(wsi_device, wsi_conn, + chain->base.present_mode)) && + !chain->base.wsi->sw) { chain->has_present_queue = true; /* Initialize our queues. We make them base.image_count + 1 because we will @@ -1912,7 +1929,11 @@ wsi_x11_init_wsi(struct wsi_device *wsi_device, wsi_device->x11.ensure_minImageCount = driQueryOptionb(dri_options, "vk_x11_ensure_min_image_count"); } - + wsi_device->x11.xwaylandWaitReady = true; + if (driCheckOption(dri_options, "vk_xwayland_wait_ready", DRI_BOOL)) { + wsi_device->x11.xwaylandWaitReady = + driQueryOptionb(dri_options, "vk_xwayland_wait_ready"); + } } wsi->base.get_support = x11_surface_get_support;