mirror of https://gitlab.freedesktop.org/mesa/mesa
drisw: Port the MIT-SHM check to XCB
The old version isn't thread-safe, and xlib makes it unreasonably difficult to write thread-safely. Fixes: mesa/mesa#3398 Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6294>
This commit is contained in:
parent
ee905aa3a0
commit
aeba69deaa
|
@ -294,7 +294,7 @@ x86_test-base:
|
|||
x86_test-gl:
|
||||
extends: .use-x86_test-base
|
||||
variables:
|
||||
FDO_DISTRIBUTION_TAG: &x86_test-gl "2020-07-28-x86-2"
|
||||
FDO_DISTRIBUTION_TAG: &x86_test-gl "2020-08-14-xcb-shm"
|
||||
|
||||
# Debian 10 based x86 test image for VK
|
||||
x86_test-vk:
|
||||
|
|
|
@ -33,6 +33,7 @@ STABLE_EPHEMERAL=" \
|
|||
"
|
||||
|
||||
apt-get install -y --no-remove \
|
||||
libxcb-shm0 \
|
||||
$STABLE_EPHEMERAL
|
||||
|
||||
|
||||
|
|
|
@ -1701,6 +1701,7 @@ dep_xcb_sync = null_dep
|
|||
dep_xcb_xfixes = null_dep
|
||||
dep_xshmfence = null_dep
|
||||
dep_xcb_xrandr = null_dep
|
||||
dep_xcb_shm = null_dep
|
||||
dep_xlib_xrandr = null_dep
|
||||
if with_platform_x11
|
||||
if with_glx == 'xlib' or with_glx == 'gallium-xlib'
|
||||
|
@ -1713,6 +1714,7 @@ if with_platform_x11
|
|||
dep_xdamage = dependency('xdamage', version : '>= 1.1')
|
||||
dep_xfixes = dependency('xfixes')
|
||||
dep_xcb_glx = dependency('xcb-glx', version : '>= 1.8.1')
|
||||
dep_xcb_shm = dependency('xcb-shm')
|
||||
endif
|
||||
if (with_any_vk or with_glx == 'dri' or with_egl or
|
||||
(with_gallium_vdpau or with_gallium_xvmc or with_gallium_va or
|
||||
|
|
|
@ -23,7 +23,10 @@
|
|||
|
||||
#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
|
||||
|
||||
#include <xcb/xproto.h>
|
||||
#include <xcb/shm.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
#include "glxclient.h"
|
||||
#include <dlfcn.h>
|
||||
#include "dri_common.h"
|
||||
|
@ -823,27 +826,26 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions)
|
|||
static int
|
||||
check_xshm(Display *dpy)
|
||||
{
|
||||
int (*old_handler)(Display *, XErrorEvent *);
|
||||
|
||||
xcb_connection_t *c = XGetXCBConnection(dpy);
|
||||
xcb_void_cookie_t cookie;
|
||||
xcb_generic_error_t *error;
|
||||
int ret = True;
|
||||
int ignore;
|
||||
XShmSegmentInfo info = { 0, };
|
||||
|
||||
if (!XQueryExtension(dpy, "MIT-SHM", &xshm_opcode, &ignore, &ignore))
|
||||
return False;
|
||||
|
||||
old_handler = XSetErrorHandler(handle_xerror);
|
||||
XShmDetach(dpy, &info);
|
||||
XSync(dpy, False);
|
||||
(void) XSetErrorHandler(old_handler);
|
||||
cookie = xcb_shm_detach_checked(c, 0);
|
||||
if ((error = xcb_request_check(c, 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);
|
||||
}
|
||||
|
||||
/* BadRequest means we're a remote client. If we were local we'd
|
||||
* expect BadValue since 'info' has an invalid segment name.
|
||||
*/
|
||||
if (xshm_error == BadRequest)
|
||||
return False;
|
||||
|
||||
xshm_error = 0;
|
||||
return True;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct glx_screen *
|
||||
|
|
|
@ -159,7 +159,7 @@ libgl = shared_library(
|
|||
dependencies : [
|
||||
dep_libdrm, dep_dl, dep_m, dep_thread, dep_x11, dep_xcb_glx, dep_xcb,
|
||||
dep_x11_xcb, dep_xcb_dri2, dep_xext, dep_xfixes, dep_xdamage, dep_xxf86vm,
|
||||
extra_deps_libgl,
|
||||
dep_xcb_shm, extra_deps_libgl,
|
||||
],
|
||||
version : gl_lib_version,
|
||||
install : true,
|
||||
|
|
Loading…
Reference in New Issue