diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 46ee6740e30..2495ac3146c 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -1170,6 +1170,21 @@ dri2GetGlxDrawableFromXDrawableId(Display *dpy, XID id) return NULL; } +bool +dri2CheckSupport(Display *dpy) +{ + int eventBase, errorBase; + int driMajor, driMinor; + + if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) + return false; + if (!DRI2QueryVersion(dpy, &driMajor, &driMinor) || + driMinor < 3) { + return false; + } + return true; +} + /* * Allocate, initialize and return a __DRIdisplayPrivate object. * This is called from __glXInitialize() when we are given a new @@ -1179,22 +1194,13 @@ _X_HIDDEN __GLXDRIdisplay * dri2CreateDisplay(Display * dpy) { struct dri2_display *pdp; - int eventBase, errorBase, i; - int driMajor, driMinor; - - if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) - return NULL; - if (!DRI2QueryVersion(dpy, &driMajor, &driMinor) || - driMinor < 3) { - return NULL; - } pdp = malloc(sizeof *pdp); if (pdp == NULL) return NULL; - i = 0; + int i = 0; pdp->loader_extensions[i++] = &dri2LoaderExtension.base; pdp->loader_extensions[i++] = &dri2UseInvalidate.base; pdp->loader_extensions[i++] = &driBackgroundCallable.base; diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 466d4493233..8cdbc7a7e11 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -150,6 +150,7 @@ struct glx_screen *dri3_create_screen(int screen, struct glx_display * priv, boo void dri3_destroy_display(__GLXDRIdisplay * dpy); #endif +bool dri2CheckSupport(Display *dpy); struct glx_screen *dri2CreateScreen(int screen, struct glx_display * priv, bool driver_name_is_inferred); void dri2DestroyDisplay(__GLXDRIdisplay * dpy); diff --git a/src/glx/glxext.c b/src/glx/glxext.c index 6f3e696349d..24f6a4bc492 100644 --- a/src/glx/glxext.c +++ b/src/glx/glxext.c @@ -797,7 +797,7 @@ AllocAndFetchScreenConfigs(Display * dpy, struct glx_display * priv, enum glx_dr } #endif /* HAVE_DRI3 */ #if defined(HAVE_X11_DRI2) - if (psc == NULL && glx_driver & GLX_DRIVER_DRI2) { + if (psc == NULL && glx_driver & GLX_DRIVER_DRI2 && dri2CheckSupport(dpy)) { priv->dri2Display = dri2CreateDisplay(dpy); psc = dri2CreateScreen(i, priv, driver_name_is_inferred); if (psc)