From 64b627332d4a27bc8ca1fbd021be0a8f4b96b1ae Mon Sep 17 00:00:00 2001 From: lfdevs Date: Thu, 8 Oct 2026 15:32:43 +0800 Subject: [PATCH] dri3: add an option to disable the Present wait-fence bridge Some Android/Xwayland combinations can hang on the first frame or show a black window when the native render-fence bridge introduced in PR #96 is enabled. Add MESA_DRI3_DISABLE_PRESENT_WAIT_FENCE to skip initialization of the XSync Present wait-fence bridge and use the existing flush path instead. The option defaults to false, preserving the current synchronization behavior unless explicitly disabled. This provides a per-process workaround while the underlying compatibility issue is investigated. --- src/gallium/frontends/dri/loader_dri3_helper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/frontends/dri/loader_dri3_helper.c b/src/gallium/frontends/dri/loader_dri3_helper.c index 3e6109f9664c..860c02cab6b6 100644 --- a/src/gallium/frontends/dri/loader_dri3_helper.c +++ b/src/gallium/frontends/dri/loader_dri3_helper.c @@ -46,6 +46,7 @@ #include "util/macros.h" #include "util/u_atomic.h" #include "util/u_queue.h" +#include "util/u_debug.h" #include "util/simple_mtx.h" #include "drm-uapi/drm_fourcc.h" #include "dri_screen.h" @@ -1821,11 +1822,12 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int fourcc, if (!ret) buffer->modifier = DRM_FORMAT_MOD_INVALID; - /* Android's dma-buf implementation may lack sync-file import/export even - * though DRI3 buffer sharing itself works. In that case Present needs an - * explicit render-completion fence. + /* Some Android/Xwayland combinations cannot consume the XSync wait fence + * reliably. Keep an escape hatch for those sessions while retaining the + * explicit bridge by default on other platforms. */ - dri3_present_sync_init(draw, buffer_fds[0]); + if (!debug_get_bool_option("MESA_DRI3_DISABLE_PRESENT_WAIT_FENCE", false)) + dri3_present_sync_init(draw, buffer_fds[0]); if (draw->dri_screen_render_gpu != draw->dri_screen_display_gpu && draw->dri_screen_display_gpu && linear_buffer_display_gpu) {