egl/x11: Refuse to initialize if Display isn't thread-safe

Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36123>
This commit is contained in:
Faith Ekstrand 2025-07-14 11:31:41 -04:00 committed by Marge Bot
parent 30b98a7ec1
commit eb48921b8e
2 changed files with 3 additions and 16 deletions

View file

@ -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;
}

View file

@ -52,6 +52,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#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 {