diff options
author | idr <idr> | 2003-03-27 01:36:11 +0000 |
---|---|---|
committer | idr <idr> | 2003-03-27 01:36:11 +0000 |
commit | bd778f30b96dc3e9575be388fa71bd250be500aa (patch) | |
tree | b38f88ff7bea0a2eeb5f13f1d87073d22fa86f26 | |
parent | b6ce73032f62b2300d0bfc5fc7dc3c913b35f9fc (diff) |
Fixed a significant binary-compatibility problem resulting from
changing the __GLXvisualConfigRec data structure.
-rw-r--r-- | xc/include/GL/glxint.h | 26 | ||||
-rw-r--r-- | xc/lib/GL/glx/glxclient.h | 9 | ||||
-rw-r--r-- | xc/lib/GL/glx/glxcmds.c | 56 | ||||
-rw-r--r-- | xc/lib/GL/glx/glxext.c | 73 |
4 files changed, 129 insertions, 35 deletions
diff --git a/xc/include/GL/glxint.h b/xc/include/GL/glxint.h index 1bfaafd53..e6ae8da46 100644 --- a/xc/include/GL/glxint.h +++ b/xc/include/GL/glxint.h @@ -27,6 +27,7 @@ #include <X11/Xdefs.h> typedef struct __GLXvisualConfigRec __GLXvisualConfig; +typedef struct __GLXFBConfigRec __GLXFBConfig; struct __GLXvisualConfigRec { VisualID vid; @@ -51,6 +52,31 @@ struct __GLXvisualConfigRec { /* colors are floats scaled to ints */ int transparentRed, transparentGreen, transparentBlue, transparentAlpha; int transparentIndex; +}; + +struct __GLXFBConfigRec { + VisualID vid; + int class; + Bool rgba; + int redSize, greenSize, blueSize, alphaSize; + unsigned long redMask, greenMask, blueMask, alphaMask; + int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; + Bool doubleBuffer; + Bool stereo; + int bufferSize; + int depthSize; + int stencilSize; + int auxBuffers; + int level; + + /* EXT_visual_rating / GLX 1.2 */ + int visualRating; + + /* EXT_visual_info / GLX 1.2 */ + int transparentPixel; + /* colors are floats scaled to ints */ + int transparentRed, transparentGreen, transparentBlue, transparentAlpha; + int transparentIndex; /* ARB_multisample / SGIS_multisample */ int sampleBuffers; diff --git a/xc/lib/GL/glx/glxclient.h b/xc/lib/GL/glx/glxclient.h index 9d416ce1e..a95be5fde 100644 --- a/xc/lib/GL/glx/glxclient.h +++ b/xc/lib/GL/glx/glxclient.h @@ -138,7 +138,7 @@ struct __DRIscreenRec { ** context dependent methods. */ void *(*createContext)(Display *dpy, XVisualInfo *vis, void *sharedPrivate, - __DRIcontext *pctx, __GLXvisualConfig * fbconfig); + __DRIcontext *pctx, __GLXFBConfig * fbconfig); /* ** Method to create the private DRI drawable data and initialize the @@ -565,8 +565,11 @@ extern void __glFreeAttributeState(__GLXcontext *); ** a pointer to the config data for that screen (if the screen supports GL). */ typedef struct __GLXscreenConfigsRec { - __GLXvisualConfig *configs; + __GLXFBConfig *configs; int numConfigs; + __GLXvisualConfig * old_configs; + int numOldConfigs; + const char *serverGLXexts; char *effectiveGLXexts; @@ -746,7 +749,7 @@ extern void _XSend(Display*, const void*, long); #endif -extern void __glXInitializeVisualConfigFromTags( __GLXvisualConfig *config, +extern void __glXInitializeVisualConfigFromTags( __GLXFBConfig *config, int count, const INT32 *bp, Bool tagged_only, Bool two_part_tags ); extern char *__glXInternalQueryServerString( Display *dpy, int opcode, diff --git a/xc/lib/GL/glx/glxcmds.c b/xc/lib/GL/glx/glxcmds.c index 1a9a9f4a8..076c3e55c 100644 --- a/xc/lib/GL/glx/glxcmds.c +++ b/xc/lib/GL/glx/glxcmds.c @@ -47,6 +47,7 @@ #endif #include "glxextensions.h" #include <sys/time.h> +#include <stdio.h> static const char __glXGLClientExtensions[] = "GL_ARB_depth_texture " @@ -655,7 +656,7 @@ void GLX_PREFIX(glXSwapBuffers)(Display *dpy, GLXDrawable drawable) } -static int GetConfigData(const __GLXvisualConfig *pConfig, int attribute, +static int GetConfigData(const __GLXFBConfig *pConfig, int attribute, int *value_return) { switch (attribute) { @@ -805,7 +806,7 @@ static int GetConfigData(const __GLXvisualConfig *pConfig, int attribute, int GLX_PREFIX(glXGetConfig)(Display *dpy, XVisualInfo *vis, int attribute, int *value_return) { - __GLXvisualConfig *pConfig; + __GLXFBConfig *pConfig; __GLXscreenConfigs *psc; __GLXdisplayPrivate *priv; GLint i; @@ -883,8 +884,8 @@ int GLX_PREFIX(glXGetConfig)(Display *dpy, XVisualInfo *vis, int attribute, * \param b Server specified config to test against \c a. */ static Bool -fbconfigs_compatible( const __GLXvisualConfig * const a, - const __GLXvisualConfig * const b ) +fbconfigs_compatible( const __GLXFBConfig * const a, + const __GLXFBConfig * const b ) { MATCH_DONT_CARE( doubleBuffer ); MATCH_DONT_CARE( class ); @@ -967,8 +968,8 @@ fbconfigs_compatible( const __GLXvisualConfig * const a, * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX */ static int -fbconfig_compare( const __GLXvisualConfig * const * const a, - const __GLXvisualConfig * const * const b ) +fbconfig_compare( const __GLXFBConfig * const * const a, + const __GLXFBConfig * const * const b ) { /* The order of these comparisons must NOT change. It is defined by * SGIX_fbconfig, SGIX_pbuffer, and ARB_multisample. @@ -1032,10 +1033,10 @@ fbconfig_compare( const __GLXvisualConfig * const * const a, * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX */ static int -choose_visual( __GLXvisualConfig ** configs, int num_configs, +choose_visual( __GLXFBConfig ** configs, int num_configs, const int *attribList, GLboolean two_part_tags ) { - __GLXvisualConfig test_config; + __GLXFBConfig test_config; int base; int i; @@ -1071,7 +1072,7 @@ choose_visual( __GLXvisualConfig ** configs, int num_configs, * specifications. */ - qsort( configs, base, sizeof( __GLXvisualConfig * ), + qsort( configs, base, sizeof( __GLXFBConfig * ), (int (*)(const void*, const void*)) fbconfig_compare ); return base; } @@ -1088,9 +1089,9 @@ XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, int *attribLi XVisualInfo visualTemplate; XVisualInfo *visualList; __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLXvisualConfig *config_list; - __GLXvisualConfig test_config; - const __GLXvisualConfig *best_config = NULL; + __GLXFBConfig *config_list; + __GLXFBConfig test_config; + const __GLXFBConfig *best_config = NULL; int count, i; /* @@ -1121,7 +1122,7 @@ XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, int *attribLi */ for (i = 0; i < count; i++) { if ( fbconfigs_compatible( & test_config, &config_list[i] ) ) { - const __GLXvisualConfig * const temp = &config_list[i]; + const __GLXFBConfig * const temp = &config_list[i]; if ( (best_config == None) || (fbconfig_compare( &temp, &best_config ) > 0) ) { @@ -1137,9 +1138,12 @@ XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, int *attribLi */ visualList = NULL; if (best_config != NULL) { + fprintf( stderr, "%s:%d: vid = 0x%02x\n", __FILE__, __LINE__, + best_config->vid ); visualTemplate.screen = screen; visualTemplate.visualid = best_config->vid; - visualList = XGetVisualInfo(dpy,VisualScreenMask|VisualIDMask,&visualTemplate,&count); + visualList = XGetVisualInfo( dpy, VisualScreenMask|VisualIDMask, + &visualTemplate, &count ); } return visualList; @@ -1184,7 +1188,7 @@ char *__glXInternalQueryServerString( Display *dpy, int opcode, const char *GLX_PREFIX(glXQueryExtensionsString)( Display *dpy, int screen ) { - __GLXvisualConfig *pConfig; + __GLXFBConfig *pConfig; __GLXscreenConfigs *psc; __GLXdisplayPrivate *priv; @@ -1236,7 +1240,7 @@ const char *GLX_PREFIX(glXGetClientString)( Display *dpy, int name ) const char *GLX_PREFIX(glXQueryServerString)( Display *dpy, int screen, int name ) { - __GLXvisualConfig *pConfig; + __GLXFBConfig *pConfig; __GLXscreenConfigs *psc; __GLXdisplayPrivate *priv; @@ -1468,11 +1472,11 @@ void GLX_PREFIX(glXFreeContextEXT)(Display *dpy, GLXContext ctx) GLXFBConfig *GLX_PREFIX(glXChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems) { - __GLXvisualConfig ** config_list; + __GLXFBConfig ** config_list; int list_size; - config_list = (__GLXvisualConfig **) + config_list = (__GLXFBConfig **) GLX_PREFIX(glXGetFBConfigs)( dpy, screen, & list_size ); if ( (config_list != NULL) && (list_size > 0) ) { @@ -1496,7 +1500,7 @@ GLXContext GLX_PREFIX(glXCreateNewContext)(Display *dpy, GLXFBConfig config, int #ifdef GLX_DIRECT_RENDERING __GLXdisplayPrivate *priv; #endif - __GLXvisualConfig * fbconfig = (__GLXvisualConfig *) config; + __GLXFBConfig * fbconfig = (__GLXFBConfig *) config; if (!dpy || !fbconfig) return NULL; @@ -1615,14 +1619,14 @@ GLXDrawable glXGetCurrentReadDrawable(void) GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, int *nelements) { __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLXvisualConfig ** config = NULL; + __GLXFBConfig ** config = NULL; int i; if ( (priv->screenConfigs != NULL) && (screen >= 0) && (screen <= ScreenCount(dpy)) && (priv->screenConfigs[screen].numConfigs > 0) && (priv->screenConfigs[screen].configs->fbconfigID != ((XID)-1)) ) { - config = (__GLXvisualConfig **) Xmalloc( sizeof(__GLXvisualConfig *) + config = (__GLXFBConfig **) Xmalloc( sizeof(__GLXFBConfig *) * priv->screenConfigs[screen].numConfigs ); if ( config != NULL ) { *nelements = priv->screenConfigs[screen].numConfigs; @@ -1638,7 +1642,7 @@ GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, int *nelement int GLX_PREFIX(glXGetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value) { __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLXvisualConfig * fbconfig = (__GLXvisualConfig *) config; + __GLXFBConfig * fbconfig = (__GLXFBConfig *) config; const int screen_count = ScreenCount(dpy); int i; @@ -1670,7 +1674,7 @@ void GLX_PREFIX(glXGetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigne XVisualInfo *GLX_PREFIX(glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config) { XVisualInfo visualTemplate; - __GLXvisualConfig * fbconfig = (__GLXvisualConfig *) config; + __GLXFBConfig * fbconfig = (__GLXFBConfig *) config; int count; /* @@ -2112,7 +2116,7 @@ GLXPixmap GLX_PREFIX(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, GLXFBConfig xGLXCreateGLXPixmapWithConfigSGIXReq *req; GLXPixmap xid = None; CARD8 opcode; - __GLXvisualConfig * fbconfig = (__GLXvisualConfig *) config; + __GLXFBConfig * fbconfig = (__GLXFBConfig *) config; if ( __glXExtensionBitIsEnabled( SGIX_fbconfig_bit ) ) { @@ -2147,7 +2151,7 @@ GLXContext GLX_PREFIX(glXCreateContextWithConfigSGIX)(Display *dpy, GLXFBConfigS #ifdef GLX_DIRECT_RENDERING __GLXdisplayPrivate *priv; #endif - __GLXvisualConfig * fbconfig = (__GLXvisualConfig *) config; + __GLXFBConfig * fbconfig = (__GLXFBConfig *) config; if ( __glXExtensionBitIsEnabled( SGIX_fbconfig_bit ) ) { if (!dpy || !fbconfig) @@ -2216,7 +2220,7 @@ XVisualInfo * GLX_PREFIX(glXGetVisualFromFBConfigSGIX)(Display *dpy, GLXFBConfig GLXFBConfigSGIX GLX_PREFIX(glXGetFBConfigFromVisualSGIX)(Display *dpy, XVisualInfo *vis) { __GLXdisplayPrivate *priv = __glXInitialize(dpy); - __GLXvisualConfig * configs = NULL; + __GLXFBConfig * configs = NULL; const int screen = vis->screen; int i; diff --git a/xc/lib/GL/glx/glxext.c b/xc/lib/GL/glx/glxext.c index d79058594..85a486241 100644 --- a/xc/lib/GL/glx/glxext.c +++ b/xc/lib/GL/glx/glxext.c @@ -145,6 +145,8 @@ int __glXDebug = 0; */ int __glXCloseDisplay(Display *dpy, XExtCodes *codes); +static GLboolean FillInVisuals( __GLXscreenConfigs * psc ); + /************************************************************************/ /* Extension required boiler plate */ @@ -222,6 +224,13 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv) Xfree((char*) psc->configs); if(psc->effectiveGLXexts) Xfree(psc->effectiveGLXexts); + + if ( psc->old_configs != NULL ) { + Xfree( psc->old_configs ); + psc->old_configs = NULL; + psc->numOldConfigs = 0; + } + psc->configs = 0; /* NOTE: just for paranoia */ } @@ -306,8 +315,53 @@ static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor) } +static GLboolean +FillInVisuals( __GLXscreenConfigs * psc ) +{ + int glx_visual_count; + int i; + + + glx_visual_count = 0; + for ( i = 0 ; i < psc->numConfigs ; i++ ) { + if ( (psc->configs[i].vid != GLX_DONT_CARE) + && (psc->configs[i].sampleBuffers == 0) + && (psc->configs[i].samples == 0) + && (psc->configs[i].drawableType == GLX_WINDOW_BIT) + && ((psc->configs[i].xRenderable == GL_TRUE) + || (psc->configs[i].xRenderable == GLX_DONT_CARE)) ) { + glx_visual_count++; + } + } + + psc->old_configs = (__GLXvisualConfig *) + Xmalloc( sizeof( __GLXvisualConfig ) * glx_visual_count ); + if ( psc->old_configs == NULL ) { + return GL_FALSE; + } + + glx_visual_count = 0; + for ( i = 0 ; i < psc->numConfigs ; i++ ) { + if ( (psc->configs[i].vid != GLX_DONT_CARE) + && (psc->configs[i].sampleBuffers == 0) + && (psc->configs[i].samples == 0) + && (psc->configs[i].drawableType == GLX_WINDOW_BIT) + && ((psc->configs[i].xRenderable == GL_TRUE) + || (psc->configs[i].xRenderable == GLX_DONT_CARE)) ) { + (void) memcpy( & psc->old_configs[glx_visual_count], + & psc->configs[i], + sizeof( __GLXvisualConfig ) ); + glx_visual_count++; + } + } + + psc->numOldConfigs = glx_visual_count; + return GL_TRUE; +} + + void -__glXInitializeVisualConfigFromTags( __GLXvisualConfig *config, int count, +__glXInitializeVisualConfigFromTags( __GLXFBConfig *config, int count, const INT32 *bp, Bool tagged_only, Bool two_part_tags ) { @@ -561,7 +615,7 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv) xGLXGetFBConfigsSGIXReq *sgi_req; xGLXGetVisualConfigsReply reply; __GLXscreenConfigs *psc; - __GLXvisualConfig *config; + __GLXFBConfig *config; GLint i, j, nprops, screens; INT32 buf[__GLX_TOTAL_CONFIG], *props; unsigned supported_request = 0; @@ -671,8 +725,8 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv) } /* Allocate memory for our config structure */ - psc->configs = (__GLXvisualConfig*) - Xmalloc(reply.numVisuals * sizeof(__GLXvisualConfig)); + psc->configs = (__GLXFBConfig*) + Xmalloc(reply.numVisuals * sizeof(__GLXFBConfig)); psc->numConfigs = reply.numVisuals; if (!psc->configs) { FreeScreenConfigs(priv); @@ -714,10 +768,17 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv) if (driver && driver->registerExtensionsFunc) (*driver->registerExtensionsFunc)(); /* screen initialization (bootstrap the driver) */ + + if ( (psc->old_configs == NULL) + && !FillInVisuals(psc) ) { + FreeScreenConfigs(priv); + return GL_FALSE; + } + psc->driScreen.private = (*(priv->driDisplay.createScreen[i]))(dpy, i, &psc->driScreen, - psc->numConfigs, - psc->configs); + psc->numOldConfigs, + psc->old_configs); } #endif } |