summaryrefslogtreecommitdiff
path: root/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'extras/Mesa/src/mesa/drivers/dri/common/dri_util.c')
-rw-r--r--extras/Mesa/src/mesa/drivers/dri/common/dri_util.c86
1 files changed, 60 insertions, 26 deletions
diff --git a/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c b/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c
index dd83080cc..88caa34e9 100644
--- a/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c
+++ b/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c
@@ -141,6 +141,26 @@ __driUtilMessage(const char *f, ...)
}
}
+/*
+ * fd.o bug #1713: Some rare libGL's have __glXFindDRIScreen defined but do not
+ * export it via glXGetProcAddress. These are not supported anymore, so print
+ * an error message to that effect. - ajax 2004-10-26
+ */
+typedef __DRIscreen *(*PFNGLXFINDDRISCREEN)(__DRInativeDisplay *, int);
+
+static __DRIscreen *glx_find_dri_screen(__DRInativeDisplay *d, int i)
+{
+ PFNGLXFINDDRISCREEN findscreen =
+ (PFNGLXFINDDRISCREEN)glXGetProcAddress("__glXFindDRIScreen");
+
+ if (!findscreen)
+ {
+ __driUtilMessage("glXGetProcAddress(\"__glXFindDRIScreen\") failed!");
+ __driUtilMessage("Your libGL is too old, please upgrade.");
+ return NULL;
+ }
+ else return findscreen(d, i);
+}
/*****************************************************************/
/** \name Visual utility functions */
@@ -212,23 +232,33 @@ static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw)
static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw)
{
int retcode;
- __DRIdrawable *pdraw;
+ union
+ {
+ __DRIdrawable *pdraw;
+ void *ptr;
+ } p;
- retcode = drmHashLookup(drawHash, draw, (void **)&pdraw);
+ retcode = drmHashLookup(drawHash, draw, &p.ptr);
if (retcode)
return NULL;
- return pdraw;
+ return p.pdraw;
}
static void __driRemoveDrawable(void *drawHash, __DRIdrawable *pdraw)
{
int retcode;
- __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+ union
+ {
+ __DRIdrawablePrivate *pdp;
+ void *ptr;
+ } p;
+
+ p.pdp = (__DRIdrawablePrivate *)pdraw->private;
- retcode = drmHashLookup(drawHash, pdp->draw, (void **)&pdraw);
+ retcode = drmHashLookup(drawHash, p.pdp->draw, &p.ptr);
if (!retcode) { /* Found */
- drmHashDelete(drawHash, pdp->draw);
+ drmHashDelete(drawHash, p.pdp->draw);
}
}
@@ -286,21 +316,25 @@ static GLboolean __driWindowExists(Display *dpy, GLXDrawable draw)
static void __driGarbageCollectDrawables(void *drawHash)
{
__DRIid draw;
- __DRIdrawable *pdraw;
__DRInativeDisplay *dpy;
+ union
+ {
+ __DRIdrawable *pdraw;
+ void *ptr;
+ } p;
- if (drmHashFirst(drawHash, &draw, (void **)&pdraw)) {
+ if (drmHashFirst(drawHash, &draw, &p.ptr)) {
do {
- __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)p.pdraw->private;
dpy = pdp->driScreenPriv->display;
if (! (*window_exists)(dpy, draw)) {
/* Destroy the local drawable data in the hash table, if the
drawable no longer exists in the Xserver */
- __driRemoveDrawable(drawHash, pdraw);
- (*pdraw->destroyDrawable)(dpy, pdraw->private);
- _mesa_free(pdraw);
+ __driRemoveDrawable(drawHash, p.pdraw);
+ (*p.pdraw->destroyDrawable)(dpy, p.pdraw->private);
+ _mesa_free(p.pdraw);
}
- } while (drmHashNext(drawHash, &draw, (void **)&pdraw));
+ } while (drmHashNext(drawHash, &draw, &p.ptr));
}
}
@@ -353,7 +387,7 @@ static GLboolean driUnbindContext3(__DRInativeDisplay *dpy, int scrn,
return GL_FALSE;
}
- pDRIScreen = __glXFindDRIScreen(dpy, scrn);
+ pDRIScreen = glx_find_dri_screen(dpy, scrn);
if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
/* ERROR!!! */
return GL_FALSE;
@@ -529,7 +563,7 @@ static GLboolean driBindContext3(__DRInativeDisplay *dpy, int scrn,
return GL_FALSE;
}
- pDRIScreen = __glXFindDRIScreen(dpy, scrn);
+ pDRIScreen = glx_find_dri_screen(dpy, scrn);
if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
/* ERROR!!! */
return GL_FALSE;
@@ -563,7 +597,7 @@ static GLboolean driBindContext2(Display *dpy, int scrn,
return GL_FALSE;
}
- pDRIScreen = __glXFindDRIScreen(dpy, scrn);
+ pDRIScreen = glx_find_dri_screen(dpy, scrn);
modes = (driCompareGLXAPIVersion( 20040317 ) >= 0)
? gc->driContext.mode
: findConfigMode( dpy, scrn, gc->vid, pDRIScreen );
@@ -793,7 +827,7 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy,
int renderType,
const int *attrs)
{
- __DRIscreen * const pDRIScreen = __glXFindDRIScreen(dpy, modes->screen);
+ __DRIscreen * const pDRIScreen = glx_find_dri_screen(dpy, modes->screen);
__DRIscreenPrivate *psp;
__DRIdrawablePrivate *pdp;
@@ -848,7 +882,7 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy,
_mesa_free(pdp);
return NULL;
#else
- pdp->getInfo = XF86DRIGetDrawableInfo;
+ pdp->getInfo = (PFNGLXGETDRAWABLEINFOPROC) XF86DRIGetDrawableInfo;
#endif /* DRI_NEW_INTERFACE_ONLY */
}
@@ -988,7 +1022,7 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
__DRIscreenPrivate *psp;
void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL;
- pDRIScreen = __glXFindDRIScreen(dpy, modes->screen);
+ pDRIScreen = glx_find_dri_screen(dpy, modes->screen);
if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
/* ERROR!!! */
return NULL;
@@ -1033,16 +1067,16 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
pctx->bindContext3 = driBindContext3;
pctx->unbindContext3 = driUnbindContext3;
#else
- pctx->bindContext = driBindContext;
- pctx->unbindContext = driUnbindContext;
+ pctx->bindContext = (void *)driBindContext;
+ pctx->unbindContext = (void *)driUnbindContext;
if ( driCompareGLXAPIVersion( 20030606 ) >= 0 ) {
- pctx->bindContext2 = driBindContext2;
- pctx->unbindContext2 = driUnbindContext2;
+ pctx->bindContext2 = (void *)driBindContext2;
+ pctx->unbindContext2 = (void *)driUnbindContext2;
}
if ( driCompareGLXAPIVersion( 20040415 ) >= 0 ) {
- pctx->bindContext3 = driBindContext3;
- pctx->unbindContext3 = driUnbindContext3;
+ pctx->bindContext3 = (void *)driBindContext3;
+ pctx->unbindContext3 = (void *)driUnbindContext3;
}
#endif
@@ -1088,7 +1122,7 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis,
__DRIscreen *pDRIScreen;
const __GLcontextModes *modes;
- pDRIScreen = __glXFindDRIScreen(dpy, vis->screen);
+ pDRIScreen = glx_find_dri_screen(dpy, vis->screen);
if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
/* ERROR!!! */
return NULL;