X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fx11%2Ffakeglx.c;h=969ee7d299842d142995f46cd18194a4e4caec5f;hb=bab755ad1b8cc5560c7d92e21b1fb1c3bebd43ae;hp=f097d93a71062a3edd5158d4cffda62231585b3c;hpb=32f2fd1c5d6088692551c80352b7d6fa35b0cd09;p=mesa.git diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index f097d93a710..969ee7d2998 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.5 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -18,9 +17,10 @@ * 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 NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. + * THE AUTHORS OR COPYRIGHT HOLDERS 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. */ @@ -52,10 +52,6 @@ #include "xfonts.h" #include "xmesaP.h" -#ifdef __VMS -#define _mesa_sprintf sprintf -#endif - /* This indicates the client-side GLX API and GLX encoder version. */ #define CLIENT_MAJOR_VERSION 1 #define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */ @@ -67,7 +63,7 @@ #define SERVER_MINOR_VERSION 4 /* This is appended onto the glXGetClient/ServerString version strings. */ -#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING +#define MESA_GLX_VERSION "Mesa " PACKAGE_VERSION /* Who implemented this GLX? */ #define VENDOR "Brian Paul" @@ -152,13 +148,8 @@ is_usable_visual( XVisualInfo *vinfo ) return GL_TRUE; case StaticColor: case PseudoColor: - /* Any StaticColor/PseudoColor visual of at least 4 bits */ - if (vinfo->depth>=4) { - return GL_TRUE; - } - else { - return GL_FALSE; - } + /* Color-index rendering is not supported. */ + return GL_FALSE; case TrueColor: case DirectColor: /* Any depth of TrueColor or DirectColor works in RGB mode */ @@ -206,7 +197,7 @@ GetOverlayInfo(Display *dpy, int screen, int *numOverlays) if (status != Success || actualType != overlayVisualsAtom || actualFormat != 32 || sizeData < 4) { /* something went wrong */ - XFree((void *) ovInfo); + free((void *) ovInfo); *numOverlays = 0; return NULL; } @@ -244,18 +235,18 @@ level_of_visual( Display *dpy, XVisualInfo *vinfo ) /* found the visual */ if (/*ov->transparent_type==1 &&*/ ov->layer!=0) { int level = ov->layer; - XFree((void *) overlay_info); + free((void *) overlay_info); return level; } else { - XFree((void *) overlay_info); + free((void *) overlay_info); return 0; } } } /* The visual ID was not found in the overlay list. */ - XFree((void *) overlay_info); + free((void *) overlay_info); return 0; } @@ -268,7 +259,7 @@ level_of_visual( Display *dpy, XVisualInfo *vinfo ) */ static XMesaVisual save_glx_visual( Display *dpy, XVisualInfo *vinfo, - GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, + GLboolean alphaFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint depth_size, GLint stencil_size, GLint accumRedSize, GLint accumGreenSize, @@ -309,7 +300,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, comparePointers = GL_FALSE; /* Force the visual to have an alpha channel */ - if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA")) + if (_mesa_getenv("MESA_GLX_FORCE_ALPHA")) alphaFlag = GL_TRUE; /* First check if a matching visual is already in the list */ @@ -319,7 +310,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, && v->mesa_visual.level == level && v->mesa_visual.numAuxBuffers == numAuxBuffers && v->ximage_flag == ximageFlag - && v->mesa_visual.rgbMode == rgbFlag && v->mesa_visual.doubleBufferMode == dbFlag && v->mesa_visual.stereoMode == stereoFlag && (v->mesa_visual.alphaBits > 0) == alphaFlag @@ -339,7 +329,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, /* Create a new visual and add it to the list. */ - xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, + xmvis = XMesaCreateVisual( dpy, vinfo, GL_TRUE, alphaFlag, dbFlag, stereoFlag, ximageFlag, depth_size, stencil_size, accumRedSize, accumBlueSize, @@ -422,53 +412,26 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) vislevel = level_of_visual( dpy, visinfo ); if (vislevel) { - /* Configure this visual as a CI, single-buffered overlay */ - return save_glx_visual( dpy, visinfo, - GL_FALSE, /* rgb */ - GL_FALSE, /* alpha */ - GL_FALSE, /* double */ - GL_FALSE, /* stereo */ - 0, /* depth bits */ - 0, /* stencil bits */ - 0,0,0,0, /* accum bits */ - vislevel, /* level */ - 0 /* numAux */ - ); + /* Color-index rendering to overlays is not supported. */ + return NULL; } else if (is_usable_visual( visinfo )) { - if (_mesa_getenv("MESA_GLX_FORCE_CI")) { - /* Configure this visual as a COLOR INDEX visual. */ - return save_glx_visual( dpy, visinfo, - GL_FALSE, /* rgb */ - GL_FALSE, /* alpha */ - GL_TRUE, /* double */ - GL_FALSE, /* stereo */ - zBits, - STENCIL_BITS, - 0, 0, 0, 0, /* accum bits */ - 0, /* level */ - 0 /* numAux */ - ); - } - else { - /* Configure this visual as RGB, double-buffered, depth-buffered. */ - /* This is surely wrong for some people's needs but what else */ - /* can be done? They should use glXChooseVisual(). */ - return save_glx_visual( dpy, visinfo, - GL_TRUE, /* rgb */ - alphaFlag, /* alpha */ - GL_TRUE, /* double */ - GL_FALSE, /* stereo */ - zBits, - STENCIL_BITS, - accBits, /* r */ - accBits, /* g */ - accBits, /* b */ - accBits, /* a */ - 0, /* level */ - 0 /* numAux */ - ); - } + /* Configure this visual as RGB, double-buffered, depth-buffered. */ + /* This is surely wrong for some people's needs but what else */ + /* can be done? They should use glXChooseVisual(). */ + return save_glx_visual( dpy, visinfo, + alphaFlag, /* alpha */ + GL_TRUE, /* double */ + GL_FALSE, /* stereo */ + zBits, + 8, /* stencil bits */ + accBits, /* r */ + accBits, /* g */ + accBits, /* b */ + accBits, /* a */ + 0, /* level */ + 0 /* numAux */ + ); } else { _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n"); @@ -530,19 +493,19 @@ transparent_pixel( XMesaVisual glxvis ) /* found it! */ if (ov->transparent_type == 0) { /* type 0 indicates no transparency */ - XFree((void *) overlay_info); + free((void *) overlay_info); return -1; } else { /* ov->value is the transparent pixel */ - XFree((void *) overlay_info); + free((void *) overlay_info); return ov->value; } } } /* The visual ID was not found in the overlay list. */ - XFree((void *) overlay_info); + free((void *) overlay_info); return -1; } @@ -587,7 +550,7 @@ get_visual( Display *dpy, int scr, unsigned int depth, int xclass ) return vis; } else { - XFree((void *) vis); + free((void *) vis); return NULL; } } @@ -623,8 +586,6 @@ get_env_visual(Display *dpy, int scr, const char *varname) if (strcmp(type,"TrueColor")==0) xclass = TrueColor; else if (strcmp(type,"DirectColor")==0) xclass = DirectColor; - else if (strcmp(type,"PseudoColor")==0) xclass = PseudoColor; - else if (strcmp(type,"StaticColor")==0) xclass = StaticColor; else if (strcmp(type,"GrayScale")==0) xclass = GrayScale; else if (strcmp(type,"StaticGray")==0) xclass = StaticGray; @@ -646,160 +607,79 @@ get_env_visual(Display *dpy, int scr, const char *varname) /* * Select an X visual which satisfies the RGBA/CI flag and minimum depth. * Input: dpy, screen - X display and screen number - * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode * min_depth - minimum visual depth * preferred_class - preferred GLX visual class or DONT_CARE * Return: pointer to an XVisualInfo or NULL. */ static XVisualInfo * -choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth, - int preferred_class ) +choose_x_visual(Display *dpy, int screen, int min_depth, int preferred_class) { XVisualInfo *vis; int xclass, visclass = 0; int depth; - if (rgba) { - Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True); - /* First see if the MESA_RGB_VISUAL env var is defined */ - vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); - if (vis) { - return vis; - } - /* Otherwise, search for a suitable visual */ - if (preferred_class==DONT_CARE) { - for (xclass=0;xclass<6;xclass++) { - switch (xclass) { - case 0: visclass = TrueColor; break; - case 1: visclass = DirectColor; break; - case 2: visclass = PseudoColor; break; - case 3: visclass = StaticColor; break; - case 4: visclass = GrayScale; break; - case 5: visclass = StaticGray; break; - } - if (min_depth==0) { - /* start with shallowest */ - for (depth=0;depth<=32;depth++) { - if (visclass==TrueColor && depth==8 && !hp_cr_maps) { - /* Special case: try to get 8-bit PseudoColor before */ - /* 8-bit TrueColor */ - vis = get_visual( dpy, screen, 8, PseudoColor ); - if (vis) { - return vis; - } - } - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - } - else { - /* start with deepest */ - for (depth=32;depth>=min_depth;depth--) { - if (visclass==TrueColor && depth==8 && !hp_cr_maps) { - /* Special case: try to get 8-bit PseudoColor before */ - /* 8-bit TrueColor */ - vis = get_visual( dpy, screen, 8, PseudoColor ); - if (vis) { - return vis; - } - } - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - } - } - } - else { - /* search for a specific visual class */ - switch (preferred_class) { - case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; - case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; - case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; - case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; - case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; - case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; - default: return NULL; - } - if (min_depth==0) { - /* start with shallowest */ - for (depth=0;depth<=32;depth++) { - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - } - else { - /* start with deepest */ - for (depth=32;depth>=min_depth;depth--) { - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - } + /* First see if the MESA_RGB_VISUAL env var is defined */ + vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" ); + if (vis) { + return vis; + } + /* Otherwise, search for a suitable visual */ + if (preferred_class==DONT_CARE) { + for (xclass=0;xclass<4;xclass++) { + switch (xclass) { + case 0: visclass = TrueColor; break; + case 1: visclass = DirectColor; break; + case 2: visclass = GrayScale; break; + case 3: visclass = StaticGray; break; + } + if (min_depth==0) { + /* start with shallowest */ + for (depth=0;depth<=32;depth++) { + vis = get_visual( dpy, screen, depth, visclass ); + if (vis) { + return vis; + } + } + } + else { + /* start with deepest */ + for (depth=32;depth>=min_depth;depth--) { + vis = get_visual( dpy, screen, depth, visclass ); + if (vis) { + return vis; + } + } + } } } else { - /* First see if the MESA_CI_VISUAL env var is defined */ - vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" ); - if (vis) { - return vis; + /* search for a specific visual class */ + switch (preferred_class) { + case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; + case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; + case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; + case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; + case GLX_PSEUDO_COLOR_EXT: + case GLX_STATIC_COLOR_EXT: + default: return NULL; } - /* Otherwise, search for a suitable visual, starting with shallowest */ - if (preferred_class==DONT_CARE) { - for (xclass=0;xclass<4;xclass++) { - switch (xclass) { - case 0: visclass = PseudoColor; break; - case 1: visclass = StaticColor; break; - case 2: visclass = GrayScale; break; - case 3: visclass = StaticGray; break; - } - /* try 8-bit up through 16-bit */ - for (depth=8;depth<=16;depth++) { - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - /* try min_depth up to 8-bit */ - for (depth=min_depth;depth<8;depth++) { - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - } + if (min_depth==0) { + /* start with shallowest */ + for (depth=0;depth<=32;depth++) { + vis = get_visual( dpy, screen, depth, visclass ); + if (vis) { + return vis; + } + } } else { - /* search for a specific visual class */ - switch (preferred_class) { - case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break; - case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break; - case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break; - case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break; - case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break; - case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break; - default: return NULL; - } - /* try 8-bit up through 16-bit */ - for (depth=8;depth<=16;depth++) { - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } - /* try min_depth up to 8-bit */ - for (depth=min_depth;depth<8;depth++) { - vis = get_visual( dpy, screen, depth, visclass ); - if (vis) { - return vis; - } - } + /* start with deepest */ + for (depth=32;depth>=min_depth;depth--) { + vis = get_visual( dpy, screen, depth, visclass ); + if (vis) { + return vis; + } + } } } @@ -822,7 +702,7 @@ choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth, * Return: pointer to an XVisualInfo or NULL. */ static XVisualInfo * -choose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag, +choose_x_overlay_visual( Display *dpy, int scr, int level, int trans_type, int trans_value, int min_depth, int preferred_class ) { @@ -889,21 +769,13 @@ choose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag, continue; } - /* if RGB was requested, make sure we have True/DirectColor */ - if (rgbFlag && vislist->CLASS != TrueColor - && vislist->CLASS != DirectColor) - continue; - - /* if CI was requested, make sure we have a color indexed visual */ - if (!rgbFlag - && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor)) + /* Color-index rendering is not supported. Make sure we have True/DirectColor */ + if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) continue; if (deepvis==NULL || vislist->depth > deepest) { /* YES! found a satisfactory visual */ - if (deepvis) { - XFree( deepvis ); - } + free(deepvis); deepest = vislist->depth; deepvis = vislist; /* DEBUG tt = ov->transparent_type;*/ @@ -990,6 +862,7 @@ register_with_display(Display *dpy) XExtCodes *c = XAddExtension(dpy); ext = dpy->ext_procs; /* new extension is at head of list */ assert(c->extension == ext->codes.extension); + (void) c; /* silence warning */ ext->name = _mesa_strdup(extName); ext->close_display = close_display_callback; } @@ -1038,6 +911,20 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) while (*parselist) { + if (fbConfig && + parselist[1] == GLX_DONT_CARE && + parselist[0] != GLX_LEVEL) { + /* For glXChooseFBConfig(), skip attributes whose value is + * GLX_DONT_CARE (-1), unless it's GLX_LEVEL (which can legitimately be + * a negative value). + * + * From page 17 (23 of the pdf) of the GLX 1.4 spec: + * GLX DONT CARE may be specified for all attributes except GLX LEVEL. + */ + parselist += 2; + continue; + } + switch (*parselist) { case GLX_USE_GL: if (fbConfig) { @@ -1218,12 +1105,16 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) parselist++; break; case GLX_FBCONFIG_ID: + case GLX_VISUAL_ID: if (!fbConfig) return NULL; parselist++; desiredVisualID = *parselist++; break; case GLX_X_RENDERABLE: + case GLX_MAX_PBUFFER_WIDTH: + case GLX_MAX_PBUFFER_HEIGHT: + case GLX_MAX_PBUFFER_PIXELS: if (!fbConfig) return NULL; parselist += 2; @@ -1266,7 +1157,11 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) } } + if (!rgb_flag) + return NULL; + (void) caveat; + (void) min_ci; /* * Since we're only simulating the GLX extension this function will never @@ -1285,46 +1180,27 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) if (vis) { /* give the visual some useful GLX attributes */ double_flag = GL_TRUE; - if (vis->depth > 8) - rgb_flag = GL_TRUE; + if (vis->depth <= 8) + return NULL; depth_size = default_depth_bits(); - stencil_size = STENCIL_BITS; + stencil_size = 8; /* XXX accum??? */ } } - else if (level==0) { - /* normal color planes */ - if (rgb_flag) { - /* Get an RGB visual */ - int min_rgb = min_red + min_green + min_blue; - if (min_rgb>1 && min_rgb<8) { - /* a special case to be sure we can get a monochrome visual */ - min_rgb = 1; - } - vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type ); - } - else { - /* Get a color index visual */ - vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); - accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; - } - } else { - /* over/underlay planes */ - if (rgb_flag) { - /* rgba overlay */ - int min_rgb = min_red + min_green + min_blue; - if (min_rgb>1 && min_rgb<8) { - /* a special case to be sure we can get a monochrome visual */ - min_rgb = 1; - } - vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, - trans_type, trans_value, min_rgb, visual_type ); + /* RGB visual */ + int min_rgb = min_red + min_green + min_blue; + if (min_rgb>1 && min_rgb<8) { + /* a special case to be sure we can get a monochrome visual */ + min_rgb = 1; + } + + if (level==0) { + vis = choose_x_visual(dpy, screen, min_rgb, visual_type); } else { - /* color index overlay */ - vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level, - trans_type, trans_value, min_ci, visual_type ); + vis = choose_x_overlay_visual(dpy, screen, level, + trans_type, trans_value, min_rgb, visual_type); } } @@ -1348,7 +1224,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) /* we only support one size of stencil and accum buffers. */ if (stencil_size > 0) - stencil_size = STENCIL_BITS; + stencil_size = 8; if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 || accumAlphaSize > 0) { accumRedSize = @@ -1357,7 +1233,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) accumAlphaSize = alpha_flag ? accumRedSize : 0; } - xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, + xmvis = save_glx_visual( dpy, vis, alpha_flag, double_flag, stereo_flag, depth_size, stencil_size, accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize, level, numAux ); @@ -1381,7 +1257,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); + xmvis->vishandle = malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -1429,7 +1305,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, /* deallocate unused windows/buffers */ #if 0 - XMesaGarbageCollect(); + XMesaGarbageCollect(dpy); #endif xmvis = find_glx_visual( dpy, visinfo ); @@ -1490,9 +1366,6 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, /* Out of memory, or context/drawable depth mismatch */ return False; } -#ifdef FX - FXcreateContext( xmctx->xm_visual, draw, xmctx, drawBuffer ); -#endif } /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ @@ -1510,9 +1383,6 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, /* Out of memory, or context/drawable depth mismatch */ return False; } -#ifdef FX - FXcreateContext( xmctx->xm_visual, read, xmctx, readBuffer ); -#endif } MakeCurrent_PrevContext = ctx; @@ -1662,16 +1532,18 @@ void _kw_ungrab_all( Display *dpy ) static void Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) { - struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; - (void) dpy; - MakeCurrent_PrevContext = 0; - MakeCurrent_PrevDrawable = 0; - MakeCurrent_PrevReadable = 0; - MakeCurrent_PrevDrawBuffer = 0; - MakeCurrent_PrevReadBuffer = 0; - XMesaDestroyContext( glxCtx->xmesaContext ); - XMesaGarbageCollect(); - free(glxCtx); + if (ctx) { + struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; + (void) dpy; + MakeCurrent_PrevContext = 0; + MakeCurrent_PrevDrawable = 0; + MakeCurrent_PrevReadable = 0; + MakeCurrent_PrevDrawBuffer = 0; + MakeCurrent_PrevReadBuffer = 0; + XMesaDestroyContext( glxCtx->xmesaContext ); + XMesaGarbageCollect(dpy); + free(glxCtx); + } } @@ -1680,7 +1552,7 @@ Fake_glXIsDirect( Display *dpy, GLXContext ctx ) { struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; (void) dpy; - return glxCtx->xmesaContext->direct; + return glxCtx ? glxCtx->xmesaContext->direct : False; } @@ -2005,12 +1877,6 @@ Fake_glXWaitX( void ) static const char * get_extensions( void ) { -#ifdef FX - const char *fx = _mesa_getenv("MESA_GLX_FX"); - if (fx && fx[0] != 'd') { - return EXTENSIONS; - } -#endif return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */ } @@ -2032,8 +1898,8 @@ static const char * Fake_glXQueryServerString( Display *dpy, int screen, int name ) { static char version[1000]; - _mesa_sprintf(version, "%d.%d %s", - SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); + sprintf(version, "%d.%d %s", + SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION); (void) dpy; (void) screen; @@ -2057,8 +1923,8 @@ static const char * Fake_glXGetClientString( Display *dpy, int name ) { static char version[1000]; - _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, - CLIENT_MINOR_VERSION, MESA_GLX_VERSION); + sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION, + CLIENT_MINOR_VERSION, MESA_GLX_VERSION); (void) dpy; @@ -2108,7 +1974,7 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); if (*nelements > 0) { XMesaVisual *results; - results = (XMesaVisual *) malloc(*nelements * sizeof(XMesaVisual)); + results = malloc(*nelements * sizeof(XMesaVisual)); if (!results) { *nelements = 0; return NULL; @@ -2128,6 +1994,9 @@ Fake_glXChooseFBConfig( Display *dpy, int screen, { XMesaVisual xmvis; + /* register ourselves as an extension on this display */ + register_with_display(dpy); + if (!attribList || !attribList[0]) { /* return list of all configs (per GLX_SGIX_fbconfig spec) */ return Fake_glXGetFBConfigs(dpy, screen, nitems); @@ -2135,7 +2004,7 @@ Fake_glXChooseFBConfig( Display *dpy, int screen, xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); if (xmvis) { - GLXFBConfig *config = (GLXFBConfig *) malloc(sizeof(XMesaVisual)); + GLXFBConfig *config = malloc(sizeof(XMesaVisual)); if (!config) { *nitems = 0; return NULL; @@ -2160,7 +2029,7 @@ Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); + xmvis->vishandle = malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -2186,11 +2055,6 @@ Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win, if (!xmbuf) return 0; -#ifdef FX - /* XXX this will segfault if actually called */ - FXcreateContext(xmvis, win, NULL, xmbuf); -#endif - (void) dpy; (void) attribList; /* Ignored in GLX 1.3 */ @@ -2367,13 +2231,13 @@ Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config, if (width == 0 || height == 0) return 0; - if (width > MAX_WIDTH || height > MAX_HEIGHT) { + if (width > SWRAST_MAX_WIDTH || height > SWRAST_MAX_HEIGHT) { /* If allocation would have failed and GLX_LARGEST_PBUFFER is set, * allocate the largest possible buffer. */ if (useLargest) { - width = MAX_WIDTH; - height = MAX_HEIGHT; + width = SWRAST_MAX_WIDTH; + height = SWRAST_MAX_HEIGHT; } } @@ -2464,7 +2328,7 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config, return 0; /* deallocate unused windows/buffers */ - XMesaGarbageCollect(); + XMesaGarbageCollect(dpy); glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL); @@ -2493,10 +2357,7 @@ Fake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) *value = xmctx->xm_visual->visinfo->visualid; break; case GLX_RENDER_TYPE: - if (xmctx->xm_visual->mesa_visual.rgbMode) - *value = GLX_RGBA_TYPE; - else - *value = GLX_COLOR_INDEX_TYPE; + *value = GLX_RGBA_TYPE; break; case GLX_SCREEN: *value = 0; @@ -2682,7 +2543,7 @@ Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int re return 0; /* deallocate unused windows/buffers */ - XMesaGarbageCollect(); + XMesaGarbageCollect(dpy); glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx ? shareCtx->xmesaContext : NULL);