From 5f481dd89db04a2c3ae35402efdf2def005f4008 Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Wed, 28 May 2025 08:24:39 -0400 Subject: [PATCH] egl/dri: Check that xshm can be attached Cc: mesa-stable Co-authored-by: Carlos Lopez Part-of: --- src/egl/drivers/dri2/platform_x11.c | 35 +++-------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index d36ce8bdd3d..62ae615c6f3 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -51,7 +51,9 @@ #include "util/log.h" #include #include +#include #include "x11_dri3.h" +#include "x11_display.h" #include "kopper_interface.h" #include "loader.h" #include "platform_x11.h" @@ -1121,37 +1123,6 @@ dri2_x11_setup_swap_interval(_EGLDisplay *disp) dri2_setup_swap_interval(disp, arbitrary_max_interval); } -static bool -check_xshm(struct dri2_egl_display *dri2_dpy) -{ - xcb_void_cookie_t cookie; - xcb_generic_error_t *error; - int ret = true; - xcb_query_extension_cookie_t shm_cookie; - xcb_query_extension_reply_t *shm_reply; - bool has_mit_shm; - - shm_cookie = xcb_query_extension(dri2_dpy->conn, 7, "MIT-SHM"); - shm_reply = xcb_query_extension_reply(dri2_dpy->conn, shm_cookie, NULL); - - has_mit_shm = shm_reply && shm_reply->present; - free(shm_reply); - if (!has_mit_shm) - return false; - - cookie = xcb_shm_detach_checked(dri2_dpy->conn, 0); - if ((error = xcb_request_check(dri2_dpy->conn, cookie))) { - /* BadRequest means we're a remote client. If we were local we'd - * expect BadValue since 'info' has an invalid segment name. - */ - if (error->error_code == BadRequest) - ret = false; - free(error); - } - - return ret; -} - static bool platform_x11_finalize(_EGLDisplay *disp, bool force_zink) { @@ -1218,7 +1189,7 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - if (check_xshm(dri2_dpy)) { + if (x11_xcb_display_supports_xshm(dri2_dpy->conn)) { dri2_dpy->loader_extensions = swrast_loader_shm_extensions; } else { dri2_dpy->loader_extensions = swrast_loader_extensions;