X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Fx11%2Fglxcmds.c;h=2110b2cd86d35994b71a372bd68dc5bd0412ee1d;hb=6497d50924230e6b96929c8da0c2bd7287b70d8a;hp=ba3bf7572dd64078e2ba8b031ead9ea4b9437e80;hpb=489ccef3982267b0d35c8548921f58d553c25a3a;p=mesa.git diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index ba3bf7572dd..2110b2cd86d 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -39,178 +39,110 @@ * Client-side GLX interface. */ -#include #include "glxclient.h" -#include -#include -#include -#include #include "glapi.h" -#ifdef GLX_DIRECT_RENDERING -#include "indirect_init.h" -#include "xf86vmode.h" -#endif #include "glxextensions.h" #include "glcontextmodes.h" #include "glheader.h" -#include -#ifdef IN_DOXYGEN -#define GLX_PREFIX(x) x -#endif /* IN_DOXYGEN */ +#ifdef GLX_DIRECT_RENDERING +#include +#include +#include "xf86dri.h" +#endif static const char __glXGLXClientVendorName[] = "SGI"; static const char __glXGLXClientVersion[] = "1.4"; -#if defined(GLX_DIRECT_RENDERING) -#include "xf86dri.h" - -static Bool __glXWindowExists(Display *dpy, GLXDrawable draw); - -static void * DriverCreateContextWrapper( const __GLXscreenConfigs *psc, - Display *dpy, XVisualInfo *vis, void *shared, __DRIcontext *ctx, - const __GLcontextModes *fbconfig, int render_type ); - -static Bool dummyBindContext2( Display *dpy, int scrn, - GLXDrawable draw, GLXDrawable read, GLXContext gc ); - -static Bool dummyUnbindContext2( Display *dpy, int scrn, - GLXDrawable draw, GLXDrawable read, GLXContext gc ); - /****************************************************************************/ -/** - * Used as glue when a driver does not support - * \c __DRIcontextRec::bindContext2. - * - * XXX .bindContext is only defined as a function pointer if - * !DRI_NEW_INTERFACE_ONLY. - * - * \sa DriverCreateContextWrapper, __DRIcontextRec::bindContext2 - */ -static Bool dummyBindContext2( Display *dpy, int scrn, - GLXDrawable draw, GLXDrawable read, - GLXContext gc ) -{ - assert( draw == read ); - return (*gc->driContext.bindContext)( dpy, scrn, draw, gc ); -} +#ifdef GLX_DIRECT_RENDERING -/** - * Used as glue when a driver does not support - * \c __DRIcontextRec::unbindContext2. - * - * XXX .unbindContext is only defined as a function pointer if - * !DRI_NEW_INTERFACE_ONLY. - * - * \sa DriverCreateContextWrapper, __DRIcontextRec::unbindContext2 - */ -static Bool dummyUnbindContext2( Display *dpy, int scrn, - GLXDrawable draw, GLXDrawable read, - GLXContext gc ) +static Bool windowExistsFlag; +static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr) { - assert( draw == read ); - return (*gc->driContext.unbindContext)( dpy, scrn, draw, gc, GL_FALSE ); + if (xerr->error_code == BadWindow) { + windowExistsFlag = GL_FALSE; + } + return 0; } - -/****************************************************************************/ /** - * Wrap the call to the driver's \c createContext function. - * - * The \c createContext function is wrapped because not all drivers support - * the "new" \c unbindContext2 and \c bindContext2 interfaces. libGL should - * not have to check to see which functions the driver supports. Instead, - * if either function is not supported it is wrapped. The wrappers test to - * make sure that both drawables are the same and pass control to the old - * interface. - * - * \sa dummyBindContext2, dummyUnbindContext2, - * __DRIcontextRec::bindContext2, __DRIcontextRec::unbindContext2 + * Find drawables in the local hash that have been destroyed on the + * server. + * + * \param dpy Display to destroy drawables for + * \param screen Screen number to destroy drawables for */ - -static void * DriverCreateContextWrapper( const __GLXscreenConfigs *psc, - Display *dpy, XVisualInfo *vis, - void *shared, - __DRIcontext *ctx, - const __GLcontextModes *modes, - int render_type ) +static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc) { - void * ctx_priv = NULL; - - if ( psc->driScreen.createNewContext != NULL ) { - assert( modes != NULL ); - ctx_priv = (*psc->driScreen.createNewContext)(dpy, modes, render_type, - shared, ctx); - - /* If the driver supports the createNewContext interface, then - * it MUST also support either the bindContext2 / unbindContext2 - * interface or the bindContext3 / unbindContext3 interface. - */ - - assert( (ctx_priv == NULL) || (ctx->unbindContext2 != NULL) - || (ctx->unbindContext3 != NULL) ); - assert( (ctx_priv == NULL) || (ctx->bindContext2 != NULL) - || (ctx->bindContext3 != NULL) ); - } - else { - if ( vis != NULL ) { - ctx_priv = (*psc->driScreen.createContext)(dpy, vis, shared, ctx); + XID draw; + __GLXDRIdrawable *pdraw; + XWindowAttributes xwa; + int (*oldXErrorHandler)(Display *, XErrorEvent *); - if ( ctx_priv != NULL ) { - if ( ctx->unbindContext2 == NULL ) { - ctx->unbindContext2 = dummyUnbindContext2; - } + /* Set no-op error handler so Xlib doesn't bail out if the windows + * has alreay been destroyed on the server. */ + XSync(dpy, GL_FALSE); + oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler); - if ( ctx->bindContext2 == NULL ) { - ctx->bindContext2 = dummyBindContext2; - } + if (__glxHashFirst(sc->drawHash, &draw, (void *)&pdraw) == 1) { + do { + windowExistsFlag = GL_TRUE; + XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */ + if (!windowExistsFlag) { + /* Destroy the local drawable data, if the drawable no + longer exists in the Xserver */ + (*pdraw->destroyDrawable)(pdraw); + __glxHashDelete(sc->drawHash, draw); } - } + } while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1); } - return ctx_priv; + XSync(dpy, GL_FALSE); + XSetErrorHandler(oldXErrorHandler); } -#endif +extern __GLXDRIdrawable * +GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num); -/****************************************************************************/ /** * Get the __DRIdrawable for the drawable associated with a GLXContext * * \param dpy The display associated with \c drawable. * \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved. + * \param scrn_num If non-NULL, the drawables screen is stored there * \returns A pointer to the context's __DRIdrawable on success, or NULL if * the drawable is not associated with a direct-rendering context. */ - -#ifdef GLX_DIRECT_RENDERING -static __DRIdrawable * -GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num ) +_X_HIDDEN __GLXDRIdrawable * +GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num) { - __GLXdisplayPrivate * const priv = __glXInitialize(dpy); - - if ( (priv != NULL) && (priv->driDisplay.private != NULL) ) { - const unsigned screen_count = ScreenCount(dpy); - unsigned i; - - for ( i = 0 ; i < screen_count ; i++ ) { - __DRIscreen * const psc = &priv->screenConfigs[i].driScreen; - __DRIdrawable * const pdraw = (psc->private != NULL) - ? (*psc->getDrawable)(dpy, drawable, psc->private) : NULL; + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + __GLXDRIdrawable *pdraw; + const unsigned screen_count = ScreenCount(dpy); + unsigned i; + __GLXscreenConfigs *psc; - if ( pdraw != NULL ) { - if ( scrn_num != NULL ) { - *scrn_num = i; - } - return pdraw; - } + if (priv == NULL) + return NULL; + + for (i = 0; i < screen_count; i++) { + psc = &priv->screenConfigs[i]; + if (psc->drawHash == NULL) + continue; + + if (__glxHashLookup(psc->drawHash, drawable, (void *) &pdraw) == 0) { + if (scrn_num != NULL) + *scrn_num = i; + return pdraw; } } return NULL; } + #endif @@ -371,8 +303,6 @@ GLXContext AllocateGLXContext( Display *dpy ) state->storePack.alignment = 4; state->storeUnpack.alignment = 4; - __glXInitVertexArrayState(gc); - gc->attributes.stackPointer = &gc->attributes.stack[0]; /* @@ -382,9 +312,9 @@ GLXContext AllocateGLXContext( Display *dpy ) */ gc->fastImageUnpack = GL_FALSE; gc->fillImage = __glFillImage; - gc->isDirect = GL_FALSE; gc->pc = gc->buf; gc->bufEnd = gc->buf + bufSize; + gc->isDirect = GL_FALSE; if (__glXDebug) { /* ** Set limit register so that there will be one command per packet @@ -430,6 +360,10 @@ CreateContext(Display *dpy, XVisualInfo *vis, Bool use_glx_1_3, int renderType) { GLXContext gc; +#ifdef GLX_DIRECT_RENDERING + int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen; + __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); +#endif if ( dpy == NULL ) return NULL; @@ -443,41 +377,36 @@ CreateContext(Display *dpy, XVisualInfo *vis, return NULL; #ifdef GLX_DIRECT_RENDERING - if (allowDirect) { - int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen; - __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); + if (allowDirect && psc->driScreen) { const __GLcontextModes * mode; - /* The value of fbconfig cannot change because it is tested - * later in the function. - */ - if ( fbconfig == NULL ) { - /* FIXME: Is it possible for the __GLcontextModes structure - * FIXME: to not be found? - */ - mode = _gl_context_modes_find_visual( psc->configs, - vis->visualid ); - assert( mode != NULL ); - assert( mode->screen == screen ); + if (fbconfig == NULL) { + mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid); + if (mode == NULL) { + xError error; + + error.errorCode = BadValue; + error.resourceID = vis->visualid; + error.sequenceNumber = dpy->request; + error.type = X_Error; + error.majorCode = gc->majorOpcode; + error.minorCode = X_GLXCreateContext; + _XError(dpy, &error); + return None; + } } else { mode = fbconfig; } - if (psc && psc->driScreen.private) { - void * const shared = (shareList != NULL) - ? shareList->driContext.private : NULL; - gc->driContext.private = - DriverCreateContextWrapper( psc, dpy, vis, shared, - &gc->driContext, mode, - renderType ); - if (gc->driContext.private) { - gc->isDirect = GL_TRUE; - gc->screen = mode->screen; - gc->vid = mode->visualID; - gc->fbconfigID = mode->fbconfigID; - gc->driContext.mode = mode; - } + gc->driContext = psc->driScreen->createContext(psc, mode, gc, + shareList, + renderType); + if (gc->driContext != NULL) { + gc->screen = mode->screen; + gc->psc = psc; + gc->mode = mode; + gc->isDirect = GL_TRUE; } } #endif @@ -494,7 +423,7 @@ CreateContext(Display *dpy, XVisualInfo *vis, req->visual = vis->visualid; req->screen = vis->screen; req->shareList = shareList ? shareList->xid : None; - req->isDirect = gc->isDirect; + req->isDirect = gc->driContext != NULL; } else if ( use_glx_1_3 ) { xGLXCreateNewContextReq *req; @@ -508,7 +437,7 @@ CreateContext(Display *dpy, XVisualInfo *vis, req->screen = fbconfig->screen; req->renderType = renderType; req->shareList = shareList ? shareList->xid : None; - req->isDirect = gc->isDirect; + req->isDirect = gc->driContext != NULL; } else { xGLXVendorPrivateWithReplyReq *vpreq; @@ -526,7 +455,7 @@ CreateContext(Display *dpy, XVisualInfo *vis, req->screen = fbconfig->screen; req->renderType = renderType; req->shareList = shareList ? shareList->xid : None; - req->isDirect = gc->isDirect; + req->isDirect = gc->driContext != NULL; } UnlockDisplay(dpy); @@ -541,15 +470,14 @@ CreateContext(Display *dpy, XVisualInfo *vis, return gc; } -PUBLIC GLXContext GLX_PREFIX(glXCreateContext)(Display *dpy, XVisualInfo *vis, - GLXContext shareList, - Bool allowDirect) +PUBLIC GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis, + GLXContext shareList, Bool allowDirect) { return CreateContext(dpy, vis, NULL, shareList, allowDirect, None, False, 0); } -void __glXFreeContext(__GLXcontext *gc) +_X_HIDDEN void __glXFreeContext(__GLXcontext *gc) { if (gc->vendor) XFree((char *) gc->vendor); if (gc->renderer) XFree((char *) gc->renderer); @@ -585,12 +513,10 @@ DestroyContext(Display *dpy, GLXContext gc) #ifdef GLX_DIRECT_RENDERING /* Destroy the direct rendering context */ - if (gc->isDirect) { - if (gc->driContext.private) { - (*gc->driContext.destroyContext)(dpy, gc->screen, - gc->driContext.private); - gc->driContext.private = NULL; - } + if (gc->driContext) { + (*gc->driContext->destroyContext)(gc->driContext, gc->psc, dpy); + gc->driContext = NULL; + GarbageCollectDRIDrawables(dpy, gc->psc); } #endif @@ -618,7 +544,7 @@ DestroyContext(Display *dpy, GLXContext gc) } } -PUBLIC void GLX_PREFIX(glXDestroyContext)(Display *dpy, GLXContext gc) +PUBLIC void glXDestroyContext(Display *dpy, GLXContext gc) { DestroyContext(dpy, gc); } @@ -626,7 +552,7 @@ PUBLIC void GLX_PREFIX(glXDestroyContext)(Display *dpy, GLXContext gc) /* ** Return the major and minor version #s for the GLX extension */ -PUBLIC Bool GLX_PREFIX(glXQueryVersion)(Display *dpy, int *major, int *minor) +PUBLIC Bool glXQueryVersion(Display *dpy, int *major, int *minor) { __GLXdisplayPrivate *priv; @@ -642,8 +568,7 @@ PUBLIC Bool GLX_PREFIX(glXQueryVersion)(Display *dpy, int *major, int *minor) /* ** Query the existance of the GLX extension */ -PUBLIC Bool GLX_PREFIX(glXQueryExtension)(Display *dpy, int *errorBase, - int *eventBase) +PUBLIC Bool glXQueryExtension(Display *dpy, int *errorBase, int *eventBase) { int major_op, erb, evb; Bool rv; @@ -660,7 +585,7 @@ PUBLIC Bool GLX_PREFIX(glXQueryExtension)(Display *dpy, int *errorBase, ** Put a barrier in the token stream that forces the GL to finish its ** work before X can proceed. */ -PUBLIC void GLX_PREFIX(glXWaitGL)(void) +PUBLIC void glXWaitGL(void) { xGLXWaitGLReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -672,7 +597,7 @@ PUBLIC void GLX_PREFIX(glXWaitGL)(void) __glXFlushRenderBuffer(gc, gc->pc); #ifdef GLX_DIRECT_RENDERING - if (gc->isDirect) { + if (gc->driContext) { /* This bit of ugliness unwraps the glFinish function */ #ifdef glFinish #undef glFinish @@ -696,7 +621,7 @@ PUBLIC void GLX_PREFIX(glXWaitGL)(void) ** Put a barrier in the token stream that forces X to finish its ** work before GL can proceed. */ -PUBLIC void GLX_PREFIX(glXWaitX)(void) +PUBLIC void glXWaitX(void) { xGLXWaitXReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -708,7 +633,7 @@ PUBLIC void GLX_PREFIX(glXWaitX)(void) __glXFlushRenderBuffer(gc, gc->pc); #ifdef GLX_DIRECT_RENDERING - if (gc->isDirect) { + if (gc->driContext) { XSync(dpy, False); return; } @@ -726,8 +651,7 @@ PUBLIC void GLX_PREFIX(glXWaitX)(void) SyncHandle(); } -PUBLIC void GLX_PREFIX(glXUseXFont)(Font font, int first, int count, - int listBase) +PUBLIC void glXUseXFont(Font font, int first, int count, int listBase) { xGLXUseXFontReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -739,7 +663,7 @@ PUBLIC void GLX_PREFIX(glXUseXFont)(Font font, int first, int count, (void) __glXFlushRenderBuffer(gc, gc->pc); #ifdef GLX_DIRECT_RENDERING - if (gc->isDirect) { + if (gc->driContext) { DRI_glXUseXFont(font, first, count, listBase); return; } @@ -765,8 +689,8 @@ PUBLIC void GLX_PREFIX(glXUseXFont)(Font font, int first, int count, ** Copy the source context to the destination context using the ** attribute "mask". */ -PUBLIC void GLX_PREFIX(glXCopyContext)(Display *dpy, GLXContext source, - GLXContext dest, unsigned long mask) +PUBLIC void glXCopyContext(Display *dpy, GLXContext source, + GLXContext dest, unsigned long mask) { xGLXCopyContextReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -779,7 +703,7 @@ PUBLIC void GLX_PREFIX(glXCopyContext)(Display *dpy, GLXContext source, } #ifdef GLX_DIRECT_RENDERING - if (gc->isDirect) { + if (gc->driContext) { /* NOT_DONE: This does not work yet */ } #endif @@ -840,20 +764,26 @@ static Bool __glXIsDirect(Display *dpy, GLXContextID contextID) return reply.isDirect; } -PUBLIC Bool GLX_PREFIX(glXIsDirect)(Display *dpy, GLXContext gc) +/** + * \todo + * Shouldn't this function \b always return \c GL_FALSE when + * \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with + * the GLX protocol here at all? + */ +PUBLIC Bool glXIsDirect(Display *dpy, GLXContext gc) { if (!gc) { return GL_FALSE; #ifdef GLX_DIRECT_RENDERING - } else if (gc->isDirect) { + } else if (gc->driContext) { return GL_TRUE; #endif } return __glXIsDirect(dpy, gc->xid); } -PUBLIC GLXPixmap GLX_PREFIX(glXCreateGLXPixmap)(Display *dpy, XVisualInfo *vis, - Pixmap pixmap) +PUBLIC GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *vis, + Pixmap pixmap) { xGLXCreateGLXPixmapReq *req; GLXPixmap xid; @@ -881,7 +811,7 @@ PUBLIC GLXPixmap GLX_PREFIX(glXCreateGLXPixmap)(Display *dpy, XVisualInfo *vis, /* ** Destroy the named pixmap */ -PUBLIC void GLX_PREFIX(glXDestroyGLXPixmap)(Display *dpy, GLXPixmap glxpixmap) +PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap) { xGLXDestroyGLXPixmapReq *req; CARD8 opcode; @@ -901,17 +831,17 @@ PUBLIC void GLX_PREFIX(glXDestroyGLXPixmap)(Display *dpy, GLXPixmap glxpixmap) SyncHandle(); } -PUBLIC void GLX_PREFIX(glXSwapBuffers)(Display *dpy, GLXDrawable drawable) +PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable) { xGLXSwapBuffersReq *req; GLXContext gc; GLXContextTag tag; CARD8 opcode; #ifdef GLX_DIRECT_RENDERING - __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL ); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); - if ( pdraw != NULL ) { - (*pdraw->swapBuffers)(dpy, pdraw->private); + if (pdraw != NULL) { + (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable); return; } #endif @@ -950,17 +880,17 @@ PUBLIC void GLX_PREFIX(glXSwapBuffers)(Display *dpy, GLXDrawable drawable) ** Return configuration information for the given display, screen and ** visual combination. */ -PUBLIC int GLX_PREFIX(glXGetConfig)(Display *dpy, XVisualInfo *vis, - int attribute, int *value_return) +PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute, + int *value_return) { __GLXdisplayPrivate *priv; __GLXscreenConfigs *psc; + __GLcontextModes *modes; int status; status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ); if ( status == Success ) { - const __GLcontextModes * const modes = _gl_context_modes_find_visual( - psc->configs, vis->visualid ); + modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid); /* Lookup attribute after first finding a match on the visual */ if ( modes != NULL ) { @@ -1307,8 +1237,7 @@ choose_visual( __GLcontextModes ** configs, int num_configs, ** Return the visual that best matches the template. Return None if no ** visual matches the template. */ -PUBLIC XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, - int *attribList) +PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList) { XVisualInfo *visualList = NULL; __GLXdisplayPrivate *priv; @@ -1339,7 +1268,7 @@ PUBLIC XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, ** Compute a score for those that do ** Remember which visual, if any, got the highest score */ - for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) { + for ( modes = psc->visuals ; modes != NULL ; modes = modes->next ) { if ( fbconfigs_compatible( & test_config, modes ) && ((best_config == NULL) || (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) { @@ -1366,8 +1295,7 @@ PUBLIC XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, } -PUBLIC const char *GLX_PREFIX(glXQueryExtensionsString)( Display *dpy, - int screen ) +PUBLIC const char *glXQueryExtensionsString( Display *dpy, int screen ) { __GLXscreenConfigs *psc; __GLXdisplayPrivate *priv; @@ -1385,7 +1313,7 @@ PUBLIC const char *GLX_PREFIX(glXQueryExtensionsString)( Display *dpy, __glXCalculateUsableExtensions(psc, #ifdef GLX_DIRECT_RENDERING - (priv->driDisplay.private != NULL), + (psc->driScreen != NULL), #else GL_FALSE, #endif @@ -1395,7 +1323,7 @@ PUBLIC const char *GLX_PREFIX(glXQueryExtensionsString)( Display *dpy, return psc->effectiveGLXexts; } -PUBLIC const char *GLX_PREFIX(glXGetClientString)( Display *dpy, int name ) +PUBLIC const char *glXGetClientString( Display *dpy, int name ) { switch(name) { case GLX_VENDOR: @@ -1409,8 +1337,7 @@ PUBLIC const char *GLX_PREFIX(glXGetClientString)( Display *dpy, int name ) } } -PUBLIC const char *GLX_PREFIX(glXQueryServerString)( Display *dpy, int screen, - int name ) +PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name ) { __GLXscreenConfigs *psc; __GLXdisplayPrivate *priv; @@ -1565,13 +1492,15 @@ static int __glXQueryContextInfo(Display *dpy, GLXContext ctx) ctx->share_xid = *pProp++; break; case GLX_VISUAL_ID_EXT: - ctx->vid = *pProp++; + ctx->mode = + _gl_context_modes_find_visual(ctx->psc->visuals, *pProp++); break; case GLX_SCREEN: ctx->screen = *pProp++; break; case GLX_FBCONFIG_ID: - ctx->fbconfigID = *pProp++; + ctx->mode = + _gl_context_modes_find_fbconfig(ctx->psc->configs, *pProp++); break; case GLX_RENDER_TYPE: ctx->renderType = *pProp++; @@ -1591,13 +1520,12 @@ static int __glXQueryContextInfo(Display *dpy, GLXContext ctx) } PUBLIC int -GLX_PREFIX(glXQueryContext)(Display *dpy, GLXContext ctx, - int attribute, int *value) +glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value) { int retVal; /* get the information from the server if we don't have it already */ - if (!ctx->isDirect && (ctx->vid == None)) { + if (!ctx->driContext && (ctx->mode == NULL)) { retVal = __glXQueryContextInfo(dpy, ctx); if (Success != retVal) return retVal; } @@ -1606,13 +1534,13 @@ GLX_PREFIX(glXQueryContext)(Display *dpy, GLXContext ctx, *value = (int)(ctx->share_xid); break; case GLX_VISUAL_ID_EXT: - *value = (int)(ctx->vid); + *value = ctx->mode ? ctx->mode->visualID : None; break; case GLX_SCREEN: *value = (int)(ctx->screen); break; case GLX_FBCONFIG_ID: - *value = (int)(ctx->fbconfigID); + *value = ctx->mode ? ctx->mode->fbconfigID : None; break; case GLX_RENDER_TYPE: *value = (int)(ctx->renderType); @@ -1633,8 +1561,7 @@ PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx) return ctx->xid; } -PUBLIC GLXContext GLX_PREFIX(glXImportContextEXT)(Display *dpy, - GLXContextID contextID) +PUBLIC GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID) { GLXContext ctx; @@ -1654,7 +1581,7 @@ PUBLIC GLXContext GLX_PREFIX(glXImportContextEXT)(Display *dpy, return ctx; } -PUBLIC void GLX_PREFIX(glXFreeContextEXT)(Display *dpy, GLXContext ctx) +PUBLIC void glXFreeContextEXT(Display *dpy, GLXContext ctx) { DestroyContext(dpy, ctx); } @@ -1665,18 +1592,17 @@ PUBLIC void GLX_PREFIX(glXFreeContextEXT)(Display *dpy, GLXContext ctx) * GLX 1.3 functions - these are just stubs for now! */ -PUBLIC GLXFBConfig *GLX_PREFIX(glXChooseFBConfig)(Display *dpy, int screen, - const int *attribList, - int *nitems) +PUBLIC GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, + const int *attribList, int *nitems) { __GLcontextModes ** config_list; int list_size; config_list = (__GLcontextModes **) - GLX_PREFIX(glXGetFBConfigs)( dpy, screen, & list_size ); + glXGetFBConfigs( dpy, screen, & list_size ); - if ( (config_list != NULL) && (list_size > 0) ) { + if ( (config_list != NULL) && (list_size > 0) && (attribList != NULL) ) { list_size = choose_visual( config_list, list_size, attribList, GL_TRUE ); if ( list_size == 0 ) { @@ -1690,31 +1616,29 @@ PUBLIC GLXFBConfig *GLX_PREFIX(glXChooseFBConfig)(Display *dpy, int screen, } -PUBLIC GLXContext GLX_PREFIX(glXCreateNewContext)(Display *dpy, - GLXFBConfig config, - int renderType, - GLXContext shareList, - Bool allowDirect) +PUBLIC GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config, + int renderType, GLXContext shareList, + Bool allowDirect) { return CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList, allowDirect, None, True, renderType ); } -PUBLIC GLXDrawable GLX_PREFIX(glXGetCurrentReadDrawable)(void) +PUBLIC GLXDrawable glXGetCurrentReadDrawable(void) { GLXContext gc = __glXGetCurrentContext(); return gc->currentReadable; } -PUBLIC GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, - int *nelements) +PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements) { __GLXdisplayPrivate *priv = __glXInitialize(dpy); __GLcontextModes ** config = NULL; int i; + *nelements = 0; if ( (priv->screenConfigs != NULL) && (screen >= 0) && (screen <= ScreenCount(dpy)) && (priv->screenConfigs[screen].configs != NULL) @@ -1739,8 +1663,10 @@ PUBLIC GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, for ( modes = priv->screenConfigs[screen].configs ; modes != NULL ; modes = modes->next ) { - config[i] = modes; - i++; + if ( modes->fbconfigID != GLX_DONT_CARE ) { + config[i] = modes; + i++; + } } } } @@ -1748,8 +1674,8 @@ PUBLIC GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, } -PUBLIC int GLX_PREFIX(glXGetFBConfigAttrib)(Display *dpy, GLXFBConfig config, - int attribute, int *value) +PUBLIC int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, + int attribute, int *value) { __GLcontextModes * const modes = ValidateGLXFBConfig( dpy, config ); @@ -1759,8 +1685,7 @@ PUBLIC int GLX_PREFIX(glXGetFBConfigAttrib)(Display *dpy, GLXFBConfig config, } -PUBLIC XVisualInfo *GLX_PREFIX(glXGetVisualFromFBConfig)(Display *dpy, - GLXFBConfig config) +PUBLIC XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config) { XVisualInfo visualTemplate; __GLcontextModes * fbconfig = (__GLcontextModes *) config; @@ -1774,18 +1699,10 @@ PUBLIC XVisualInfo *GLX_PREFIX(glXGetVisualFromFBConfig)(Display *dpy, } -/* -** GLX_SGI_make_current_read -*/ - -PUBLIC GLX_ALIAS(GLXDrawable, glXGetCurrentReadDrawableSGI, (void), (), - glXGetCurrentReadDrawable) - - /* ** GLX_SGI_swap_control */ -PUBLIC int GLX_PREFIX(glXSwapIntervalSGI)(int interval) +static int __glXSwapIntervalSGI(int interval) { xGLXVendorPrivateReq *req; GLXContext gc = __glXGetCurrentContext(); @@ -1801,16 +1718,15 @@ PUBLIC int GLX_PREFIX(glXSwapIntervalSGI)(int interval) return GLX_BAD_VALUE; } -#ifdef GLX_DIRECT_RENDERING - if ( gc->isDirect ) { +#ifdef __DRI_SWAP_CONTROL + if (gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - __DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy, - gc->currentDrawable, - NULL ); - if ( __glXExtensionBitIsEnabled( psc, SGI_swap_control_bit ) - && (pdraw != NULL) ) { - pdraw->swap_interval = interval; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(gc->currentDpy, + gc->currentDrawable, + NULL); + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); return 0; } else { @@ -1832,7 +1748,7 @@ PUBLIC int GLX_PREFIX(glXSwapIntervalSGI)(int interval) req->vendorCode = X_GLXvop_SwapIntervalSGI; req->contextTag = gc->currentContextTag; - interval_ptr = (CARD32 *) req + 1; + interval_ptr = (CARD32 *) (req + 1); *interval_ptr = interval; UnlockDisplay(dpy); @@ -1846,27 +1762,24 @@ PUBLIC int GLX_PREFIX(glXSwapIntervalSGI)(int interval) /* ** GLX_MESA_swap_control */ -PUBLIC GLint GLX_PREFIX(glXSwapIntervalMESA)(unsigned interval) +static int __glXSwapIntervalMESA(unsigned int interval) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_CONTROL GLXContext gc = __glXGetCurrentContext(); if ( interval < 0 ) { return GLX_BAD_VALUE; } - if ( (gc != NULL) && gc->isDirect ) { + if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( (psc != NULL) && (psc->driScreen.private != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) { - __DRIdrawable * const pdraw = - (*psc->driScreen.getDrawable)(gc->currentDpy, - gc->currentDrawable, - psc->driScreen.private); - if ( pdraw != NULL ) { - pdraw->swap_interval = interval; + if ( (psc != NULL) && (psc->driScreen != NULL) ) { + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + if (psc->swapControl != NULL && pdraw != NULL) { + psc->swapControl->setSwapInterval(pdraw->driDrawable, interval); return 0; } } @@ -1878,23 +1791,21 @@ PUBLIC GLint GLX_PREFIX(glXSwapIntervalMESA)(unsigned interval) return GLX_BAD_CONTEXT; } -PUBLIC GLint GLX_PREFIX(glXGetSwapIntervalMESA)( void ) + +static int __glXGetSwapIntervalMESA(void) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_CONTROL GLXContext gc = __glXGetCurrentContext(); - if ( (gc != NULL) && gc->isDirect ) { + if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( (psc != NULL) && (psc->driScreen.private != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) { - __DRIdrawable * const pdraw = - (*psc->driScreen.getDrawable)(gc->currentDpy, - gc->currentDrawable, - psc->driScreen.private); - if ( pdraw != NULL ) { - return pdraw->swap_interval; + if ( (psc != NULL) && (psc->driScreen != NULL) ) { + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + if (psc->swapControl != NULL && pdraw != NULL) { + return psc->swapControl->getSwapInterval(pdraw->driDrawable); } } } @@ -1908,19 +1819,16 @@ PUBLIC GLint GLX_PREFIX(glXGetSwapIntervalMESA)( void ) ** GLX_MESA_swap_frame_usage */ -PUBLIC GLint GLX_PREFIX(glXBeginFrameTrackingMESA)(Display *dpy, - GLXDrawable drawable) +static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; - __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking( dpy, pdraw->private, GL_TRUE ); - } + if (pdraw != NULL && psc->frameTracking != NULL) + status = psc->frameTracking->frameTracking(pdraw->driDrawable, GL_TRUE); #else (void) dpy; (void) drawable; @@ -1929,19 +1837,17 @@ PUBLIC GLint GLX_PREFIX(glXBeginFrameTrackingMESA)(Display *dpy, } -PUBLIC GLint GLX_PREFIX(glXEndFrameTrackingMESA)(Display *dpy, - GLXDrawable drawable) +static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; - __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); - __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen); + __GLXscreenConfigs *psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL) && (pdraw->frameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - status = pdraw->frameTracking( dpy, pdraw->private, GL_FALSE ); - } + if (pdraw != NULL && psc->frameTracking != NULL) + status = psc->frameTracking->frameTracking(pdraw->driDrawable, + GL_FALSE); #else (void) dpy; (void) drawable; @@ -1950,24 +1856,24 @@ PUBLIC GLint GLX_PREFIX(glXEndFrameTrackingMESA)(Display *dpy, } -PUBLIC GLint GLX_PREFIX(glXGetFrameUsageMESA)(Display *dpy, - GLXDrawable drawable, - GLfloat *usage) +static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable, + GLfloat *usage) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; - __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); + __GLXDRIdrawable * const pdraw = GetGLXDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { - int64_t sbc, missedFrames; - float lastMissedUsage; + if (pdraw != NULL && psc->frameTracking != NULL) { + int64_t sbc, missedFrames; + float lastMissedUsage; - status = pdraw->queryFrameTracking( dpy, pdraw->private, &sbc, - &missedFrames, &lastMissedUsage, - usage ); + status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, + &sbc, + &missedFrames, + &lastMissedUsage, + usage); } #else (void) dpy; @@ -1978,25 +1884,22 @@ PUBLIC GLint GLX_PREFIX(glXGetFrameUsageMESA)(Display *dpy, } -PUBLIC GLint GLX_PREFIX(glXQueryFrameTrackingMESA)(Display *dpy, - GLXDrawable drawable, - int64_t *sbc, - int64_t *missedFrames, - GLfloat *lastMissedUsage) +static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable, + int64_t *sbc, int64_t *missedFrames, + GLfloat *lastMissedUsage) { int status = GLX_BAD_CONTEXT; -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_FRAME_TRACKING int screen; - __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, & screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen); - if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL) - && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) { + if (pdraw != NULL && psc->frameTracking != NULL) { float usage; - status = pdraw->queryFrameTracking( dpy, pdraw->private, sbc, - missedFrames, lastMissedUsage, - & usage ); + status = psc->frameTracking->queryFrameTracking(pdraw->driDrawable, + sbc, missedFrames, + lastMissedUsage, &usage); } #else (void) dpy; @@ -2012,27 +1915,30 @@ PUBLIC GLint GLX_PREFIX(glXQueryFrameTrackingMESA)(Display *dpy, /* ** GLX_SGI_video_sync */ -PUBLIC int GLX_PREFIX(glXGetVideoSyncSGI)(unsigned int *count) +static int __glXGetVideoSyncSGI(unsigned int *count) { /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry, * FIXME: there should be a GLX encoding for this call. I can find no * FIXME: documentation for the GLX encoding. */ -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_MEDIA_STREAM_COUNTER GLXContext gc = __glXGetCurrentContext(); - if ( (gc != NULL) && gc->isDirect ) { + if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit ) - && psc->driScreen.private && psc->driScreen.getMSC) { - int ret; - int64_t temp; + if ( psc->msc && psc->driScreen ) { + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + int64_t temp; + int ret; + + ret = (*psc->msc->getDrawableMSC)(psc->__driScreen, + pdraw->driDrawable, &temp); + *count = (unsigned) temp; - ret = psc->driScreen.getMSC( psc->driScreen.private, & temp ); - *count = (unsigned) temp; - return (ret == 0) ? 0 : GLX_BAD_CONTEXT; + return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } } #else @@ -2041,35 +1947,28 @@ PUBLIC int GLX_PREFIX(glXGetVideoSyncSGI)(unsigned int *count) return GLX_BAD_CONTEXT; } -PUBLIC int GLX_PREFIX(glXWaitVideoSyncSGI)(int divisor, int remainder, - unsigned int *count) +static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_MEDIA_STREAM_COUNTER GLXContext gc = __glXGetCurrentContext(); if ( divisor <= 0 || remainder < 0 ) return GLX_BAD_VALUE; - if ( (gc != NULL) && gc->isDirect ) { + if (gc != NULL && gc->driContext) { __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy, gc->screen ); - if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit ) - && psc->driScreen.private ) { - __DRIdrawable * const pdraw = - (*psc->driScreen.getDrawable)(gc->currentDpy, - gc->currentDrawable, - psc->driScreen.private); - if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) ) { - int ret; - int64_t msc; - int64_t sbc; - - ret = (*pdraw->waitForMSC)( gc->currentDpy, pdraw->private, - 0, divisor, remainder, - & msc, & sbc ); - *count = (unsigned) msc; - return (ret == 0) ? 0 : GLX_BAD_CONTEXT; - } + if (psc->msc != NULL && psc->driScreen ) { + __GLXDRIdrawable *pdraw = + GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL); + int ret; + int64_t msc; + int64_t sbc; + + ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, 0, + divisor, remainder, &msc, &sbc); + *count = (unsigned) msc; + return (ret == 0) ? 0 : GLX_BAD_CONTEXT; } } #else @@ -2079,34 +1978,6 @@ PUBLIC int GLX_PREFIX(glXWaitVideoSyncSGI)(int divisor, int remainder, } -/* -** GLX_SGIS_video_source -*/ -#if defined(_VL_H) - -PUBLIC GLXVideoSourceSGIX GLX_PREFIX(glXCreateGLXVideoSourceSGIX)(Display *dpy, - int screen, VLServer server, VLPath path, - int nodeClass, VLNode drainNode) -{ - (void) dpy; - (void) screen; - (void) server; - (void) path; - (void) nodeClass; - (void) drainNode; - return 0; -} - -PUBLIC void GLX_PREFIX(glXDestroyGLXVideoSourceSGIX)(Display *dpy, - GLXVideoSourceSGIX src) -{ - (void) dpy; - (void) src; -} - -#endif - - /* ** GLX_SGIX_fbconfig ** Many of these functions are aliased to GLX 1.3 entry points in the @@ -2128,7 +1999,7 @@ PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX, (dpy, config), glXGetVisualFromFBConfig) -PUBLIC GLXPixmap GLX_PREFIX(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, +PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap) { xGLXVendorPrivateWithReplyReq *vpreq; @@ -2170,7 +2041,7 @@ PUBLIC GLXPixmap GLX_PREFIX(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, return xid; } -PUBLIC GLXContext GLX_PREFIX(glXCreateContextWithConfigSGIX)(Display *dpy, +PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int renderType, GLXContext shareList, Bool allowDirect) { @@ -2194,8 +2065,8 @@ PUBLIC GLXContext GLX_PREFIX(glXCreateContextWithConfigSGIX)(Display *dpy, } -PUBLIC GLXFBConfigSGIX GLX_PREFIX(glXGetFBConfigFromVisualSGIX)(Display *dpy, - XVisualInfo *vis) +PUBLIC GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy, + XVisualInfo *vis) { __GLXdisplayPrivate *priv; __GLXscreenConfigs *psc; @@ -2211,103 +2082,11 @@ PUBLIC GLXFBConfigSGIX GLX_PREFIX(glXGetFBConfigFromVisualSGIX)(Display *dpy, } -/* -** GLX_SGI_cushion -*/ -PUBLIC void GLX_PREFIX(glXCushionSGI)(Display *dpy, Window win, float cushion) -{ - (void) dpy; - (void) win; - (void) cushion; -} - - -/* -** GLX_SGIX_video_resize -*/ -PUBLIC int GLX_PREFIX(glXBindChannelToWindowSGIX)(Display *dpy, int screen, - int channel , Window window) -{ - (void) dpy; - (void) screen; - (void) channel; - (void) window; - return 0; -} - -PUBLIC int GLX_PREFIX(glXChannelRectSGIX)(Display *dpy, int screen, int channel, - int x, int y, int w, int h) -{ - (void) dpy; - (void) screen; - (void) channel; - (void) x; - (void) y; - (void) w; - (void) h; - return 0; -} - -PUBLIC int GLX_PREFIX(glXQueryChannelRectSGIX)(Display *dpy, int screen, - int channel, int *x, int *y, - int *w, int *h) -{ - (void) dpy; - (void) screen; - (void) channel; - (void) x; - (void) y; - (void) w; - (void) h; - return 0; -} - -int GLX_PREFIX(glXQueryChannelDeltasSGIX)(Display *dpy, int screen, int channel, - int *dx, int *dy, int *dw, int *dh) -{ - (void) dpy; - (void) screen; - (void) channel; - (void) dx; - (void) dy; - (void) dw; - (void) dh; - return 0; -} - -PUBLIC int GLX_PREFIX(glXChannelRectSyncSGIX)(Display *dpy, int screen, - int channel, GLenum synctype) -{ - (void) dpy; - (void) screen; - (void) channel; - (void) synctype; - return 0; -} - - -#if defined(_DM_BUFFER_H_) - -PUBLIC Bool GLX_PREFIX(glXAssociateDMPbufferSGIX)(Display *dpy, - GLXPbufferSGIX pbuffer, - DMparams *params, - DMbuffer dmbuffer) -{ - (void) dpy; - (void) pbuffer; - (void) params; - (void) dmbuffer; - return False; -} - -#endif - - /* ** GLX_SGIX_swap_group */ -PUBLIC void GLX_PREFIX(glXJoinSwapGroupSGIX)(Display *dpy, GLXDrawable drawable, - GLXDrawable member) +static void __glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, + GLXDrawable member) { (void) dpy; (void) drawable; @@ -2318,17 +2097,15 @@ PUBLIC void GLX_PREFIX(glXJoinSwapGroupSGIX)(Display *dpy, GLXDrawable drawable, /* ** GLX_SGIX_swap_barrier */ -PUBLIC void GLX_PREFIX(glXBindSwapBarrierSGIX)(Display *dpy, - GLXDrawable drawable, - int barrier) +static void __glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, + int barrier) { (void) dpy; (void) drawable; (void) barrier; } -PUBLIC Bool GLX_PREFIX(glXQueryMaxSwapBarriersSGIX)(Display *dpy, int screen, - int *max) +static Bool __glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) { (void) dpy; (void) screen; @@ -2337,42 +2114,25 @@ PUBLIC Bool GLX_PREFIX(glXQueryMaxSwapBarriersSGIX)(Display *dpy, int screen, } -/* -** GLX_SUN_get_transparent_index -*/ -PUBLIC Status GLX_PREFIX(glXGetTransparentIndexSUN)(Display *dpy, - Window overlay, - Window underlay, - long *pTransparent) -{ - (void) dpy; - (void) overlay; - (void) underlay; - (void) pTransparent; - return 0; -} - - /* ** GLX_OML_sync_control */ -PUBLIC Bool GLX_PREFIX(glXGetSyncValuesOML)(Display *dpy, GLXDrawable drawable, - int64_t *ust, int64_t *msc, int64_t *sbc) +static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, + int64_t *ust, int64_t *msc, int64_t *sbc) { -#ifdef GLX_DIRECT_RENDERING +#if defined(__DRI_SWAP_BUFFER_COUNTER) && defined(__DRI_MEDIA_STREAM_COUNTER) __GLXdisplayPrivate * const priv = __glXInitialize(dpy); if ( priv != NULL ) { int i; - __DRIdrawable * const pdraw = GetDRIDrawable( dpy, drawable, & i ); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &i); __GLXscreenConfigs * const psc = &priv->screenConfigs[i]; assert( (pdraw == NULL) || (i != -1) ); - return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) - && ((*psc->driScreen.getMSC)( psc->driScreen.private, msc ) == 0) - && ((*pdraw->getSBC)( dpy, psc->driScreen.private, sbc ) == 0) - && (__glXGetUST( ust ) == 0) ); + return ( (pdraw && psc->sbc && psc->msc) + && ((*psc->msc->getMSC)(psc->driScreen, msc) == 0) + && ((*psc->sbc->getSBC)(pdraw->driDrawable, sbc) == 0) + && (__glXGetUST(ust) == 0) ); } #else (void) dpy; @@ -2384,6 +2144,68 @@ PUBLIC Bool GLX_PREFIX(glXGetSyncValuesOML)(Display *dpy, GLXDrawable drawable, return False; } +#ifdef GLX_DIRECT_RENDERING +_X_HIDDEN GLboolean +__driGetMscRateOML(__DRIdrawable *draw, + int32_t *numerator, int32_t *denominator, void *private) +{ +#ifdef XF86VIDMODE + __GLXscreenConfigs *psc; + XF86VidModeModeLine mode_line; + int dot_clock; + int i; + __GLXDRIdrawable *glxDraw = private; + + psc = glxDraw->psc; + if (XF86VidModeQueryVersion(psc->dpy, &i, &i) && + XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line) ) { + unsigned n = dot_clock * 1000; + unsigned d = mode_line.vtotal * mode_line.htotal; + +# define V_INTERLACE 0x010 +# define V_DBLSCAN 0x020 + + if (mode_line.flags & V_INTERLACE) + n *= 2; + else if (mode_line.flags & V_DBLSCAN) + d *= 2; + + /* The OML_sync_control spec requires that if the refresh rate is a + * whole number, that the returned numerator be equal to the refresh + * rate and the denominator be 1. + */ + + if (n % d == 0) { + n /= d; + d = 1; + } + else { + static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; + + /* This is a poor man's way to reduce a fraction. It's far from + * perfect, but it will work well enough for this situation. + */ + + for (i = 0; f[i] != 0; i++) { + while (n % f[i] == 0 && d % f[i] == 0) { + d /= f[i]; + n /= f[i]; + } + } + } + + *numerator = n; + *denominator = d; + + return True; + } + else + return False; +#else + return False; +#endif +} +#endif /** * Determine the refresh rate of the specified drawable and display. @@ -2401,70 +2223,17 @@ PUBLIC Bool GLX_PREFIX(glXGetSyncValuesOML)(Display *dpy, GLXDrawable drawable, * when GLX_OML_sync_control appears in the client extension string. */ -PUBLIC Bool GLX_PREFIX(glXGetMscRateOML)(Display * dpy, GLXDrawable drawable, - int32_t * numerator, int32_t * denominator) +_X_HIDDEN GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, + int32_t * numerator, + int32_t * denominator) { #if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) - __GLXdisplayPrivate * const priv = __glXInitialize(dpy); - + __GLXDRIdrawable *draw = GetGLXDRIDrawable(dpy, drawable, NULL); - if ( priv != NULL ) { - XF86VidModeModeLine mode_line; - int dot_clock; - int screen_num; - int i; - - - GetDRIDrawable( dpy, drawable, & screen_num ); - if ( (screen_num != -1) - && XF86VidModeQueryVersion( dpy, & i, & i ) - && XF86VidModeGetModeLine( dpy, screen_num, & dot_clock, - & mode_line ) ) { - unsigned n = dot_clock * 1000; - unsigned d = mode_line.vtotal * mode_line.htotal; - -# define V_INTERLACE 0x010 -# define V_DBLSCAN 0x020 - - if ( (mode_line.flags & V_INTERLACE) ) { - n *= 2; - } - else if ( (mode_line.flags & V_DBLSCAN) ) { - d *= 2; - } - - /* The OML_sync_control spec requires that if the refresh rate is a - * whole number, that the returned numerator be equal to the refresh - * rate and the denominator be 1. - */ - - if ( (n % d) == 0 ) { - n /= d; - d = 1; - } - else { - static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; - - - /* This is a poor man's way to reduce a fraction. It's far from - * perfect, but it will work well enough for this situation. - */ - - for ( i = 0 ; f[i] != 0 ; i++ ) { - while ( ((n % f[i]) == 0) && ((d % f[i]) == 0) ) { - d /= f[i]; - n /= f[i]; - } - } - } - - *numerator = n; - *denominator = d; + if (draw == NULL) + return False; - (void) drawable; - return True; - } - } + return __driGetMscRateOML(draw->driDrawable, numerator, denominator, draw); #else (void) dpy; (void) drawable; @@ -2475,15 +2244,13 @@ PUBLIC Bool GLX_PREFIX(glXGetMscRateOML)(Display * dpy, GLXDrawable drawable, } -PUBLIC int64_t GLX_PREFIX(glXSwapBuffersMscOML)(Display *dpy, - GLXDrawable drawable, - int64_t target_msc, - int64_t divisor, - int64_t remainder) +static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable, + int64_t target_msc, int64_t divisor, + int64_t remainder) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_BUFFER_COUNTER int screen; - __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE @@ -2496,11 +2263,10 @@ PUBLIC int64_t GLX_PREFIX(glXSwapBuffersMscOML)(Display *dpy, if ( divisor > 0 && remainder >= divisor ) return -1; - if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - return (*pdraw->swapBuffersMSC)(dpy, pdraw->private, target_msc, - divisor, remainder); - } + if (pdraw != NULL && psc->counters != NULL) + return (*psc->sbc->swapBuffersMSC)(pdraw->driDrawable, target_msc, + divisor, remainder); + #else (void) dpy; (void) drawable; @@ -2512,14 +2278,14 @@ PUBLIC int64_t GLX_PREFIX(glXSwapBuffersMscOML)(Display *dpy, } -PUBLIC Bool GLX_PREFIX(glXWaitForMscOML)(Display * dpy, GLXDrawable drawable, - int64_t target_msc, int64_t divisor, - int64_t remainder, int64_t *ust, - int64_t *msc, int64_t *sbc) +static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable, + int64_t target_msc, int64_t divisor, + int64_t remainder, int64_t *ust, + int64_t *msc, int64_t *sbc) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_MEDIA_STREAM_COUNTER int screen; - __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); int ret; @@ -2531,10 +2297,9 @@ PUBLIC Bool GLX_PREFIX(glXWaitForMscOML)(Display * dpy, GLXDrawable drawable, if ( divisor > 0 && remainder >= divisor ) return False; - if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) { - ret = (*pdraw->waitForMSC)( dpy, pdraw->private, target_msc, - divisor, remainder, msc, sbc ); + if (pdraw != NULL && psc->msc != NULL) { + ret = (*psc->msc->waitForMSC)(pdraw->driDrawable, target_msc, + divisor, remainder, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. @@ -2555,13 +2320,13 @@ PUBLIC Bool GLX_PREFIX(glXWaitForMscOML)(Display * dpy, GLXDrawable drawable, } -PUBLIC Bool GLX_PREFIX(glXWaitForSbcOML)(Display * dpy, GLXDrawable drawable, - int64_t target_sbc, int64_t *ust, - int64_t *msc, int64_t *sbc ) +static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable, + int64_t target_sbc, int64_t *ust, + int64_t *msc, int64_t *sbc ) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_SWAP_BUFFER_COUNTER int screen; - __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen ); + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); int ret; @@ -2571,9 +2336,8 @@ PUBLIC Bool GLX_PREFIX(glXWaitForSbcOML)(Display * dpy, GLXDrawable drawable, if ( target_sbc < 0 ) return False; - if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL) - && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) { - ret = (*pdraw->waitForSBC)( dpy, pdraw->private, target_sbc, msc, sbc ); + if (pdraw != NULL && psc->sbc != NULL) { + ret = (*psc->sbc->waitForSBC)(pdraw->driDrawable, target_sbc, msc, sbc); /* __glXGetUST returns zero on success and non-zero on failure. * This function returns True on success and False on failure. @@ -2597,20 +2361,17 @@ PUBLIC Bool GLX_PREFIX(glXWaitForSbcOML)(Display * dpy, GLXDrawable drawable, */ /*@{*/ -PUBLIC void *GLX_PREFIX(glXAllocateMemoryMESA)(Display *dpy, int scrn, - size_t size, float readFreq, - float writeFreq, float priority) +PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn, + size_t size, float readFreq, + float writeFreq, float priority) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_ALLOCATE __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn ); - if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) { - if (psc && psc->driScreen.private && psc->driScreen.allocateMemory) { - return (*psc->driScreen.allocateMemory)( dpy, scrn, size, - readFreq, writeFreq, - priority ); - } - } + if (psc && psc->allocate) + return (*psc->allocate->allocateMemory)(psc->__driScreen, size, + readFreq, writeFreq, priority); + #else (void) dpy; (void) scrn; @@ -2624,16 +2385,14 @@ PUBLIC void *GLX_PREFIX(glXAllocateMemoryMESA)(Display *dpy, int scrn, } -PUBLIC void GLX_PREFIX(glXFreeMemoryMESA)(Display *dpy, int scrn, void *pointer) +PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_ALLOCATE __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn ); - if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) { - if (psc && psc->driScreen.private && psc->driScreen.freeMemory) { - (*psc->driScreen.freeMemory)( dpy, scrn, pointer ); - } - } + if (psc && psc->allocate) + (*psc->allocate->freeMemory)(psc->__driScreen, pointer); + #else (void) dpy; (void) scrn; @@ -2642,17 +2401,15 @@ PUBLIC void GLX_PREFIX(glXFreeMemoryMESA)(Display *dpy, int scrn, void *pointer) } -PUBLIC GLuint GLX_PREFIX(glXGetMemoryOffsetMESA)( Display *dpy, int scrn, - const void *pointer ) +PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn, + const void *pointer ) { -#ifdef GLX_DIRECT_RENDERING +#ifdef __DRI_ALLOCATE __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn ); - if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) { - if (psc && psc->driScreen.private && psc->driScreen.memoryOffset) { - return (*psc->driScreen.memoryOffset)( dpy, scrn, pointer ); - } - } + if (psc && psc->allocate) + return (*psc->allocate->memoryOffset)(psc->__driScreen, pointer); + #else (void) dpy; (void) scrn; @@ -2691,7 +2448,7 @@ PUBLIC GLuint GLX_PREFIX(glXGetMemoryOffsetMESA)( Display *dpy, int scrn, * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX */ -PUBLIC Bool GLX_PREFIX(glXReleaseBuffersMESA)( Display *dpy, GLXDrawable d ) +static Bool __glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) { (void) dpy; (void) d; @@ -2699,10 +2456,8 @@ PUBLIC Bool GLX_PREFIX(glXReleaseBuffersMESA)( Display *dpy, GLXDrawable d ) } -PUBLIC GLXPixmap GLX_PREFIX(glXCreateGLXPixmapMESA)( Display *dpy, - XVisualInfo *visual, - Pixmap pixmap, - Colormap cmap ) +PUBLIC GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual, + Pixmap pixmap, Colormap cmap ) { (void) dpy; (void) visual; @@ -2710,29 +2465,191 @@ PUBLIC GLXPixmap GLX_PREFIX(glXCreateGLXPixmapMESA)( Display *dpy, (void) cmap; return 0; } +/*@}*/ -PUBLIC void GLX_PREFIX(glXCopySubBufferMESA)(Display *dpy, GLXDrawable drawable, - int x, int y, - int width, int height) +/** + * GLX_MESA_copy_sub_buffer + */ +#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */ +static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, + int x, int y, int width, int height) { - (void) dpy; - (void) drawable; - (void) x; - (void) y; - (void) width; - (void) height; + xGLXVendorPrivateReq *req; + GLXContext gc; + GLXContextTag tag; + CARD32 *drawable_ptr; + INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr; + CARD8 opcode; + +#ifdef __DRI_COPY_SUB_BUFFER + int screen; + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); + if ( pdraw != NULL ) { + __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen ); + if (psc->copySubBuffer != NULL) { + (*psc->copySubBuffer->copySubBuffer)(pdraw->driDrawable, + x, y, width, height); + } + + return; + } +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + /* + ** The calling thread may or may not have a current context. If it + ** does, send the context tag so the server can do a flush. + */ + gc = __glXGetCurrentContext(); + if ((gc != NULL) && (dpy == gc->currentDpy) && + ((drawable == gc->currentDrawable) || + (drawable == gc->currentReadable)) ) { + tag = gc->currentContextTag; + } else { + tag = 0; + } + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4,req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_CopySubBufferMESA; + req->contextTag = tag; + + drawable_ptr = (CARD32 *) (req + 1); + x_ptr = (INT32 *) (drawable_ptr + 1); + y_ptr = (INT32 *) (drawable_ptr + 2); + w_ptr = (INT32 *) (drawable_ptr + 3); + h_ptr = (INT32 *) (drawable_ptr + 4); + + *drawable_ptr = drawable; + *x_ptr = x; + *y_ptr = y; + *w_ptr = width; + *h_ptr = height; + + UnlockDisplay(dpy); + SyncHandle(); } -PUBLIC Bool GLX_PREFIX(glXSet3DfxModeMESA)( int mode ) +/** + * GLX_EXT_texture_from_pixmap + */ +/*@{*/ +static void __glXBindTexImageEXT(Display *dpy, + GLXDrawable drawable, + int buffer, + const int *attrib_list) { - (void) mode; - return GL_FALSE; + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD32 *num_attrib_ptr; + CARD32 *attrib_ptr; + CARD8 opcode; + unsigned int i; + + if (gc == NULL) + return; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2] != None) + i++; + } + +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) { + __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); + + if (pdraw != NULL) + (*pdraw->psc->texBuffer->setTexBuffer)(gc->__driContext, + pdraw->textureTarget, + pdraw->driDrawable); + + return; + } +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, 12 + 8 * i,req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_BindTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + num_attrib_ptr = (CARD32 *) (buffer_ptr + 1); + attrib_ptr = (CARD32 *) (num_attrib_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + *num_attrib_ptr = (CARD32) i; + + i = 0; + if (attrib_list) { + while (attrib_list[i * 2] != None) + { + *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 0]; + *attrib_ptr++ = (CARD32) attrib_list[i * 2 + 1]; + i++; + } + } + + UnlockDisplay(dpy); + SyncHandle(); } -/*@}*/ +static void __glXReleaseTexImageEXT(Display *dpy, + GLXDrawable drawable, + int buffer) +{ + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD8 opcode; + + if (gc == NULL) + return; +#ifdef GLX_DIRECT_RENDERING + if (gc->driContext) + return; +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32)+sizeof(INT32),req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_ReleaseTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + + UnlockDisplay(dpy); + SyncHandle(); +} +/*@}*/ /** * \c strdup is actually not a standard ANSI C or POSIX routine. @@ -2740,7 +2657,7 @@ PUBLIC Bool GLX_PREFIX(glXSet3DfxModeMESA)( int mode ) * * \sa strdup */ -char * +_X_HIDDEN char * __glXstrdup(const char *str) { char *copy; @@ -2811,22 +2728,16 @@ static const struct name_address_pair GLX_functions[] = { GLX_FUNCTION( glXSelectEvent ), /*** GLX_SGI_swap_control ***/ - GLX_FUNCTION( glXSwapIntervalSGI ), + GLX_FUNCTION2( glXSwapIntervalSGI, __glXSwapIntervalSGI ), /*** GLX_SGI_video_sync ***/ - GLX_FUNCTION( glXGetVideoSyncSGI ), - GLX_FUNCTION( glXWaitVideoSyncSGI ), + GLX_FUNCTION2( glXGetVideoSyncSGI, __glXGetVideoSyncSGI ), + GLX_FUNCTION2( glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI ), /*** GLX_SGI_make_current_read ***/ GLX_FUNCTION2( glXMakeCurrentReadSGI, glXMakeContextCurrent ), GLX_FUNCTION2( glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable ), - /*** GLX_SGIX_video_source ***/ -#if defined(_VL_H) - GLX_FUNCTION( glXCreateGLXVideoSourceSGIX ), - GLX_FUNCTION( glXDestroyGLXVideoSourceSGIX ), -#endif - /*** GLX_EXT_import_context ***/ GLX_FUNCTION( glXFreeContextEXT ), GLX_FUNCTION( glXGetContextIDEXT ), @@ -2849,30 +2760,12 @@ static const struct name_address_pair GLX_functions[] = { GLX_FUNCTION( glXSelectEventSGIX ), GLX_FUNCTION( glXGetSelectedEventSGIX ), - /*** GLX_SGI_cushion ***/ - GLX_FUNCTION( glXCushionSGI ), - - /*** GLX_SGIX_video_resize ***/ - GLX_FUNCTION( glXBindChannelToWindowSGIX ), - GLX_FUNCTION( glXChannelRectSGIX ), - GLX_FUNCTION( glXQueryChannelRectSGIX ), - GLX_FUNCTION( glXQueryChannelDeltasSGIX ), - GLX_FUNCTION( glXChannelRectSyncSGIX ), - - /*** GLX_SGIX_dmbuffer **/ -#if defined(_DM_BUFFER_H_) - GLX_FUNCTION( glXAssociateDMPbufferSGIX ), -#endif - /*** GLX_SGIX_swap_group ***/ - GLX_FUNCTION( glXJoinSwapGroupSGIX ), + GLX_FUNCTION2( glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX ), /*** GLX_SGIX_swap_barrier ***/ - GLX_FUNCTION( glXBindSwapBarrierSGIX ), - GLX_FUNCTION( glXQueryMaxSwapBarriersSGIX ), - - /*** GLX_SUN_get_transparent_index ***/ - GLX_FUNCTION( glXGetTransparentIndexSUN ), + GLX_FUNCTION2( glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX ), + GLX_FUNCTION2( glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX ), /*** GLX_MESA_allocate_memory ***/ GLX_FUNCTION( glXAllocateMemoryMESA ), @@ -2880,26 +2773,23 @@ static const struct name_address_pair GLX_functions[] = { GLX_FUNCTION( glXGetMemoryOffsetMESA ), /*** GLX_MESA_copy_sub_buffer ***/ - GLX_FUNCTION( glXCopySubBufferMESA ), + GLX_FUNCTION2( glXCopySubBufferMESA, __glXCopySubBufferMESA ), /*** GLX_MESA_pixmap_colormap ***/ GLX_FUNCTION( glXCreateGLXPixmapMESA ), /*** GLX_MESA_release_buffers ***/ - GLX_FUNCTION( glXReleaseBuffersMESA ), - - /*** GLX_MESA_set_3dfx_mode ***/ - GLX_FUNCTION( glXSet3DfxModeMESA ), + GLX_FUNCTION2( glXReleaseBuffersMESA, __glXReleaseBuffersMESA ), /*** GLX_MESA_swap_control ***/ - GLX_FUNCTION( glXSwapIntervalMESA ), - GLX_FUNCTION( glXGetSwapIntervalMESA ), + GLX_FUNCTION2( glXSwapIntervalMESA, __glXSwapIntervalMESA ), + GLX_FUNCTION2( glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA ), /*** GLX_MESA_swap_frame_usage ***/ - GLX_FUNCTION( glXBeginFrameTrackingMESA ), - GLX_FUNCTION( glXEndFrameTrackingMESA ), - GLX_FUNCTION( glXGetFrameUsageMESA ), - GLX_FUNCTION( glXQueryFrameTrackingMESA ), + GLX_FUNCTION2( glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA ), + GLX_FUNCTION2( glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA ), + GLX_FUNCTION2( glXGetFrameUsageMESA, __glXGetFrameUsageMESA ), + GLX_FUNCTION2( glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA ), /*** GLX_ARB_get_proc_address ***/ GLX_FUNCTION( glXGetProcAddressARB ), @@ -2908,35 +2798,20 @@ static const struct name_address_pair GLX_functions[] = { GLX_FUNCTION2( glXGetProcAddress, glXGetProcAddressARB ), /*** GLX_OML_sync_control ***/ - GLX_FUNCTION( glXWaitForSbcOML ), - GLX_FUNCTION( glXWaitForMscOML ), - GLX_FUNCTION( glXSwapBuffersMscOML ), - GLX_FUNCTION( glXGetMscRateOML ), - GLX_FUNCTION( glXGetSyncValuesOML ), + GLX_FUNCTION2( glXWaitForSbcOML, __glXWaitForSbcOML ), + GLX_FUNCTION2( glXWaitForMscOML, __glXWaitForMscOML ), + GLX_FUNCTION2( glXSwapBuffersMscOML, __glXSwapBuffersMscOML ), + GLX_FUNCTION2( glXGetMscRateOML, __glXGetMscRateOML ), + GLX_FUNCTION2( glXGetSyncValuesOML, __glXGetSyncValuesOML ), -#ifdef GLX_DIRECT_RENDERING - /*** - *** Internal functions useful to DRI drivers - *** With this, the DRI drivers shouldn't need dlopen()/dlsym() to - *** access internal libGL functions which may or may not exist. - ***/ - GLX_FUNCTION( __glXInitialize ), - GLX_FUNCTION( __glXFindDRIScreen ), - GLX_FUNCTION( __glXGetInternalVersion ), - GLX_FUNCTION( __glXWindowExists ), - GLX_FUNCTION2( __glXCreateContextWithConfig, XF86DRICreateContextWithConfig ), - GLX_FUNCTION2( __glXGetDrawableInfo, XF86DRIGetDrawableInfo ), + /*** GLX_EXT_texture_from_pixmap ***/ + GLX_FUNCTION2( glXBindTexImageEXT, __glXBindTexImageEXT ), + GLX_FUNCTION2( glXReleaseTexImageEXT, __glXReleaseTexImageEXT ), +#ifdef GLX_DIRECT_RENDERING /*** DRI configuration ***/ GLX_FUNCTION( glXGetScreenDriver ), GLX_FUNCTION( glXGetDriverConfig ), - - GLX_FUNCTION( __glXScrEnableExtension ), - - GLX_FUNCTION( __glXGetUST ), - - GLX_FUNCTION2( __glXCreateContextModes, _gl_context_modes_create ), - GLX_FUNCTION2( __glXDestroyContextModes, _gl_context_modes_destroy ), #endif { NULL, NULL } /* end of list */ @@ -2958,7 +2833,6 @@ get_glx_proc_address(const char *funcName) } -#ifndef GLX_BUILT_IN_XMESA /** * Get the address of a named GL function. This is the pre-GLX 1.4 name for * \c glXGetProcAddress. @@ -3007,98 +2881,9 @@ PUBLIC void (*glXGetProcAddress(const GLubyte *procName))( void ) return glXGetProcAddressARB(procName); } #endif /* __GNUC__ */ -#endif /* GLX_BUILT_IN_XMESA */ #ifdef GLX_DIRECT_RENDERING -/** - * Retrieves the verion of the internal libGL API in YYYYMMDD format. This - * might be used by the DRI drivers to determine how new libGL is at runtime. - * Drivers should not call this function directly. They should instead use - * \c glXGetProcAddress to obtain a pointer to the function. - * - * \returns An 8-digit decimal number representing the internal libGL API in - * YYYYMMDD format. - * - * \sa glXGetProcAddress, PFNGLXGETINTERNALVERSIONPROC - * - * \since Internal API version 20021121. - */ -int __glXGetInternalVersion(void) -{ - /* History: - * 20021121 - Initial version - * 20021128 - Added __glXWindowExists() function - * 20021207 - Added support for dynamic GLX extensions, - * GLX_SGI_swap_control, GLX_SGI_video_sync, - * GLX_OML_sync_control, and GLX_MESA_swap_control. - * Never officially released. Do NOT test against - * this version. Use 20030317 instead. - * 20030317 - Added support GLX_SGIX_fbconfig, - * GLX_MESA_swap_frame_usage, GLX_OML_swap_method, - * GLX_{ARB,SGIS}_multisample, and - * GLX_SGIX_visual_select_group. - * 20030606 - Added support for GLX_SGI_make_current_read. - * 20030813 - Made support for dynamic extensions multi-head aware. - * 20030818 - Added support for GLX_MESA_allocate_memory in place of the - * deprecated GLX_NV_vertex_array_range & GLX_MESA_agp_offset - * interfaces. - * 20031201 - Added support for the first round of DRI interface changes. - * Do NOT test against this version! It has binary - * compatibility bugs, use 20040317 instead. - * 20040317 - Added the 'mode' field to __DRIcontextRec. - * 20040415 - Added support for bindContext3 and unbindContext3. - * 20040602 - Add __glXGetDrawableInfo. I though that was there - * months ago. :( - */ - return 20040602; -} - - - -static Bool windowExistsFlag; - -static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr) -{ - if (xerr->error_code == BadWindow) { - windowExistsFlag = GL_FALSE; - } - return 0; -} - -/** - * Determine if a window associated with a \c GLXDrawable exists on the - * X-server. This function is not used internally by libGL. It is provided - * as a utility function for DRI drivers. - * Drivers should not call this function directly. They should instead use - * \c glXGetProcAddress to obtain a pointer to the function. - * - * \param dpy Display associated with the drawable to be queried. - * \param draw \c GLXDrawable to test. - * - * \returns \c GL_TRUE if a window exists that is associated with \c draw, - * otherwise \c GL_FALSE is returned. - * - * \warning This function is not currently thread-safe. - * - * \sa glXGetProcAddress - * - * \since Internal API version 20021128. - */ -static Bool __glXWindowExists(Display *dpy, GLXDrawable draw) -{ - XWindowAttributes xwa; - int (*oldXErrorHandler)(Display *, XErrorEvent *); - - XSync(dpy, GL_FALSE); - windowExistsFlag = GL_TRUE; - oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler); - XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */ - XSetErrorHandler(oldXErrorHandler); - return windowExistsFlag; -} - - /** * Get the unadjusted system time (UST). Currently, the UST is measured in * microseconds since Epoc. The actual resolution of the UST may vary from @@ -3113,7 +2898,7 @@ static Bool __glXWindowExists(Display *dpy, GLXDrawable draw) * * \since Internal API version 20030317. */ -int __glXGetUST( int64_t * ust ) +_X_HIDDEN int __glXGetUST( int64_t * ust ) { struct timeval tv;