glx: move dri2 init checks to separate function
Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30375>
This commit is contained in:

committed by
Marge Bot

parent
5f55da01db
commit
d723438e0d
@@ -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;
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user