*/
-#ifdef GLX_DIRECT_RENDERING
-
-#include <inttypes.h>
#include <assert.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
#ifndef DRI_NEW_INTERFACE_ONLY
# include <X11/Xlibint.h>
# include <Xext.h>
#include "drm_sarea.h"
#include "glcontextmodes.h"
-#ifndef GLX_OML_sync_control
+#ifndef PFNGLXGETMSCRATEOMLPROC
typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRInativeDisplay *dpy, __DRIid drawable, int32_t *numerator, int32_t *denominator);
#endif
+/**
+ * Weak thread-safety dispatch pointer. Older versions of libGL will not have
+ * this symbol, so a "weak" version is included here so that the driver will
+ * dynamically link properly. The value is set to \c NULL. This forces the
+ * driver to fall back to the old dispatch interface.
+ */
+struct _glapi_table *_glapi_DispatchTSD __attribute__((weak)) = NULL;
+
/**
* This is used in a couple of places that call \c driCreateNewDrawable.
*/
}
}
+/*
+ * 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 */
int retcode;
__DRIdrawable *pdraw;
- retcode = drmHashLookup(drawHash, draw, (void **)&pdraw);
+ retcode = drmHashLookup(drawHash, draw, (void *)&pdraw);
if (retcode)
return NULL;
return pdraw;
}
-static void __driRemoveDrawable(void *drawHash, __DRIdrawable *pdraw)
-{
- int retcode;
- __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
-
- retcode = drmHashLookup(drawHash, pdp->draw, (void **)&pdraw);
- if (!retcode) { /* Found */
- drmHashDelete(drawHash, pdp->draw);
- }
-}
-
#ifndef DRI_NEW_INTERFACE_ONLY
static GLboolean __driWindowExistsFlag;
static void __driGarbageCollectDrawables(void *drawHash)
{
__DRIid draw;
- __DRIdrawable *pdraw;
__DRInativeDisplay *dpy;
+ __DRIdrawable *pdraw;
- if (drmHashFirst(drawHash, &draw, (void **)&pdraw)) {
+ if (drmHashFirst(drawHash, &draw, (void *)&pdraw) == 1) {
do {
__DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)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);
+ drmHashDelete(drawHash, draw);
(*pdraw->destroyDrawable)(dpy, pdraw->private);
_mesa_free(pdraw);
}
- } while (drmHashNext(drawHash, &draw, (void **)&pdraw));
+ } while (drmHashNext(drawHash, &draw, (void *)&pdraw) == 1);
}
}
return GL_FALSE;
}
- pDRIScreen = __glXFindDRIScreen(dpy, scrn);
+ pDRIScreen = glx_find_dri_screen(dpy, scrn);
if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
/* ERROR!!! */
return GL_FALSE;
return GL_FALSE;
}
- pDRIScreen = __glXFindDRIScreen(dpy, scrn);
+ pDRIScreen = glx_find_dri_screen(dpy, scrn);
if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
/* ERROR!!! */
return GL_FALSE;
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 );
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;
_mesa_free(pdp);
return NULL;
#else
- pdp->getInfo = XF86DRIGetDrawableInfo;
+ pdp->getInfo = (PFNGLXGETDRAWABLEINFOPROC) XF86DRIGetDrawableInfo;
#endif /* DRI_NEW_INTERFACE_ONLY */
}
__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;
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
__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;
*
* \sa __glXGetInternalVersion().
*/
-int driCompareGLXAPIVersion( GLuint required_version )
+int driCompareGLXAPIVersion( GLint required_version )
{
if ( api_ver > required_version ) {
return 1;
}
/*@}*/
-
-#endif /* GLX_DIRECT_RENDERING */