From e9bf776711b22ce336cd462adf534ad3e2d61eec Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Jan 2001 04:06:20 +0000 Subject: Modify X11 driver and fake glx to store a GLcontext (ie a 'struct __GLcontextRec *') instead of an 'XMesaContext'. This is to fix conflicts in XFree86 where both the indirect XMesaContext and the GLcontext were calling themselves __GLcontextRec's. --- src/mesa/drivers/x11/fakeglx.c | 46 +++++++------- src/mesa/drivers/x11/glxheader.h | 4 +- src/mesa/drivers/x11/xfonts.c | 4 +- src/mesa/drivers/x11/xfonts.h | 4 +- src/mesa/drivers/x11/xm_api.c | 129 ++++++++++++++++++++------------------- src/mesa/drivers/x11/xm_dd.c | 5 +- src/mesa/drivers/x11/xm_span.c | 4 +- src/mesa/drivers/x11/xmesaP.h | 4 +- 8 files changed, 103 insertions(+), 97 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 3b6ff71ab5..fa93756850 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1,4 +1,4 @@ -/* $Id: fakeglx.c,v 1.42 2000/12/15 04:02:50 brianp Exp $ */ +/* $Id: fakeglx.c,v 1.43 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -1090,7 +1090,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, GLXContext share_list, Bool direct ) { XMesaVisual glxvis; - XMesaContext xmctx; + struct __GLcontextRec *ctx; /* deallocate unused windows/buffers */ XMesaGarbageCollect(); @@ -1105,12 +1105,13 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, } } - xmctx = XMesaCreateContext( glxvis, (XMesaContext) share_list ); - if (xmctx) { + ctx = XMesaCreateContext( glxvis, (struct __GLcontextRec *) share_list ); + if (ctx) { + XMesaContext xmctx = (XMesaContext)(ctx->DriverCtx); /* set the direct/indirect flag */ xmctx->direct = direct; } - return (GLXContext) xmctx; + return (GLXContext) ctx; } @@ -1123,15 +1124,16 @@ static XMesaBuffer MakeCurrent_PrevReadBuffer = 0; /* GLX 1.3 and later */ static Bool Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, - GLXDrawable read, GLXContext ctx ) + GLXDrawable read, GLXContext glxctx ) { - if (ctx && draw && read) { + if (glxctx && draw && read) { XMesaBuffer drawBuffer, readBuffer; - XMesaContext xmctx = (XMesaContext) ctx; + GLcontext *ctx = (GLcontext *) glxctx; + XMesaContext xmctx = (XMesaContext)(ctx->DriverCtx); /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */ - if (ctx == MakeCurrent_PrevContext - && draw == MakeCurrent_PrevDrawable) { + if (glxctx == MakeCurrent_PrevContext && + draw == MakeCurrent_PrevDrawable) { drawBuffer = MakeCurrent_PrevDrawBuffer; } else { @@ -1139,7 +1141,7 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, } if (!drawBuffer) { /* drawable must be a new window! */ - drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, (XMesaContext) ctx ); + drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx ); if (!drawBuffer) { /* Out of memory, or context/drawable depth mismatch */ return False; @@ -1147,7 +1149,7 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, } /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */ - if (ctx == MakeCurrent_PrevContext + if (glxctx == MakeCurrent_PrevContext && read == MakeCurrent_PrevReadable) { readBuffer = MakeCurrent_PrevReadBuffer; } @@ -1156,23 +1158,23 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw, } if (!readBuffer) { /* drawable must be a new window! */ - readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, (XMesaContext) ctx ); + readBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, read, xmctx ); if (!readBuffer) { /* Out of memory, or context/drawable depth mismatch */ return False; } } - MakeCurrent_PrevContext = ctx; + MakeCurrent_PrevContext = glxctx; MakeCurrent_PrevDrawable = draw; MakeCurrent_PrevReadable = read; MakeCurrent_PrevDrawBuffer = drawBuffer; MakeCurrent_PrevReadBuffer = readBuffer; /* Now make current! */ - return (Bool) XMesaMakeCurrent2((XMesaContext) ctx, drawBuffer, readBuffer); + return (Bool) XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer); } - else if (!ctx && !draw && !read) { + else if (!glxctx && !draw && !read) { /* release current context w/out assigning new one. */ XMesaMakeCurrent( NULL, NULL ); MakeCurrent_PrevContext = 0; @@ -1267,10 +1269,10 @@ static void Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst, unsigned long mask ) { - XMesaContext xm_src = (XMesaContext) src; - XMesaContext xm_dst = (XMesaContext) dst; + struct __GLcontextRec *csrc = (struct __GLcontextRec *) src; + struct __GLcontextRec *cdst = (struct __GLcontextRec *) dst; (void) dpy; - _mesa_copy_context( xm_src->gl_ctx, xm_dst->gl_ctx, (GLuint) mask ); + _mesa_copy_context( csrc, cdst, (GLuint) mask ); } @@ -1297,13 +1299,14 @@ void _kw_ungrab_all( Display *dpy ) static void Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) { + XMesaContext xmctx = (XMesaContext)(((GLcontext *)ctx)->DriverCtx); (void) dpy; MakeCurrent_PrevContext = 0; MakeCurrent_PrevDrawable = 0; MakeCurrent_PrevReadable = 0; MakeCurrent_PrevDrawBuffer = 0; MakeCurrent_PrevReadBuffer = 0; - XMesaDestroyContext( (XMesaContext) ctx ); + XMesaDestroyContext( xmctx ); XMesaGarbageCollect(); } @@ -1312,8 +1315,9 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) static Bool Fake_glXIsDirect( Display *dpy, GLXContext ctx ) { + XMesaContext xmctx = (XMesaContext)(((GLcontext *)ctx)->DriverCtx); (void) dpy; - return ((XMesaContext) ctx)->direct; + return xmctx->direct; } diff --git a/src/mesa/drivers/x11/glxheader.h b/src/mesa/drivers/x11/glxheader.h index 99a6400aad..9077e3460c 100644 --- a/src/mesa/drivers/x11/glxheader.h +++ b/src/mesa/drivers/x11/glxheader.h @@ -1,8 +1,8 @@ -/* $Id: glxheader.h,v 1.2 2000/08/22 13:31:04 joukj Exp $ */ +/* $Id: glxheader.h,v 1.3 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * * Copyright (C) 1999 Brian Paul All Rights Reserved. * diff --git a/src/mesa/drivers/x11/xfonts.c b/src/mesa/drivers/x11/xfonts.c index 4243f3ff8d..6e73504ba5 100644 --- a/src/mesa/drivers/x11/xfonts.c +++ b/src/mesa/drivers/x11/xfonts.c @@ -1,8 +1,8 @@ -/* $Id: xfonts.c,v 1.10 2000/11/10 17:23:03 brianp Exp $ */ +/* $Id: xfonts.c,v 1.11 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.4 + * Version: 3.5 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * diff --git a/src/mesa/drivers/x11/xfonts.h b/src/mesa/drivers/x11/xfonts.h index 712c9d4c32..abf95223ba 100644 --- a/src/mesa/drivers/x11/xfonts.h +++ b/src/mesa/drivers/x11/xfonts.h @@ -1,8 +1,8 @@ -/* $Id: xfonts.h,v 1.2 2000/08/22 13:31:04 joukj Exp $ */ +/* $Id: xfonts.h,v 1.3 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index bff35d59dd..f0861f5e4e 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1,4 +1,4 @@ -/* $Id: xm_api.c,v 1.13 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: xm_api.c,v 1.14 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -1613,7 +1613,8 @@ void XMesaDestroyVisual( XMesaVisual v ) * lists or NULL if no sharing is wanted. * Return: an XMesaContext or NULL if error. */ -XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) +struct __GLcontextRec *XMesaCreateContext( XMesaVisual v, + struct __GLcontextRec *share_list ) { XMesaContext c; GLcontext *ctx; @@ -1632,8 +1633,9 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) } ctx = c->gl_ctx = _mesa_create_context( v->gl_visual, - share_list ? share_list->gl_ctx : (GLcontext *) NULL, - (void *) c, direct ); + share_list, + (void *) c, + direct ); if (!c->gl_ctx) { FREE(c); return NULL; @@ -1676,8 +1678,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) */ _mesa_context_initialize( ctx ); - - return c; + return ctx; } @@ -1759,12 +1760,12 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w, assert(v); #ifdef XFree86Server - if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth) { + if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth) #else - XGetWindowAttributes( v->display, w, &attr ); - - if (GET_VISUAL_DEPTH(v) != attr.depth) { + XGetWindowAttributes( v->display, w, &attr ); + if (GET_VISUAL_DEPTH(v) != attr.depth) #endif + { if (getenv("MESA_DEBUG")) { fprintf(stderr, "XMesaCreateWindowBuffer: depth mismatch between visual and window!\n"); } @@ -1825,61 +1826,61 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w, #ifdef FX fxEnvVar = getenv("MESA_GLX_FX"); if (fxEnvVar) { - if (fxEnvVar[0]!='d') { - int attribs[100]; - int numAttribs = 0; - int hw; - if (v->gl_visual->DepthBits > 0) { - attribs[numAttribs++] = FXMESA_DEPTH_SIZE; - attribs[numAttribs++] = 1; - } - if (v->gl_visual->DBflag) { - attribs[numAttribs++] = FXMESA_DOUBLEBUFFER; - } - if (v->gl_visual->AccumRedBits > 0) { - attribs[numAttribs++] = FXMESA_ACCUM_SIZE; - attribs[numAttribs++] = v->gl_visual->AccumRedBits; - } - if (v->gl_visual->StencilBits > 0) { - attribs[numAttribs++] = FXMESA_STENCIL_SIZE; - attribs[numAttribs++] = v->gl_visual->StencilBits; - } - if (v->gl_visual->AlphaBits > 0) { - attribs[numAttribs++] = FXMESA_ALPHA_SIZE; - attribs[numAttribs++] = 1; - } - if (c->gl_ctx) { + if (fxEnvVar[0]!='d') { + int attribs[100]; + int numAttribs = 0; + int hw; + if (v->gl_visual->DepthBits > 0) { + attribs[numAttribs++] = FXMESA_DEPTH_SIZE; + attribs[numAttribs++] = 1; + } + if (v->gl_visual->DBflag) { + attribs[numAttribs++] = FXMESA_DOUBLEBUFFER; + } + if (v->gl_visual->AccumRedBits > 0) { + attribs[numAttribs++] = FXMESA_ACCUM_SIZE; + attribs[numAttribs++] = v->gl_visual->AccumRedBits; + } + if (v->gl_visual->StencilBits > 0) { + attribs[numAttribs++] = FXMESA_STENCIL_SIZE; + attribs[numAttribs++] = v->gl_visual->StencilBits; + } + if (v->gl_visual->AlphaBits > 0) { + attribs[numAttribs++] = FXMESA_ALPHA_SIZE; + attribs[numAttribs++] = 1; + } + if (c->gl_ctx) { #define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with fxapi.c! */ - attribs[numAttribs++] = FXMESA_SHARE_CONTEXT; - attribs[numAttribs++] = (int) c->gl_ctx; - } - attribs[numAttribs++] = FXMESA_NONE; - - if ((hw = fxQueryHardware())==GR_SSTTYPE_VOODOO) { - b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs); - if ((v->undithered_pf!=PF_INDEX) && (b->backimage)) { - b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE; - if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W') - b->FXwindowHack = b->FXctx ? GL_TRUE : GL_FALSE; - else - b->FXwindowHack = GL_FALSE; - } - } - else { - if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W') - b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE, - GR_REFRESH_75Hz, attribs); - else - b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs); - b->FXisHackUsable = GL_FALSE; - b->FXwindowHack = GL_FALSE; - } - /* - fprintf(stderr, - "voodoo %d, wid %d height %d hack: usable %d active %d\n", - hw, b->width, b->height, b->FXisHackUsable, b->FXwindowHack); - */ - } + attribs[numAttribs++] = FXMESA_SHARE_CONTEXT; + attribs[numAttribs++] = (int) c->gl_ctx; + } + attribs[numAttribs++] = FXMESA_NONE; + + if ((hw = fxQueryHardware())==GR_SSTTYPE_VOODOO) { + b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs); + if ((v->undithered_pf!=PF_INDEX) && (b->backimage)) { + b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE; + if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W') + b->FXwindowHack = b->FXctx ? GL_TRUE : GL_FALSE; + else + b->FXwindowHack = GL_FALSE; + } + } + else { + if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W') + b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE, + GR_REFRESH_75Hz, attribs); + else + b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs); + b->FXisHackUsable = GL_FALSE; + b->FXwindowHack = GL_FALSE; + } + /* + fprintf(stderr, + "voodoo %d, wid %d height %d hack: usable %d active %d\n", + hw, b->width, b->height, b->FXisHackUsable, b->FXwindowHack); + */ + } } else { fprintf(stderr,"WARNING: This Mesa Library includes the Glide driver but\n"); diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 50700c6628..21fe98cb49 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -1,8 +1,8 @@ -/* $Id: xm_dd.c,v 1.8 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: xm_dd.c,v 1.9 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * @@ -923,6 +923,7 @@ void xmesa_init_pointers( GLcontext *ctx ) ctx->Driver.Finish = finish; ctx->Driver.RenderStart = 0; + ctx->Driver.RenderPrimitive = _swsetup_RenderPrimNoop; ctx->Driver.RenderFinish = _swrast_flush; ctx->Driver.SetDrawBuffer = set_draw_buffer; diff --git a/src/mesa/drivers/x11/xm_span.c b/src/mesa/drivers/x11/xm_span.c index eb91fb329d..00c36af44c 100644 --- a/src/mesa/drivers/x11/xm_span.c +++ b/src/mesa/drivers/x11/xm_span.c @@ -1,8 +1,8 @@ -/* $Id: xm_span.c,v 1.4 2000/11/22 07:32:18 joukj Exp $ */ +/* $Id: xm_span.c,v 1.5 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index a8f953963d..8aa8a47b14 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -1,8 +1,8 @@ -/* $Id: xmesaP.h,v 1.18 2000/12/26 05:09:31 keithw Exp $ */ +/* $Id: xmesaP.h,v 1.19 2001/01/08 04:06:20 keithw Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.3 + * Version: 3.5 * * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * -- cgit v1.2.3