From 2c4c7fbfa907d330317340c5d43ae93d46107e19 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 (cherry picked from commit 5f481dd89db04a2c3ae35402efdf2def005f4008) Part-of: --- .pick_status.json | 2 +- src/egl/drivers/dri2/platform_x11.c | 35 +++-------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 883b185b45b..eeeb68ed42a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2414,7 +2414,7 @@ "description": "egl/dri: Check that xshm can be attached", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 25d6ed20754..579433e17d5 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" @@ -1123,37 +1125,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) { @@ -1220,7 +1191,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;