diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index b178146c6fb..2cdf39ccad7 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -799,24 +799,6 @@ dri2GetSwapInterval(__GLXDRIdrawable *pdraw) return priv->swap_interval; } -static void -driSetBackgroundContext(void *loaderPrivate) -{ - __glXSetCurrentContext(loaderPrivate); -} - -static GLboolean -driIsThreadSafe(void *loaderPrivate) -{ - struct glx_context *pcp = (struct glx_context *) loaderPrivate; - /* Check Xlib is running in thread safe mode - * - * 'lock_fns' is the XLockDisplay function pointer of the X11 display 'dpy'. - * It will be NULL if XInitThreads wasn't called. - */ - return pcp->psc->dpy->lock_fns != NULL; -} - static const __DRIdri2LoaderExtension dri2LoaderExtension = { .base = { __DRI_DRI2_LOADER, 3 }, @@ -825,17 +807,6 @@ static const __DRIdri2LoaderExtension dri2LoaderExtension = { .getBuffersWithFormat = dri2GetBuffersWithFormat, }; -const __DRIuseInvalidateExtension dri2UseInvalidate = { - .base = { __DRI_USE_INVALIDATE, 1 } -}; - -const __DRIbackgroundCallableExtension driBackgroundCallable = { - .base = { __DRI_BACKGROUND_CALLABLE, 2 }, - - .setBackgroundContext = driSetBackgroundContext, - .isThreadSafe = driIsThreadSafe, -}; - _X_HIDDEN void dri2InvalidateBuffers(Display *dpy, XID drawable) { diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 1074696d16b..d56a6b57792 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -541,7 +541,7 @@ const __DRIuseInvalidateExtension dri3UseInvalidate = { .base = { __DRI_USE_INVALIDATE, 1 } }; -static const __DRIbackgroundCallableExtension driBackgroundCallable = { +static const __DRIbackgroundCallableExtension dri3BackgroundCallable = { .base = { __DRI_BACKGROUND_CALLABLE, 2 }, .setBackgroundContext = dri_set_background_context, @@ -551,7 +551,7 @@ static const __DRIbackgroundCallableExtension driBackgroundCallable = { static const __DRIextension *loader_extensions[] = { &imageLoaderExtension.base, &dri3UseInvalidate.base, - &driBackgroundCallable.base, + &dri3BackgroundCallable.base, NULL }; diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 8ddad6f0b51..686c560c097 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -806,4 +806,33 @@ out: return e ? e->config : NULL; } +static void +driSetBackgroundContext(void *loaderPrivate) +{ + __glXSetCurrentContext(loaderPrivate); +} + +static GLboolean +driIsThreadSafe(void *loaderPrivate) +{ + struct glx_context *pcp = (struct glx_context *) loaderPrivate; + /* Check Xlib is running in thread safe mode + * + * 'lock_fns' is the XLockDisplay function pointer of the X11 display 'dpy'. + * It will be NULL if XInitThreads wasn't called. + */ + return pcp->psc->dpy->lock_fns != NULL; +} + +const __DRIbackgroundCallableExtension driBackgroundCallable = { + .base = { __DRI_BACKGROUND_CALLABLE, 2 }, + + .setBackgroundContext = driSetBackgroundContext, + .isThreadSafe = driIsThreadSafe, +}; + +const __DRIuseInvalidateExtension dri2UseInvalidate = { + .base = { __DRI_USE_INVALIDATE, 1 } +}; + #endif /* GLX_DIRECT_RENDERING */ diff --git a/src/glx/dri_common.h b/src/glx/dri_common.h index adb2aaf2dbe..cfa07955c74 100644 --- a/src/glx/dri_common.h +++ b/src/glx/dri_common.h @@ -90,6 +90,9 @@ dri_common_create_context(struct glx_screen *base, struct glx_context *shareList, int renderType); +extern const __DRIbackgroundCallableExtension driBackgroundCallable; +extern const __DRIuseInvalidateExtension dri2UseInvalidate; + #endif /* GLX_DIRECT_RENDERING */ #endif /* _DRI_COMMON_H */ diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index e37b6ee7041..31de1a21755 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -406,9 +406,6 @@ static const __DRIextension *loader_extensions_noshm[] = { NULL }; -extern const __DRIuseInvalidateExtension dri2UseInvalidate; -extern const __DRIbackgroundCallableExtension driBackgroundCallable; - static const __DRIextension *kopper_extensions_noshm[] = { &swrastLoaderExtension.base, &kopperLoaderExtension.base, diff --git a/src/glx/glxext.c b/src/glx/glxext.c index eee9f040151..85ed4a30e88 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -785,8 +785,10 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv, Bool zink, if (priv->dri3Display) psc = priv->dri3Display->createScreen(i, priv, driver_name_is_inferred); #endif /* HAVE_DRI3 */ +#if defined(HAVE_X11_DRI2) if (psc == NULL && priv->dri2Display) psc = priv->dri2Display->createScreen(i, priv, driver_name_is_inferred); +#endif #endif /* GLX_USE_DRM */ #ifdef GLX_USE_WINDOWSGL @@ -917,8 +919,10 @@ __glXInitialize(Display * dpy) try_zink = !debug_get_bool_option("LIBGL_KOPPER_DISABLE", false); } #endif /* HAVE_DRI3 */ +#if defined(HAVE_X11_DRI2) if (!debug_get_bool_option("LIBGL_DRI2_DISABLE", false)) dpyPriv->dri2Display = dri2CreateDisplay(dpy); +#endif #if defined(HAVE_ZINK) if (!dpyPriv->dri3Display && !dpyPriv->dri2Display) try_zink = !debug_get_bool_option("LIBGL_KOPPER_DISABLE", false) && diff --git a/src/glx/meson.build b/src/glx/meson.build index caf0417ed4b..da2eeddb7d2 100644 --- a/src/glx/meson.build +++ b/src/glx/meson.build @@ -61,7 +61,7 @@ extra_deps_libgl = [] extra_ld_args_libgl = [] # dri2 -if (with_dri_platform == 'drm' and dep_libdrm.found()) or with_dri_platform == 'apple' +if with_x11_dri2 files_libglx += files( 'dri2.c', 'dri2_glx.c',