From eea8efe4516750b2505b52ebc9f769f5e8a6f94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 28 Jun 2006 15:59:01 -0400 Subject: [PATCH 1/6] Add marshalling for GLX 1.3 requests. Also, hook up glXGetDrawableAttributes and glXQueryContext to existing DoGetDrawableAttributes and __glXQueryContextInfoEXT. --- GL/glx/g_disptab.c | 44 ++++++++++---------- GL/glx/g_disptab.h | 23 +++++++++- GL/glx/glxcmds.c | 99 ++++++++++++++++++++++++++++++++++++++------ GL/glx/glxcmdsswap.c | 76 +++++++++++++++++++++++++++++++++- GL/glx/glxext.h | 3 ++ 5 files changed, 207 insertions(+), 38 deletions(-) diff --git a/GL/glx/g_disptab.c b/GL/glx/g_disptab.c index c41c45e9f..e97ace6ba 100644 --- a/GL/glx/g_disptab.c +++ b/GL/glx/g_disptab.c @@ -47,7 +47,7 @@ __GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE] = { __glXMakeCurrent, __glXIsDirect, __glXQueryVersion, - __glXWaitGL, + __glXWaitGL, /* 0x08 */ __glXWaitX, __glXCopyContext, __glXSwapBuffers, @@ -55,23 +55,23 @@ __GLXdispatchSingleProcPtr __glXSingleTable[__GLX_SINGLE_TABLE_SIZE] = { __glXCreateGLXPixmap, __glXGetVisualConfigs, __glXDestroyGLXPixmap, - __glXVendorPrivate, + __glXVendorPrivate, /* 0x10 */ __glXVendorPrivateWithReply, __glXQueryExtensionsString, __glXQueryServerString, __glXClientInfo, __glXGetFBConfigs, __glXCreatePixmap, - __glXDestroyGLXPixmap, /* glXDestroyPixmap */ - __glXCreateNewContext, - __glXNoSuchSingleOpcode, /* glXQueryContext */ + __glXDestroyPixmap, + __glXCreateNewContext, /* 0x18 */ + __glXQueryContext, __glXMakeContextCurrent, - __glXNoSuchSingleOpcode, /* glXCreatePbuffer */ - __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */ - __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */ - __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */ - __glXNoSuchSingleOpcode, /* glXCreateWindow */ - __glXNoSuchSingleOpcode, /* glXDestroyWindow */ + __glXCreatePbuffer, + __glXDestroyPbuffer, + __glXGetDrawableAttributes, + __glXChangeDrawableAttributes, + __glXCreateWindow, + __glXDestroyWindow, /* 0x20 */ __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, @@ -448,7 +448,7 @@ __GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE] = { __glXSwapMakeCurrent, __glXSwapIsDirect, __glXSwapQueryVersion, - __glXSwapWaitGL, + __glXSwapWaitGL, /* 0x08 */ __glXSwapWaitX, __glXSwapCopyContext, __glXSwapSwapBuffers, @@ -456,23 +456,23 @@ __GLXdispatchSingleProcPtr __glXSwapSingleTable[__GLX_SINGLE_TABLE_SIZE] = { __glXSwapCreateGLXPixmap, __glXSwapGetVisualConfigs, __glXSwapDestroyGLXPixmap, - __glXSwapVendorPrivate, + __glXSwapVendorPrivate, /* 0x10 */ __glXSwapVendorPrivateWithReply, __glXSwapQueryExtensionsString, __glXSwapQueryServerString, __glXSwapClientInfo, __glXSwapGetFBConfigs, __glXSwapCreatePixmap, - __glXSwapDestroyGLXPixmap, /* glXDestroyPixmap */ - __glXSwapCreateNewContext, - __glXNoSuchSingleOpcode, /* glXQueryContext */ + __glXSwapDestroyPixmap, + __glXSwapCreateNewContext, /* 0x18 */ + __glXSwapQueryContext, __glXSwapMakeContextCurrent, - __glXNoSuchSingleOpcode, /* glXCreatePbuffer */ - __glXNoSuchSingleOpcode, /* glXDestroyPbuffer */ - __glXNoSuchSingleOpcode, /* glXGetDrawableAttributes */ - __glXNoSuchSingleOpcode, /* glXChangeDrawableAttributes */ - __glXNoSuchSingleOpcode, /* glXCreateWindow */ - __glXNoSuchSingleOpcode, /* glXDestroyWindow */ + __glXSwapCreatePbuffer, + __glXSwapDestroyPbuffer, + __glXSwapGetDrawableAttributes, + __glXSwapChangeDrawableAttributes, + __glXSwapCreateWindow, + __glXSwapDestroyWindow, /* 0x20 */ __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, __glXNoSuchSingleOpcode, diff --git a/GL/glx/g_disptab.h b/GL/glx/g_disptab.h index 9ae901c1d..9be5bdf2c 100644 --- a/GL/glx/g_disptab.h +++ b/GL/glx/g_disptab.h @@ -60,8 +60,17 @@ extern int __glXQueryServerString(__GLXclientState*, GLbyte*); extern int __glXClientInfo(__GLXclientState*, GLbyte*); extern int __glXMakeContextCurrent(__GLXclientState*, GLbyte*); extern int __glXGetFBConfigs(__GLXclientState*, GLbyte*); -extern int __glXCreateNewContext(__GLXclientState*, GLbyte*); extern int __glXCreatePixmap(__GLXclientState*, GLbyte*); +extern int __glXDestroyPixmap(__GLXclientState*, GLbyte*); +extern int __glXCreateNewContext(__GLXclientState*, GLbyte*); +extern int __glXQueryContext(__GLXclientState*, GLbyte*); +extern int __glXMakeContextCurrent(__GLXclientState*, GLbyte*); +extern int __glXCreatePbuffer(__GLXclientState*, GLbyte*); +extern int __glXDestroyPbuffer(__GLXclientState*, GLbyte*); +extern int __glXGetDrawableAttributes(__GLXclientState*, GLbyte*); +extern int __glXChangeDrawableAttributes(__GLXclientState*, GLbyte*); +extern int __glXCreateWindow(__GLXclientState*, GLbyte*); +extern int __glXDestroyWindow(__GLXclientState*, GLbyte*); extern int __glXSwapRender(__GLXclientState*, GLbyte*); extern int __glXSwapRenderLarge(__GLXclientState*, GLbyte*); @@ -88,8 +97,18 @@ extern int __glXSwapQueryServerString(__GLXclientState*, GLbyte*); extern int __glXSwapClientInfo(__GLXclientState*, GLbyte*); extern int __glXSwapMakeContextCurrent(__GLXclientState*, GLbyte*); extern int __glXSwapGetFBConfigs(__GLXclientState*, GLbyte*); -extern int __glXSwapCreateNewContext(__GLXclientState*, GLbyte*); extern int __glXSwapCreatePixmap(__GLXclientState*, GLbyte*); +extern int __glXSwapDestroyPixmap(__GLXclientState*, GLbyte*); +extern int __glXSwapCreateNewContext(__GLXclientState*, GLbyte*); +extern int __glXSwapQueryContext(__GLXclientState*, GLbyte*); +extern int __glXSwapMakeContextCurrent(__GLXclientState*, GLbyte*); +extern int __glXSwapCreatePbuffer(__GLXclientState*, GLbyte*); +extern int __glXSwapDestroyPbuffer(__GLXclientState*, GLbyte*); +extern int __glXSwapGetDrawableAttributes(__GLXclientState*, GLbyte*); +extern int __glXSwapChangeDrawableAttributes(__GLXclientState*, GLbyte*); +extern int __glXSwapCreateWindow(__GLXclientState*, GLbyte*); +extern int __glXSwapDestroyWindow(__GLXclientState*, GLbyte*); + #define __GLX_MIN_GLXCMD_OPCODE 1 #define __GLX_MAX_GLXCMD_OPCODE 20 diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index 79fee207a..e2e157db8 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -1299,16 +1299,9 @@ int __glXCreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc) } -/** - * Destroy a GLX pixmap. This function is used for both - * \c glXDestroyGLXPixmap and \c glXDestroyPixmap. - */ - -int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) +int DoDestroyPixmap(__GLXclientState *cl, XID glxpixmap) { ClientPtr client = cl->client; - xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; - XID glxpixmap = req->glxpixmap; /* ** Check if it's a valid GLX pixmap. @@ -1318,9 +1311,71 @@ int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) return __glXBadPixmap; } FreeResource(glxpixmap, FALSE); + return Success; } +int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; + + return DoDestroyPixmap(cl, req->glxpixmap); +} + +int __glXDestroyPixmap(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc; + + return DoDestroyPixmap(cl, req->glxpixmap); +} + +int __glXCreatePbuffer(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXDestroyPbuffer(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) +{ + xGLXChangeDrawableAttributesReq *req = + (xGLXChangeDrawableAttributesReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; + + (void) req; + + return BadRequest; +} + + /*****************************************************************************/ /* @@ -1419,20 +1474,18 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) } -int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) +int DoQueryContext(__GLXclientState *cl, GLXContextID gcId) { ClientPtr client = cl->client; __GLXcontext *ctx; - xGLXQueryContextInfoEXTReq *req; xGLXQueryContextInfoEXTReply reply; int nProps; int *sendBuf, *pSendBuf; int nReplyBytes; - req = (xGLXQueryContextInfoEXTReq *)pc; - ctx = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes); + ctx = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes); if (!ctx) { - client->errorValue = req->context; + client->errorValue = gcId; return __glXBadContext; } @@ -1466,6 +1519,19 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) return Success; } +int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc) +{ + xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc; + + return DoQueryContext(cl, req->context); +} + +int __glXQueryContext(__GLXclientState *cl, GLbyte *pc) +{ + xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; + + return DoQueryContext(cl, req->context); +} int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc) { @@ -1589,6 +1655,13 @@ int __glXGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) return DoGetDrawableAttributes(cl, drawable); } +int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; + + return DoGetDrawableAttributes(cl, req->drawable); +} + /************************************************************************/ /* diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c index 0f8b67496..3464e135a 100644 --- a/GL/glx/glxcmdsswap.c +++ b/GL/glx/glxcmdsswap.c @@ -315,6 +315,68 @@ int __glXSwapDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc) return __glXDestroyGLXPixmap(cl, pc); } +int __glXSwapDestroyPixmap(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->glxpixmap); + + return __glXDestroyGLXPixmap(cl, pc); +} + +int __glXSwapQueryContext(__GLXclientState *cl, GLbyte *pc) +{ + xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXSwapCreatePbuffer(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXSwapDestroyPbuffer(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) req; + + return BadRequest; +} + +int __glXSwapChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) +{ + xGLXChangeDrawableAttributesReq *req = + (xGLXChangeDrawableAttributesReq *) req; + + return BadRequest; +} + +int __glXSwapCreateWindow(__GLXclientState *cl, GLbyte *pc) +{ + xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; + + (void) req; + + return BadRequest; +} + +int __glXSwapDestroyWindow(__GLXclientState *cl, GLbyte *pc) +{ + xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; + + (void) req; + + return BadRequest; +} + int __glXSwapSwapBuffers(__GLXclientState *cl, GLbyte *pc) { xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; @@ -444,7 +506,19 @@ int __glXSwapGetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc) __GLX_SWAP_INT(&req->contextTag); __GLX_SWAP_INT(data); - return __glXGetDrawableAttributesSGIX(cl, (GLbyte *)pc); + return __glXGetDrawableAttributesSGIX(cl, pc); +} + +int __glXSwapGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc) +{ + xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc; + + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_SHORT(&req->length); + __GLX_SWAP_INT(&req->drawable); + + return __glXGetDrawableAttributes(cl, pc); } diff --git a/GL/glx/glxext.h b/GL/glx/glxext.h index 5d569899f..34d361217 100644 --- a/GL/glx/glxext.h +++ b/GL/glx/glxext.h @@ -87,6 +87,9 @@ extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect); extern int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, GLuint screenNum, XID pixmapId, XID glxpixmapId); +extern int DoDestroyPixmap(__GLXclientState *cl, XID glxpixmapId); + +extern int DoQueryContext(__GLXclientState *cl, GLXContextID gcId); extern void GlxExtensionInit(void); From 7cf3ec7b59223f15314a0629f122ecb796678421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 28 Jun 2006 17:00:23 -0400 Subject: [PATCH 2/6] Move createDrawable from __GLXcontext to __GLXscreen. --- GL/glx/glxcontext.h | 6 +-- GL/glx/glxdri.c | 91 +++++++++++++++++++++++---------------------- GL/glx/glxscreens.h | 13 +++++-- GL/glx/glxutil.c | 24 +++++++++++- GL/glx/glxutil.h | 12 +++--- GL/mesa/X/xf86glx.c | 39 +++++++------------ 6 files changed, 99 insertions(+), 86 deletions(-) diff --git a/GL/glx/glxcontext.h b/GL/glx/glxcontext.h index d57745a25..68e26609d 100644 --- a/GL/glx/glxcontext.h +++ b/GL/glx/glxcontext.h @@ -58,7 +58,7 @@ struct __GLXtextureFromPixmap { struct __GLXcontext { - void (*destroy) (__GLXcontext *context); + void (*destroy) (__GLXcontext *context); int (*makeCurrent) (__GLXcontext *context); int (*loseCurrent) (__GLXcontext *context); int (*copy) (__GLXcontext *dst, @@ -66,10 +66,6 @@ struct __GLXcontext { unsigned long mask); int (*forceCurrent) (__GLXcontext *context); - __GLXdrawable *(*createDrawable)(__GLXcontext *context, - DrawablePtr pDraw, - XID drawId); - __GLXtextureFromPixmap *textureFromPixmap; /* diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c index c0339050f..423922966 100644 --- a/GL/glx/glxdri.c +++ b/GL/glx/glxdri.c @@ -177,48 +177,6 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *basePrivate) return TRUE; } -static __GLXdrawable * -__glXDRIcontextCreateDrawable(__GLXcontext *context, - DrawablePtr pDraw, - XID drawId) -{ - __GLXDRIdrawable *private; - - private = xalloc(sizeof *private); - if (private == NULL) - return NULL; - - memset(private, 0, sizeof *private); - - if (!__glXDrawableInit(&private->base, context, pDraw, drawId)) { - xfree(private); - return NULL; - } - - private->base.destroy = __glXDRIdrawableDestroy; - private->base.resize = __glXDRIdrawableResize; - private->base.swapBuffers = __glXDRIdrawableSwapBuffers; - -#if 0 - /* FIXME: It would only be natural that we called - * driScreen->createNewDrawable here but the DRI drivers manage - * them a little oddly. FIXME: describe this better.*/ - - /* The last argument is 'attrs', which is used with pbuffers which - * we currently don't support. */ - - glxPriv->driDrawable.private = - (pGlxScreen->driScreen.createNewDrawable)(NULL, modes, - drawId, - &glxPriv->driDrawable, - 0, - NULL); -#endif - - return &private->base; -} - - static void __glXDRIcontextDestroy(__GLXcontext *baseContext) { @@ -483,7 +441,6 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, context->base.loseCurrent = __glXDRIcontextLoseCurrent; context->base.copy = __glXDRIcontextCopy; context->base.forceCurrent = __glXDRIcontextForceCurrent; - context->base.createDrawable = __glXDRIcontextCreateDrawable; context->base.textureFromPixmap = &__glXDRItextureFromPixmap; @@ -498,6 +455,49 @@ __glXDRIscreenCreateContext(__GLXscreen *baseScreen, return &context->base; } +static __GLXdrawable * +__glXDRIscreenCreateDrawable(__GLXscreen *screen, + DrawablePtr pDraw, + XID drawId, + __GLcontextModes *modes) +{ + __GLXDRIdrawable *private; + + private = xalloc(sizeof *private); + if (private == NULL) + return NULL; + + memset(private, 0, sizeof *private); + + if (!__glXDrawableInit(&private->base, screen, pDraw, drawId, modes)) { + xfree(private); + return NULL; + } + + private->base.destroy = __glXDRIdrawableDestroy; + private->base.resize = __glXDRIdrawableResize; + private->base.swapBuffers = __glXDRIdrawableSwapBuffers; + +#if 0 + /* FIXME: It would only be natural that we called + * driScreen->createNewDrawable here but the DRI drivers manage + * them a little oddly. FIXME: describe this better.*/ + + /* The last argument is 'attrs', which is used with pbuffers which + * we currently don't support. */ + + glxPriv->driDrawable.private = + (screen->driScreen.createNewDrawable)(NULL, modes, + drawId, + &glxPriv->driDrawable, + 0, + NULL); +#endif + + return &private->base; +} + + static unsigned filter_modes(__GLcontextModes **server_modes, const __GLcontextModes *driver_modes) @@ -798,8 +798,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen) return NULL; memset(screen, 0, sizeof *screen); - screen->base.destroy = __glXDRIscreenDestroy; - screen->base.createContext = __glXDRIscreenCreateContext; + screen->base.destroy = __glXDRIscreenDestroy; + screen->base.createContext = __glXDRIscreenCreateContext; + screen->base.createDrawable = __glXDRIscreenCreateDrawable; screen->base.pScreen = pScreen; /* DRI protocol version. */ diff --git a/GL/glx/glxscreens.h b/GL/glx/glxscreens.h index 8a2b2388f..96373dbee 100644 --- a/GL/glx/glxscreens.h +++ b/GL/glx/glxscreens.h @@ -53,11 +53,16 @@ */ typedef struct __GLXscreen __GLXscreen; struct __GLXscreen { - void (*destroy)(__GLXscreen *screen); + void (*destroy) (__GLXscreen *screen); - __GLXcontext *(*createContext)(__GLXscreen *screen, - __GLcontextModes *modes, - __GLXcontext *shareContext); + __GLXcontext *(*createContext) (__GLXscreen *screen, + __GLcontextModes *modes, + __GLXcontext *shareContext); + + __GLXdrawable *(*createDrawable)(__GLXscreen *context, + DrawablePtr pDraw, + XID drawId, + __GLcontextModes *modes); ScreenPtr pScreen; diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c index f1f9c06c5..ed5bafa34 100644 --- a/GL/glx/glxutil.c +++ b/GL/glx/glxutil.c @@ -140,12 +140,14 @@ __glXUnrefDrawable(__GLXdrawable *glxPriv) GLboolean __glXDrawableInit(__GLXdrawable *drawable, - __GLXcontext *ctx, DrawablePtr pDraw, XID drawId) + __GLXscreen *screen, DrawablePtr pDraw, XID drawId, + __GLcontextModes *modes) { drawable->type = pDraw->type; drawable->pDraw = pDraw; drawable->drawId = drawId; drawable->refCount = 1; + drawable->modes = modes; /* if not a pixmap, lookup will fail, so pGlxPixmap will be NULL */ drawable->pGlxPixmap = (__GLXpixmap *) @@ -167,13 +169,31 @@ __glXFindDrawable(XID drawId) __GLXdrawable * __glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId) { + __GLXscreen *pGlxScreen = ctx->pGlxScreen; __GLXdrawable *glxPriv; + __GLcontextModes *modes; glxPriv = __glXFindDrawable(drawId); if (glxPriv == NULL) { - glxPriv = ctx->createDrawable(ctx, pDraw, drawId); + if (pDraw->type == DRAWABLE_WINDOW) { + VisualID vid = wVisual((WindowPtr)pDraw); + + modes = _gl_context_modes_find_visual(pGlxScreen->modes, vid); + } else { + __GLXpixmap *pGlxPixmap = + (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes); + + /* We never get here without a valid pixmap. + * GetDrawableOrPixmap weeds out X Pixmaps without GLX + * pixmaps for us. */ + + modes = pGlxPixmap->modes; + } + + glxPriv = + pGlxScreen->createDrawable(ctx->pGlxScreen, pDraw, drawId, modes); /* since we are creating the drawablePrivate, drawId should be new */ if (!AddResource(drawId, __glXDrawableRes, glxPriv)) diff --git a/GL/glx/glxutil.h b/GL/glx/glxutil.h index d5cfa20b5..7b5494c9a 100644 --- a/GL/glx/glxutil.h +++ b/GL/glx/glxutil.h @@ -58,11 +58,13 @@ extern GLboolean __glXResizeDrawableBuffers(__GLXdrawable *glxPriv); extern void __glXRefDrawable(__GLXdrawable *glxPriv); extern void __glXUnrefDrawable(__GLXdrawable *glxPriv); -extern __GLXdrawable *__glXCreateDrawable(__GLXcontext *ctx, - DrawablePtr pDraw, - XID glxpixmapId); -extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, __GLXcontext *ctx, - DrawablePtr pDraw, XID drawID); +extern __GLXdrawable *__glXCreateDrawable(__GLXscreen *screen, + DrawablePtr pDraw, XID drawId, + __GLcontextModes *modes); +extern GLboolean __glXDrawableInit(__GLXdrawable *drawable, + __GLXscreen *screen, + DrawablePtr pDraw, XID drawID, + __GLcontextModes *modes); extern GLboolean __glXDestroyDrawable(__GLXdrawable *glxPriv); extern __GLXdrawable *__glXFindDrawable(XID glxpixmapId); extern __GLXdrawable *__glXGetDrawable(__GLXcontext *ctx, diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c index b1125a733..5085eb95e 100644 --- a/GL/mesa/X/xf86glx.c +++ b/GL/mesa/X/xf86glx.c @@ -140,12 +140,12 @@ __glXMesaDrawableSwapBuffers(__GLXdrawable *base) static __GLXdrawable * -__glXMesaContextCreateDrawable(__GLXcontext *context, - DrawablePtr pDraw, - XID drawId) +__glXMesaScreenCreateDrawable(__GLXscreen *screen, + DrawablePtr pDraw, + XID drawId, + __GLcontextModes *modes) { __GLXMESAdrawable *glxPriv; - __GLXscreen *pGlxScreen; XMesaVisual xm_vis; glxPriv = xalloc(sizeof *glxPriv); @@ -154,30 +154,19 @@ __glXMesaContextCreateDrawable(__GLXcontext *context, memset(glxPriv, 0, sizeof *glxPriv); - if (!__glXDrawableInit(&glxPriv->base, context, pDraw, drawId)) { + if (!__glXDrawableInit(&glxPriv->base, screen, pDraw, drawId, modes)) { xfree(glxPriv); return NULL; } - glxPriv->base.destroy = __glXMesaDrawableDestroy; - glxPriv->base.resize = __glXMesaDrawableResize; - glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers; + glxPriv->base.destroy = __glXMesaDrawableDestroy; + glxPriv->base.resize = __glXMesaDrawableResize; + glxPriv->base.swapBuffers = __glXMesaDrawableSwapBuffers; - pGlxScreen = __glXActiveScreens[pDraw->pScreen->myNum]; - - if (glxPriv->base.type == DRAWABLE_WINDOW) { - VisualID vid = wVisual((WindowPtr)pDraw); - - glxPriv->base.modes = _gl_context_modes_find_visual(pGlxScreen->modes, - vid); - } else { - glxPriv->base.modes = glxPriv->base.pGlxPixmap->modes; - } - - xm_vis = find_mesa_visual(pGlxScreen, glxPriv->base.modes->visualID); + xm_vis = find_mesa_visual(screen, modes->visualID); if (xm_vis == NULL) { ErrorF("find_mesa_visual returned NULL for visualID = 0x%04x\n", - glxPriv->base.modes->visualID); + modes->visualID); xfree(glxPriv); return NULL; } @@ -197,7 +186,7 @@ __glXMesaContextDestroy(__GLXcontext *baseContext) __GLXMESAcontext *context = (__GLXMESAcontext *) baseContext; XMesaDestroyContext(context->xmesa); - __glXContextDestroy(context); + __glXContextDestroy(&context->base); xfree(context); } @@ -268,7 +257,6 @@ __glXMesaScreenCreateContext(__GLXscreen *screen, context->base.loseCurrent = __glXMesaContextLoseCurrent; context->base.copy = __glXMesaContextCopy; context->base.forceCurrent = __glXMesaContextForceCurrent; - context->base.createDrawable = __glXMesaContextCreateDrawable; xm_vis = find_mesa_visual(screen, modes->visualID); if (!xm_vis) { @@ -417,8 +405,9 @@ __glXMesaScreenProbe(ScreenPtr pScreen) __glXScreenInit(&screen->base, pScreen); - screen->base.destroy = __glXMesaScreenDestroy; - screen->base.createContext = __glXMesaScreenCreateContext; + screen->base.destroy = __glXMesaScreenDestroy; + screen->base.createContext = __glXMesaScreenCreateContext; + screen->base.createDrawable = __glXMesaScreenCreateDrawable; screen->base.pScreen = pScreen; /* From 8b5bc6a9ab487fdea754266b120c686d75d9e100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 29 Jun 2006 00:05:01 -0400 Subject: [PATCH 3/6] Drop global GLX error integer variables and use __glXError() instead. Also drop glxerror.h (__glXError is now declared in glxserver.h) and global.c (last remaining globals are in glxext.c now). With this change we now support all GLX 1.3 error codes. --- GL/glx/Makefile.am | 2 -- GL/glx/global.c | 77 --------------------------------------- GL/glx/glxcmds.c | 86 ++++++++++++++++++++++---------------------- GL/glx/glxcmdsswap.c | 24 ++++++------- GL/glx/glxerror.h | 58 ------------------------------ GL/glx/glxext.c | 58 +++++++++++++++++++++--------- GL/glx/glxserver.h | 3 +- GL/glx/xfont.c | 2 +- 8 files changed, 99 insertions(+), 211 deletions(-) delete mode 100644 GL/glx/global.c delete mode 100644 GL/glx/glxerror.h diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am index fd8a59bd0..646f7d102 100644 --- a/GL/glx/Makefile.am +++ b/GL/glx/Makefile.am @@ -43,13 +43,11 @@ libglx_la_SOURCES = \ glapi.c \ glcontextmodes.c \ glcontextmodes.h \ - global.c \ glthread.c \ glxcmds.c \ glxcmdsswap.c \ glxcontext.h \ glxdrawable.h \ - glxerror.h \ glxext.c \ glxext.h \ glxvisuals.c \ diff --git a/GL/glx/global.c b/GL/glx/global.c deleted file mode 100644 index 28030ec03..000000000 --- a/GL/glx/global.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $XFree86$ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -#define NEED_REPLIES -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "glxserver.h" - -/* -** The last context used by the server. It is the context that is current -** from the server's perspective. -*/ -__GLXcontext *__glXLastContext; - -/* -** X resources. -*/ -RESTYPE __glXContextRes; -RESTYPE __glXClientRes; -RESTYPE __glXPixmapRes; -RESTYPE __glXDrawableRes; -RESTYPE __glXSwapBarrierRes; - -/* -** Error codes with the extension error base already added in. -*/ -int __glXBadContext, __glXBadContextState, __glXBadDrawable, __glXBadPixmap; -int __glXBadContextTag, __glXBadCurrentWindow; -int __glXBadRenderRequest, __glXBadLargeRequest; -int __glXUnsupportedPrivateRequest; - -/* -** Reply for most singles. -*/ -xGLXSingleReply __glXReply; - -/* -** A set of state for each client. The 0th one is unused because client -** indices start at 1, not 0. -*/ -__GLXclientState *__glXClients[MAXCLIENTS+1]; - diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index e2e157db8..665159ced 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -188,7 +188,7 @@ int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes); if (!shareglxc) { client->errorValue = shareList; - return __glXBadContext; + return __glXError(GLXBadContext); } if (shareglxc->isDirect) { /* @@ -301,7 +301,7 @@ int __glXDestroyContext(__GLXclientState *cl, GLbyte *pc) return Success; } else { client->errorValue = gcId; - return __glXBadContext; + return __glXError(GLXBadContext); } } @@ -474,7 +474,7 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, ** is, but it must first be created with glxCreateGLXPixmap). */ client->errorValue = drawId; - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } else { drawPixmap = (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes); @@ -494,7 +494,7 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, ** Drawable is neither a Window nor a GLXPixmap. */ client->errorValue = drawId; - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } @@ -542,12 +542,12 @@ int DoMakeCurrent( __GLXclientState *cl, /* ** Tag for previous context is invalid. */ - return __glXBadContextTag; + return __glXError(GLXBadContextTag); } if (prevglxc->renderMode != GL_RENDER) { /* Oops. Not in render mode render. */ client->errorValue = prevglxc->id; - return __glXBadContextState; + return __glXError(GLXBadContextState); } } else { prevglxc = 0; @@ -562,7 +562,7 @@ int DoMakeCurrent( __GLXclientState *cl, glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes); if (!glxc) { client->errorValue = contextId; - return __glXBadContext; + return __glXError(GLXBadContext); } if ((glxc != prevglxc) && glxc->isCurrent) { /* Context is current to somebody else */ @@ -593,14 +593,14 @@ int DoMakeCurrent( __GLXclientState *cl, if (pDraw) { drawPriv = __glXGetDrawable(glxc, pDraw, drawId); if (drawPriv == NULL) { - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } if (pRead != pDraw) { readPriv = __glXGetDrawable(glxc, pRead, readId); if (readPriv == NULL) { - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } else { readPriv = drawPriv; @@ -631,7 +631,7 @@ int DoMakeCurrent( __GLXclientState *cl, ** Make the previous context not current. */ if (!(*prevglxc->loseCurrent)(prevglxc)) { - return __glXBadContext; + return __glXError(GLXBadContext); } __glXFlushContextCache(); __glXDeassociateContext(prevglxc); @@ -647,7 +647,7 @@ int DoMakeCurrent( __GLXclientState *cl, if (!(*glxc->makeCurrent)(glxc)) { glxc->drawPriv = NULL; glxc->readPriv = NULL; - return __glXBadContext; + return __glXError(GLXBadContext); } /* resize the buffers */ @@ -656,7 +656,7 @@ int DoMakeCurrent( __GLXclientState *cl, (*glxc->loseCurrent)(glxc); glxc->drawPriv = NULL; glxc->readPriv = NULL; - return __glXBadContext; + return __glXError(GLXBadContext); } glxc->isCurrent = GL_TRUE; @@ -750,7 +750,7 @@ int __glXIsDirect(__GLXclientState *cl, GLbyte *pc) glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes); if (!glxc) { client->errorValue = req->context; - return __glXBadContext; + return __glXError(GLXBadContext); } reply.isDirect = glxc->isDirect; @@ -844,12 +844,12 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc) src = (__GLXcontext *) LookupIDByType(source, __glXContextRes); if (!src) { client->errorValue = source; - return __glXBadContext; + return __glXError(GLXBadContext); } dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes); if (!dst) { client->errorValue = dest; - return __glXBadContext; + return __glXError(GLXBadContext); } /* @@ -874,7 +874,7 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc) __GLXcontext *tagcx = __glXLookupContextByTag(cl, tag); if (!tagcx) { - return __glXBadContextTag; + return __glXError(GLXBadContextTag); } if (tagcx != src) { /* @@ -1308,7 +1308,7 @@ int DoDestroyPixmap(__GLXclientState *cl, XID glxpixmap) */ if (!LookupIDByType(glxpixmap, __glXPixmapRes)) { client->errorValue = glxpixmap; - return __glXBadPixmap; + return __glXError(GLXBadPixmap); } FreeResource(glxpixmap, FALSE); @@ -1408,7 +1408,7 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) ** Drawable is an X pixmap, which is not allowed. */ client->errorValue = drawId; - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } else { pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId, @@ -1422,14 +1422,14 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) ** Drawable is neither a X window nor a GLX pixmap. */ client->errorValue = drawId; - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } if (tag) { glxc = __glXLookupContextByTag(cl, tag); if (!glxc) { - return __glXBadContextTag; + return __glXError(GLXBadContextTag); } /* ** The calling thread is swapping its current drawable. In this case, @@ -1454,7 +1454,7 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) if (glxc) { glxPriv = __glXGetDrawable(glxc, pDraw, drawId); if (glxPriv == NULL) { - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } else { @@ -1466,7 +1466,7 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) } if ((*glxPriv->swapBuffers)(glxPriv) == GL_FALSE) { - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } } @@ -1486,7 +1486,7 @@ int DoQueryContext(__GLXclientState *cl, GLXContextID gcId) ctx = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes); if (!ctx) { client->errorValue = gcId; - return __glXBadContext; + return __glXError(GLXBadContext); } nProps = 3; @@ -1498,7 +1498,7 @@ int DoQueryContext(__GLXclientState *cl, GLXContextID gcId) nReplyBytes = reply.length << 2; sendBuf = (int *)xalloc((size_t)nReplyBytes); if (sendBuf == NULL) { - return __glXBadContext; /* XXX: Is this correct? */ + return __glXError(GLXBadContext); /* XXX: Is this correct? */ } pSendBuf = sendBuf; *pSendBuf++ = GLX_SHARE_CONTEXT_EXT; @@ -1549,7 +1549,7 @@ int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc) buffer = *((INT32 *) (pc + 4)); if (buffer != GLX_FRONT_LEFT_EXT) - return __glXBadPixmap; + return __glXError(GLXBadPixmap); context = __glXForceCurrent (cl, req->contextTag, &error); if (!context) @@ -1558,11 +1558,11 @@ int __glXBindTexImageEXT(__GLXclientState *cl, GLbyte *pc) pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes); if (!pGlxPixmap) { client->errorValue = drawId; - return __glXBadPixmap; + return __glXError(GLXBadPixmap); } if (!context->textureFromPixmap) - return __glXUnsupportedPrivateRequest; + return __glXError(GLXUnsupportedPrivateRequest); return context->textureFromPixmap->bindTexImage(context, buffer, @@ -1591,11 +1591,11 @@ int __glXReleaseTexImageEXT(__GLXclientState *cl, GLbyte *pc) pGlxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes); if (!pGlxPixmap) { client->errorValue = drawId; - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } if (!context->textureFromPixmap) - return __glXUnsupportedPrivateRequest; + return __glXError(GLXUnsupportedPrivateRequest); return context->textureFromPixmap->releaseTexImage(context, buffer, @@ -1617,7 +1617,7 @@ DoGetDrawableAttributes(__GLXclientState *cl, XID drawId) glxPixmap = (__GLXpixmap *)LookupIDByType(drawId, __glXPixmapRes); if (!glxPixmap) { client->errorValue = drawId; - return __glXBadPixmap; + return __glXError(GLXBadPixmap); } numAttribs = 2; @@ -1728,13 +1728,13 @@ int __glXRender(__GLXclientState *cl, GLbyte *pc) #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ } else { client->errorValue = commandsDone; - return __glXBadRenderRequest; + return __glXError(GLXBadRenderRequest); } if (!entry->bytes) { /* unused opcode */ client->errorValue = commandsDone; - return __glXBadRenderRequest; + return __glXError(GLXBadRenderRequest); } if (entry->varsize) { /* variable size command */ @@ -1820,7 +1820,7 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc) */ if (req->requestNumber != 1) { client->errorValue = req->requestNumber; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } hdr = (__GLXrenderLargeHeader *) pc; @@ -1841,13 +1841,13 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc) #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ } else { client->errorValue = opcode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } if (!entry->bytes) { /* unused opcode */ client->errorValue = opcode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } if (entry->varsize) { /* @@ -1904,12 +1904,12 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc) if (req->requestNumber != cl->largeCmdRequestsSoFar + 1) { client->errorValue = req->requestNumber; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } if (req->requestTotal != cl->largeCmdRequestsTotal) { client->errorValue = req->requestTotal; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } /* @@ -1918,7 +1918,7 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc) if ((cl->largeCmdBytesSoFar + dataBytes) > cl->largeCmdBytesTotal) { client->errorValue = dataBytes; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes); cl->largeCmdBytesSoFar += dataBytes; @@ -1942,7 +1942,7 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc) __GLX_PAD(cl->largeCmdBytesTotal)) { client->errorValue = dataBytes; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } hdr = (__GLXrenderLargeHeader *) cl->largeCmdBuf; opcode = hdr->opcode; @@ -1961,7 +1961,7 @@ int __glXRenderLarge(__GLXclientState *cl, GLbyte *pc) #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ } else { client->errorValue = opcode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } /* @@ -2011,7 +2011,7 @@ static int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc) } } client->errorValue = drawable; - return __glXBadDrawable; + return __glXError(GLXBadDrawable); } @@ -2252,7 +2252,7 @@ int __glXVendorPrivate(__GLXclientState *cl, GLbyte *pc) ** This sample implemention does not support any private requests. */ cl->client->errorValue = req->vendorCode; - return __glXUnsupportedPrivateRequest; + return __glXError(GLXUnsupportedPrivateRequest); } int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) @@ -2312,7 +2312,7 @@ int __glXVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) } cl->client->errorValue = vendorcode; - return __glXUnsupportedPrivateRequest; + return __glXError(GLXUnsupportedPrivateRequest); } int __glXQueryExtensionsString(__GLXclientState *cl, GLbyte *pc) diff --git a/GL/glx/glxcmdsswap.c b/GL/glx/glxcmdsswap.c index 3464e135a..b8f958bb3 100644 --- a/GL/glx/glxcmdsswap.c +++ b/GL/glx/glxcmdsswap.c @@ -674,12 +674,12 @@ int __glXSwapRender(__GLXclientState *cl, GLbyte *pc) #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ } else { client->errorValue = commandsDone; - return __glXBadRenderRequest; + return __glXError(GLXBadRenderRequest); } if (!entry->bytes) { /* unused opcode */ client->errorValue = commandsDone; - return __glXBadRenderRequest; + return __glXError(GLXBadRenderRequest); } if (entry->varsize) { /* variable size command */ @@ -772,7 +772,7 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) */ if (req->requestNumber != 1) { client->errorValue = req->requestNumber; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } hdr = (__GLXrenderLargeHeader *) pc; __GLX_SWAP_INT(&hdr->length); @@ -793,13 +793,13 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ } else { client->errorValue = opcode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } if (!entry->bytes) { /* unused opcode */ client->errorValue = opcode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } if (entry->varsize) { /* @@ -855,12 +855,12 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) if (req->requestNumber != cl->largeCmdRequestsSoFar + 1) { client->errorValue = req->requestNumber; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } if (req->requestTotal != cl->largeCmdRequestsTotal) { client->errorValue = req->requestTotal; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } /* @@ -869,7 +869,7 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) if ((cl->largeCmdBytesSoFar + dataBytes) > cl->largeCmdBytesTotal) { client->errorValue = dataBytes; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } memcpy(cl->largeCmdBuf + cl->largeCmdBytesSoFar, pc, dataBytes); cl->largeCmdBytesSoFar += dataBytes; @@ -893,7 +893,7 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) __GLX_PAD(cl->largeCmdBytesTotal)) { client->errorValue = dataBytes; __glXResetLargeCommandStatus(cl); - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } hdr = (__GLXrenderLargeHeader *) cl->largeCmdBuf; /* @@ -916,7 +916,7 @@ int __glXSwapRenderLarge(__GLXclientState *cl, GLbyte *pc) #endif /* __GLX_MAX_RENDER_OPCODE_EXT > __GLX_MIN_RENDER_OPCODE_EXT */ } else { client->errorValue = opcode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } /* @@ -984,7 +984,7 @@ int __glXSwapVendorPrivate(__GLXclientState *cl, GLbyte *pc) return Success; } cl->client->errorValue = req->vendorCode; - return __glXUnsupportedPrivateRequest; + return __glXError(GLXUnsupportedPrivateRequest); } int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) @@ -1037,5 +1037,5 @@ int __glXSwapVendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc) return (*__glXSwapVendorPrivTable_EXT[vendorcode-__GLX_MIN_VENDPRIV_OPCODE_EXT])(cl, (GLbyte*)req); } cl->client->errorValue = req->vendorCode; - return __glXUnsupportedPrivateRequest; + return __glXError(GLXUnsupportedPrivateRequest); } diff --git a/GL/glx/glxerror.h b/GL/glx/glxerror.h deleted file mode 100644 index 2c6d6d863..000000000 --- a/GL/glx/glxerror.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $XFree86$ */ -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef _GLX_error_h_ -#define _GLX_error_h_ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -** -*/ - -/* -** Error codes. These have the extension error base added to them -** when the extension initializes. -*/ -extern int __glXBadContext; -extern int __glXBadContextState; -extern int __glXBadDrawable; -extern int __glXBadPixmap; -extern int __glXBadCurrentWindow; -extern int __glXBadContextTag; -extern int __glXBadRenderRequest; -extern int __glXBadLargeRequest; -extern int __glXUnsupportedPrivateRequest; - -#endif diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c index cc5dd965a..176883da7 100644 --- a/GL/glx/glxext.c +++ b/GL/glx/glxext.c @@ -33,6 +33,33 @@ #include "glxutil.h" #include "glxext.h" +/* +** The last context used by the server. It is the context that is current +** from the server's perspective. +*/ +__GLXcontext *__glXLastContext; + +/* +** X resources. +*/ +RESTYPE __glXContextRes; +RESTYPE __glXClientRes; +RESTYPE __glXPixmapRes; +RESTYPE __glXDrawableRes; +RESTYPE __glXSwapBarrierRes; + +/* +** Reply for most singles. +*/ +xGLXSingleReply __glXReply; + +/* +** A set of state for each client. The 0th one is unused because client +** indices start at 1, not 0. +*/ +__GLXclientState *__glXClients[MAXCLIENTS+1]; + + static Bool inDispatch; /* @@ -265,6 +292,13 @@ GLboolean __glXErrorOccured(void) return errorOccured; } +static int __glXErrorBase; + +int __glXError(int error) +{ + return __glXErrorBase + error; +} + /************************************************************************/ /* @@ -274,11 +308,12 @@ void GlxExtensionInit(void) { ExtensionEntry *extEntry; int i; - + __glXContextRes = CreateNewResourceType((DeleteType)ContextGone); __glXClientRes = CreateNewResourceType((DeleteType)ClientGone); __glXPixmapRes = CreateNewResourceType((DeleteType)PixmapGone); __glXDrawableRes = CreateNewResourceType((DeleteType)DrawableGone); + __glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone); /* ** Add extension to server extensions. @@ -296,18 +331,7 @@ void GlxExtensionInit(void) return; } - __glXBadContext = extEntry->errorBase + GLXBadContext; - __glXBadContextState = extEntry->errorBase + GLXBadContextState; - __glXBadDrawable = extEntry->errorBase + GLXBadDrawable; - __glXBadPixmap = extEntry->errorBase + GLXBadPixmap; - __glXBadContextTag = extEntry->errorBase + GLXBadContextTag; - __glXBadCurrentWindow = extEntry->errorBase + GLXBadCurrentWindow; - __glXBadRenderRequest = extEntry->errorBase + GLXBadRenderRequest; - __glXBadLargeRequest = extEntry->errorBase + GLXBadLargeRequest; - __glXUnsupportedPrivateRequest = extEntry->errorBase + - GLXUnsupportedPrivateRequest; - - __glXSwapBarrierRes = CreateNewResourceType((DeleteType)SwapBarrierGone); + __glXErrorBase = extEntry->errorBase; /* ** Initialize table of client state. There is never a client 0. @@ -347,7 +371,7 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, cx = (__GLXcontext *) __glXLookupContextByTag(cl, tag); if (!cx) { cl->client->errorValue = tag; - *error = __glXBadContextTag; + *error = __glXError(GLXBadContextTag); return 0; } @@ -358,7 +382,7 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, ** windows can be destroyed from under us; GLX pixmaps are ** refcounted and don't go away until no one is using them. */ - *error = __glXBadCurrentWindow; + *error = __glXError(GLXBadCurrentWindow); return 0; } } @@ -373,7 +397,7 @@ __GLXcontext *__glXForceCurrent(__GLXclientState *cl, GLXContextTag tag, if (!(*cx->forceCurrent)(cx)) { /* Bind failed, and set the error code. Bummer */ cl->client->errorValue = cx->id; - *error = __glXBadContextState; + *error = __glXError(GLXBadContextState); return 0; } } @@ -469,7 +493,7 @@ static int __glXDispatch(ClientPtr client) */ if ((cl->largeCmdRequestsSoFar != 0) && (opcode != X_GLXRenderLarge)) { client->errorValue = stuff->glxCode; - return __glXBadLargeRequest; + return __glXError(GLXBadLargeRequest); } /* diff --git a/GL/glx/glxserver.h b/GL/glx/glxserver.h index a41720f54..ddb3ca9a6 100644 --- a/GL/glx/glxserver.h +++ b/GL/glx/glxserver.h @@ -70,7 +70,6 @@ typedef struct __GLXcontext __GLXcontext; #include "glxscreens.h" #include "glxdrawable.h" #include "glxcontext.h" -#include "glxerror.h" #define GLX_SERVER_MAJOR_VERSION 1 @@ -112,6 +111,8 @@ void __glXScreenInitVisuals(__GLXscreen *screen); extern __GLXcontext *__glXLastContext; extern __GLXcontext *__glXForceCurrent(__GLXclientState*, GLXContextTag, int*); +int __glXError(int error); + /* ** Macros to set, unset, and retrieve the flag that says whether a context ** has unflushed commands. diff --git a/GL/glx/xfont.c b/GL/glx/xfont.c index 795671534..89ff95b7c 100644 --- a/GL/glx/xfont.c +++ b/GL/glx/xfont.c @@ -179,7 +179,7 @@ int __glXUseXFont(__GLXclientState *cl, GLbyte *pc) ** to try to make a font during another lists construction. */ client->errorValue = cx->id; - return __glXBadContextState; + return __glXError(GLXBadContextState); } /* From ee012588d28b468bd41da8d216210f8cb2bf8cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 29 Jun 2006 04:25:54 -0400 Subject: [PATCH 4/6] Move __GLXdrawable lookup and creation into GetDrawableOrPixmap. Also refactors __glXSwapBuffers to use GetDrawableOrPixmap for getting the __GLXdrawable. This patch paves the way for GLXWindows with XIDs different from the X Windows they are created for, a prerequisite for glXCreateWindow(). --- GL/glx/glxcmds.c | 176 +++++++++++++++++++---------------------------- GL/glx/glxutil.c | 50 -------------- 2 files changed, 72 insertions(+), 154 deletions(-) diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index 665159ced..82166ac30 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -445,29 +445,46 @@ int __glXMakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc) * is added. */ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, - DrawablePtr *ppDraw, __GLXpixmap **ppPixmap, + __GLXdrawable **ppGlxDraw, + __GLXpixmap **ppPixmap, ClientPtr client ) { DrawablePtr pDraw; + __GLcontextModes *modes; + __GLXdrawable *pGlxDraw; __GLXpixmap *drawPixmap = NULL; + /* This is the GLX 1.3 case - the client passes in a GLXWindow and + * we just return the __GLXdrawable. The first time a GLXPixmap + * comes in, it doesn't have a corresponding __GLXdrawable, so it + * falls through to the else-case below, but after that it'll have + * a __GLXdrawable and we'll handle it here. */ + pGlxDraw = (__GLXdrawable *) LookupIDByType(drawId, __glXDrawableRes); + if (pGlxDraw != NULL) { + if (glxc != NULL && pGlxDraw->modes != glxc->modes) { + client->errorValue = drawId; + return BadMatch; + } + + *ppGlxDraw = pGlxDraw; + *ppPixmap = pGlxDraw->pGlxPixmap; + return Success; + } + + /* The drawId wasn't a GLXWindow, so presumably it's a regular X + * window. In that case, we create a shadow GLXWindow for it on + * demand here for pre GLX 1.3 compatibility and use the X Window + * XID as its GLXWindow XID. The client can't explicitly create a + * GLXWindow with the same XID as an X Window, so we wont get any + * resource ID clashes. Effectively, the X Window is now also a + * GLXWindow. */ pDraw = (DrawablePtr) LookupDrawable(drawId, client); if (pDraw) { if (pDraw->type == DRAWABLE_WINDOW) { - /* - ** Drawable is an X Window. - */ - WindowPtr pWin = (WindowPtr)pDraw; - VisualID vid = wVisual(pWin); + VisualID vid = wVisual((WindowPtr)pDraw); - /* - ** Check if window and context are similar. - */ - if ((vid != glxc->pVisual->vid) || - (pWin->drawable.pScreen != glxc->pScreen)) { - client->errorValue = drawId; - return BadMatch; - } + modes = _gl_context_modes_find_visual(glxc->pGlxScreen->modes, + vid); } else { /* ** An X Pixmap is not allowed as a parameter (a GLX Pixmap @@ -479,16 +496,8 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, } else { drawPixmap = (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes); if (drawPixmap) { - /* - ** Check if pixmap and context are similar. - */ - if (drawPixmap->pScreen != glxc->pScreen || - drawPixmap->modes->visualID != glxc->modes->visualID) { - client->errorValue = drawId; - return BadMatch; - } pDraw = drawPixmap->pDraw; - + modes = drawPixmap->modes; } else { /* ** Drawable is neither a Window nor a GLXPixmap. @@ -498,8 +507,33 @@ static int GetDrawableOrPixmap( __GLXcontext *glxc, GLXDrawable drawId, } } + /* If we're not given a context, don't create the __GLXdrawable */ + if (glxc == NULL) { + *ppPixmap = NULL; + *ppGlxDraw = NULL; + return Success; + } + + /* We're binding an X Window or a GLX Pixmap for the first time + * and need to create a GLX drawable for it. First check that the + * drawable screen and fbconfig matches the context ditto. */ + if (pDraw->pScreen != glxc->pScreen || modes != glxc->modes) { + client->errorValue = drawId; + return BadMatch; + } + + pGlxDraw = + glxc->pGlxScreen->createDrawable(glxc->pGlxScreen, + pDraw, drawId, modes); + + /* since we are creating the drawablePrivate, drawId should be new */ + if (!AddResource(drawId, __glXDrawableRes, pGlxDraw)) { + pGlxDraw->destroy (pGlxDraw); + return BadAlloc; + } + *ppPixmap = drawPixmap; - *ppDraw = pDraw; + *ppGlxDraw = pGlxDraw; return 0; } @@ -510,8 +544,6 @@ int DoMakeCurrent( __GLXclientState *cl, GLXContextID contextId, GLXContextTag tag ) { ClientPtr client = cl->client; - DrawablePtr pDraw; - DrawablePtr pRead; xGLXMakeCurrentReply reply; __GLXpixmap *drawPixmap = NULL; __GLXpixmap *readPixmap = NULL; @@ -572,36 +604,18 @@ int DoMakeCurrent( __GLXclientState *cl, assert( drawId != None ); assert( readId != None ); - status = GetDrawableOrPixmap( glxc, drawId, & pDraw, & drawPixmap, - client ); + status = GetDrawableOrPixmap(glxc, drawId, &drawPriv, &drawPixmap, + client); if ( status != 0 ) { return status; } if ( readId != drawId ) { - status = GetDrawableOrPixmap( glxc, readId, & pRead, & readPixmap, - client ); + status = GetDrawableOrPixmap(glxc, readId, &readPriv, &readPixmap, + client); if ( status != 0 ) { return status; } - } else { - pRead = pDraw; - } - - /* FIXME: Finish refactoring this. - idr */ - /* get the drawable private */ - if (pDraw) { - drawPriv = __glXGetDrawable(glxc, pDraw, drawId); - if (drawPriv == NULL) { - return __glXError(GLXBadDrawable); - } - } - - if (pRead != pDraw) { - readPriv = __glXGetDrawable(glxc, pRead, readId); - if (readPriv == NULL) { - return __glXError(GLXBadDrawable); - } } else { readPriv = drawPriv; } @@ -609,8 +623,8 @@ int DoMakeCurrent( __GLXclientState *cl, } else { /* Switching to no context. Ignore new drawable. */ glxc = 0; - pDraw = 0; - pRead = 0; + drawPriv = 0; + readPriv = 0; } @@ -1386,45 +1400,13 @@ int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc) int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) { ClientPtr client = cl->client; - DrawablePtr pDraw; xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc; GLXContextTag tag = req->contextTag; XID drawId = req->drawable; - __GLXpixmap *pGlxPixmap; __GLXcontext *glxc = NULL; + __GLXdrawable *pGlxDraw; + __GLXpixmap *pPixmap; int error; - - /* - ** Check that the GLX drawable is valid. - */ - pDraw = (DrawablePtr) LookupDrawable(drawId, client); - if (pDraw) { - if (pDraw->type == DRAWABLE_WINDOW) { - /* - ** Drawable is an X window. - */ - } else { - /* - ** Drawable is an X pixmap, which is not allowed. - */ - client->errorValue = drawId; - return __glXError(GLXBadDrawable); - } - } else { - pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId, - __glXPixmapRes); - if (pGlxPixmap) { - /* - ** Drawable is a GLX pixmap. - */ - } else { - /* - ** Drawable is neither a X window nor a GLX pixmap. - */ - client->errorValue = drawId; - return __glXError(GLXBadDrawable); - } - } if (tag) { glxc = __glXLookupContextByTag(cl, tag); @@ -1448,27 +1430,13 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc) } } - if (pDraw) { - __GLXdrawable *glxPriv; + error = GetDrawableOrPixmap(glxc, drawId, &pGlxDraw, &pPixmap, client); + if (error != Success) + return error; - if (glxc) { - glxPriv = __glXGetDrawable(glxc, pDraw, drawId); - if (glxPriv == NULL) { - return __glXError(GLXBadDrawable); - } - } - else { - glxPriv = __glXFindDrawable(drawId); - if (glxPriv == NULL) { - /* This is a window we've never seen before, do nothing */ - return Success; - } - } - - if ((*glxPriv->swapBuffers)(glxPriv) == GL_FALSE) { - return __glXError(GLXBadDrawable); - } - } + if (pGlxDraw != NULL && pGlxDraw->type == DRAWABLE_WINDOW && + (*pGlxDraw->swapBuffers)(pGlxDraw) == GL_FALSE) + return __glXError(GLXBadDrawable); return Success; } diff --git a/GL/glx/glxutil.c b/GL/glx/glxutil.c index ed5bafa34..bc9adea38 100644 --- a/GL/glx/glxutil.c +++ b/GL/glx/glxutil.c @@ -155,53 +155,3 @@ __glXDrawableInit(__GLXdrawable *drawable, return GL_TRUE; } - -__GLXdrawable * -__glXFindDrawable(XID drawId) -{ - __GLXdrawable *glxPriv; - - glxPriv = (__GLXdrawable *)LookupIDByType(drawId, __glXDrawableRes); - - return glxPriv; -} - -__GLXdrawable * -__glXGetDrawable(__GLXcontext *ctx, DrawablePtr pDraw, XID drawId) -{ - __GLXscreen *pGlxScreen = ctx->pGlxScreen; - __GLXdrawable *glxPriv; - __GLcontextModes *modes; - - glxPriv = __glXFindDrawable(drawId); - - if (glxPriv == NULL) - { - if (pDraw->type == DRAWABLE_WINDOW) { - VisualID vid = wVisual((WindowPtr)pDraw); - - modes = _gl_context_modes_find_visual(pGlxScreen->modes, vid); - } else { - __GLXpixmap *pGlxPixmap = - (__GLXpixmap *) LookupIDByType(drawId, __glXPixmapRes); - - /* We never get here without a valid pixmap. - * GetDrawableOrPixmap weeds out X Pixmaps without GLX - * pixmaps for us. */ - - modes = pGlxPixmap->modes; - } - - glxPriv = - pGlxScreen->createDrawable(ctx->pGlxScreen, pDraw, drawId, modes); - - /* since we are creating the drawablePrivate, drawId should be new */ - if (!AddResource(drawId, __glXDrawableRes, glxPriv)) - { - glxPriv->destroy (glxPriv); - return NULL; - } - } - - return glxPriv; -} From fc1a55671dceae0e2a701e044ff8203fae5eb1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 29 Jun 2006 04:35:45 -0400 Subject: [PATCH 5/6] Implement glXCreateWindow and glXDestroyWindow. --- GL/glx/glxcmds.c | 136 +++++++++++++++++++++++++++++------------------ GL/glx/glxext.h | 2 +- 2 files changed, 85 insertions(+), 53 deletions(-) diff --git a/GL/glx/glxcmds.c b/GL/glx/glxcmds.c index 82166ac30..8033f5d10 100644 --- a/GL/glx/glxcmds.c +++ b/GL/glx/glxcmds.c @@ -1201,81 +1201,82 @@ int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc) return DoGetFBConfigs( cl, req->screen, GL_FALSE ); } - -/* -** Create a GLX Pixmap from an X Pixmap. -*/ -int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, - GLuint screenNum, XID pixmapId, XID glxpixmapId) +static int ValidateCreateDrawable(ClientPtr client, + int screenNum, XID fbconfigId, + XID drawablId, XID glxDrawableId, + int type, __GLcontextModes **modes, + DrawablePtr *ppDraw) { - ClientPtr client = cl->client; DrawablePtr pDraw; ScreenPtr pScreen; VisualPtr pVisual; - __GLXpixmap *pGlxPixmap; __GLXscreen *pGlxScreen; - __GLcontextModes *modes; int i; - LEGAL_NEW_RESOURCE(glxpixmapId, client); - - pDraw = (DrawablePtr) LookupDrawable(pixmapId, client); - if (!pDraw || pDraw->type != DRAWABLE_PIXMAP) { - client->errorValue = pixmapId; - return BadPixmap; + LEGAL_NEW_RESOURCE(glxDrawableId, client); + + pDraw = (DrawablePtr) LookupDrawable(drawablId, client); + if (!pDraw || pDraw->type != type) { + client->errorValue = drawablId; + return type == DRAWABLE_WINDOW ? BadWindow : BadPixmap; } - /* - ** Check if screen of visual matches screen of pixmap. - */ + /* Check if screen of the fbconfig matches screen of drawable. */ pScreen = pDraw->pScreen; if (screenNum != pScreen->myNum) { return BadMatch; } - /* - ** Find the VisualRec for this visual. - */ + /* If this fbconfig has a corresponding VisualRec the number of + * planes must match the drawable depth. */ pVisual = pScreen->visuals; - for (i=0; i < pScreen->numVisuals; i++, pVisual++) { - if (pVisual->vid == visual) { - break; - } - } - if (i == pScreen->numVisuals) { - client->errorValue = visual; - return BadValue; - } - /* - ** Check if depth of visual matches depth of pixmap. - */ - if (pVisual->nplanes != pDraw->depth) { - return BadMatch; + for (i = 0; i < pScreen->numVisuals; i++, pVisual++) { + if (pVisual->vid == fbconfigId && pVisual->nplanes != pDraw->depth) + return BadMatch; } - /* - ** Get configuration of the visual. - */ - pGlxScreen = __glXActiveScreens[screenNum]; - modes = _gl_context_modes_find_visual( pGlxScreen->modes, visual ); - if (modes == NULL) { - /* - ** Visual not support on this screen by this OpenGL implementation. - */ - client->errorValue = visual; + /* Get configuration of the visual. */ + pGlxScreen = __glXgetActiveScreen(screenNum); + *modes = _gl_context_modes_find_visual(pGlxScreen->modes, fbconfigId); + if (*modes == NULL) { + /* Visual not support on this screen by this OpenGL implementation. */ + client->errorValue = fbconfigId; return BadValue; } + *ppDraw = pDraw; + + return Success; +} + +/* +** Create a GLX Pixmap from an X Pixmap. +*/ +int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId, + GLuint screenNum, XID pixmapId, XID glxPixmapId) +{ + ClientPtr client = cl->client; + DrawablePtr pDraw; + __GLXpixmap *pGlxPixmap; + __GLcontextModes *modes; + int retval; + + retval = ValidateCreateDrawable (client, screenNum, fbconfigId, + pixmapId, glxPixmapId, + DRAWABLE_PIXMAP, &modes, &pDraw); + if (retval != Success) + return retval; + pGlxPixmap = (__GLXpixmap *) xalloc(sizeof(__GLXpixmap)); if (!pGlxPixmap) { return BadAlloc; } - if (!(AddResource(glxpixmapId, __glXPixmapRes, pGlxPixmap))) { + if (!(AddResource(glxPixmapId, __glXPixmapRes, pGlxPixmap))) { return BadAlloc; } pGlxPixmap->pDraw = pDraw; - pGlxPixmap->pGlxScreen = pGlxScreen; - pGlxPixmap->pScreen = pScreen; + pGlxPixmap->pGlxScreen = __glXgetActiveScreen(screenNum); + pGlxPixmap->pScreen = pDraw->pScreen; pGlxPixmap->idExists = True; pGlxPixmap->pDamage = NULL; pGlxPixmap->refcnt = 0; @@ -1374,19 +1375,50 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc) int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc) { xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc; + ClientPtr client = cl->client; + DrawablePtr pDraw; + __GLXdrawable *glxPriv; + __GLXscreen *screen; + __GLcontextModes *modes; + int retval; - (void) req; + retval = ValidateCreateDrawable (client, req->screen, req->fbconfig, + req->window, req->glxwindow, + DRAWABLE_WINDOW, &modes, &pDraw); + if (retval != Success) + return retval; - return BadRequest; + /* FIXME: We need to check that the window visual is compatible + * with the specified fbconfig. */ + + screen = __glXgetActiveScreen(req->screen); + glxPriv = screen->createDrawable(screen, pDraw, req->glxwindow, modes); + if (glxPriv == NULL) + return BadAlloc; + + if (!AddResource(req->glxwindow, __glXDrawableRes, glxPriv)) { + glxPriv->destroy (glxPriv); + return BadAlloc; + } + + return Success; } int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc) { xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc; + ClientPtr client = cl->client; - (void) req; + /* + ** Check if it's a valid GLX window. + */ + if (!LookupIDByType(req->glxwindow, __glXDrawableRes)) { + client->errorValue = req->glxwindow; + return __glXError(GLXBadWindow); + } + FreeResource(req->glxwindow, FALSE); - return BadRequest; + return Success; } diff --git a/GL/glx/glxext.h b/GL/glx/glxext.h index 34d361217..03a2464ba 100644 --- a/GL/glx/glxext.h +++ b/GL/glx/glxext.h @@ -85,7 +85,7 @@ extern int DoGetFBConfigs(__GLXclientState *cl, unsigned screen, GLboolean do_swap); extern int DoCreateContext(__GLXclientState *cl, GLXContextID gcId, GLXContextID shareList, VisualID visual, GLuint screen, GLboolean isDirect); -extern int DoCreateGLXPixmap(__GLXclientState *cl, VisualID visual, +extern int DoCreateGLXPixmap(__GLXclientState *cl, XID fbconfigId, GLuint screenNum, XID pixmapId, XID glxpixmapId); extern int DoDestroyPixmap(__GLXclientState *cl, XID glxpixmapId); From 28b95fd9d1c2f078aaaac75c310a27b17c74a6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Thu, 6 Jul 2006 03:25:38 -0400 Subject: [PATCH 6/6] Drop unused GL/include subtree. Woo, less Makefile's to generate. --- GL/Makefile.am | 2 +- GL/include/GL/Makefile.am | 1 - GL/include/GL/glx_ansic.h | 112 -------------------------------------- GL/include/GL/xf86glx.h | 39 ------------- GL/include/Makefile.am | 1 - GL/mesa/X/xf86glx.c | 1 - GL/mesa/X/xf86glx_util.c | 1 - configure.ac | 2 - 8 files changed, 1 insertion(+), 158 deletions(-) delete mode 100644 GL/include/GL/Makefile.am delete mode 100644 GL/include/GL/glx_ansic.h delete mode 100644 GL/include/GL/xf86glx.h delete mode 100644 GL/include/Makefile.am diff --git a/GL/Makefile.am b/GL/Makefile.am index e8e080df1..b9337ba69 100644 --- a/GL/Makefile.am +++ b/GL/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = glx mesa include +SUBDIRS = glx mesa # someone could get really crazy someday and add support for the SI... diff --git a/GL/include/GL/Makefile.am b/GL/include/GL/Makefile.am deleted file mode 100644 index f2a902396..000000000 --- a/GL/include/GL/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = glx_ansic.h xf86glx.h diff --git a/GL/include/GL/glx_ansic.h b/GL/include/GL/glx_ansic.h deleted file mode 100644 index 9085a08fe..000000000 --- a/GL/include/GL/glx_ansic.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef _glx_ansic_h_ -#define _glx_ansic_h_ - -/* $XFree86: xc/programs/Xserver/GL/include/GL/glx_ansic.h,v 1.5 2001/03/21 20:49:08 dawes Exp $ */ -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -*/ - -/* -** this needs to check whether we're using XFree86 at all, and then -** which version we're using. Use these macros if version is 3.9+, else -** use normal commands below. -*/ - -/* -** turns out this include file only exists for XFree86 3.9+ -** I notice that not having it is not an error and does not stop the build, -** but having it will allow opengl and glx to be built for 3.9+. We no longer -** need an explicit define in the Makefile, just point to the correct X source -** tree and all should be taken care of. -*/ - -#ifdef XFree86Server - -#ifndef assert -#define assert(a) -#endif - -#else - -#if defined(Lynx) && defined(__assert_h) -#undef __assert_h -#endif -#ifdef assert -#undef assert -#endif -#include - -#endif - - -#define GLX_STDOUT stdout -#define GLX_STDERR stderr -#define __glXPrintf printf -#define __glXFprintf fprintf -#define __glXSprintf sprintf -#define __glXVfprintf vfprintf -#define __glXVsprintf vsprintf -#define __glXFopen fopen -#define __glXFclose fclose -#define __glXCos(x) cos(x) -#define __glXSin(x) sin(x) -#define __glXAtan(x) atan(x) -#define __glXAbs(x) abs(x) -#define __glXLog(x) log(x) -#define __glXCeil(x) ceil(x) -#define __glXFloor(x) floor(x) -#define __glXSqrt(x) sqrt(x) -#define __glXPow(x, y) pow(x, y) -#define __glXMemmove(dest, src, n) memmove(dest, src, n) -#define __glXMemcpy(dest, src, n) memcpy(dest, src, n) -#define __glXMemset(s, c, n) memset(s, c, n) -#define __glXStrdup(str) xstrdup(str) -#define __glXStrcpy(dest, src) strcpy(dest, src) -#define __glXStrncpy(dest, src, n) strncpy(dest, src, n) -#define __glXStrcat(dest, src) strcat(dest, src) -#define __glXStrncat(dest, src, n) strncat(dest, src, n) -#define __glXStrcmp(s1, s2) strcmp(s1, s2) -#define __glXStrncmp(s1, s2, n) strncmp(s1, s2, n) -#define __glXStrlen(str) strlen(str) -#define __glXAbort() abort() -#define __glXStrtok(s, delim) strtok(s, delim) -#define __glXStrcspn(s, reject) strcspn(s, reject) -#define __glXGetenv(a) getenv(a) -#define __glXAtoi(a) atoi(a) - -#endif /* _glx_ansic_h_ */ - diff --git a/GL/include/GL/xf86glx.h b/GL/include/GL/xf86glx.h deleted file mode 100644 index 5d018d72b..000000000 --- a/GL/include/GL/xf86glx.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $XFree86: xc/programs/Xserver/GL/include/GL/xf86glx.h,v 1.3 1999/06/14 07:31:41 dawes Exp $ */ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sub license, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice (including the -next paragraph) shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "miscstruct.h" diff --git a/GL/include/Makefile.am b/GL/include/Makefile.am deleted file mode 100644 index 1367fb437..000000000 --- a/GL/include/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = GL diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c index 5085eb95e..6015e15d2 100644 --- a/GL/mesa/X/xf86glx.c +++ b/GL/mesa/X/xf86glx.c @@ -54,7 +54,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include "context.h" #include "xmesaP.h" -#include #include "context.h" #include "glcontextmodes.h" diff --git a/GL/mesa/X/xf86glx_util.c b/GL/mesa/X/xf86glx_util.c index d8afcbcb5..4092a2654 100644 --- a/GL/mesa/X/xf86glx_util.c +++ b/GL/mesa/X/xf86glx_util.c @@ -42,7 +42,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "pixmapstr.h" #include "xf86glx_util.h" #include -#include "GL/xf86glx.h" #ifdef ROUNDUP #undef ROUNDUP diff --git a/configure.ac b/configure.ac index 9d8dfed78..55f002ee4 100644 --- a/configure.ac +++ b/configure.ac @@ -1599,8 +1599,6 @@ AC_OUTPUT([ Makefile GL/Makefile GL/glx/Makefile -GL/include/Makefile -GL/include/GL/Makefile GL/mesa/Makefile GL/mesa/array_cache/Makefile GL/mesa/glapi/Makefile