From eb48921b8e3230f7a91cbb8b4fab28a40683cefd Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 14 Jul 2025 11:31:41 -0400 Subject: [PATCH] egl/x11: Refuse to initialize if Display isn't thread-safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Mike Blumenkrantz Reviewed-by: Adam Jackson Reviewed-by: Marek Olšák Reviewed-by: Eric Engestrom Part-of: --- src/egl/drivers/dri2/egl_dri2.c | 16 ---------------- src/egl/drivers/dri2/platform_x11.c | 3 +++ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 29047d7a84a..9ceac33fb63 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -59,7 +59,6 @@ #ifdef HAVE_X11_PLATFORM #include "X11/Xlibint.h" #include "x11_dri3.h" -#include "x11_display.h" #endif #include "GL/mesa_glinterop.h" @@ -110,9 +109,6 @@ dri2_gl_flush() static GLboolean dri_is_thread_safe(UNUSED void *loaderPrivate) { -#ifdef HAVE_X11_PLATFORM - struct dri2_egl_surface *dri2_surf = loaderPrivate; - /* loader_dri3_blit_context_get creates a context with * loaderPrivate being NULL. Enabling glthread for a blitting * context isn't useful so return false. @@ -120,18 +116,6 @@ dri_is_thread_safe(UNUSED void *loaderPrivate) if (!loaderPrivate) return false; - _EGLDisplay *display = dri2_surf->base.Resource.Display; - - Display *xdpy = (Display *)display->PlatformDisplay; - - /* Check Xlib is running in thread safe mode when running on EGL/X11-xlib - * platform - */ - if (display->Platform == _EGL_PLATFORM_X11 && xdpy && - !x11_xlib_display_is_thread_safe(xdpy)) - return false; -#endif - return true; } diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index ff6d3b6cc98..738e3062c0c 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -52,6 +52,7 @@ #include #include #include "x11_dri3.h" +#include "x11_display.h" #include "kopper_interface.h" #include "loader.h" #include "platform_x11.h" @@ -1068,6 +1069,8 @@ dri2_get_xcb_connection(_EGLDisplay *disp, struct dri2_egl_display *dri2_dpy) screen = dri2_find_screen_for_display(disp, screen); } else if (disp->Platform == _EGL_PLATFORM_X11) { Display *dpy = disp->PlatformDisplay; + if (!x11_xlib_display_is_thread_safe(dpy)) + return EGL_FALSE; dri2_dpy->conn = XGetXCBConnection(dpy); screen = DefaultScreen(dpy); } else {