diff options
Diffstat (limited to 'xc/lib/GL/mesa')
-rw-r--r-- | xc/lib/GL/mesa/dri/dri_mesa.c | 142 | ||||
-rw-r--r-- | xc/lib/GL/mesa/dri/dri_mesaint.h | 23 | ||||
-rw-r--r-- | xc/lib/GL/mesa/dri/dri_xmesaapi.h | 129 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/Imakefile | 14 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/gamma/Imakefile | 1 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c | 10 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/gamma/gamma_init.h | 5 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h | 6 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c | 200 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/i810/i810_init.h | 1 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c | 243 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/i810/i810context.h | 1 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c | 251 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h | 1 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/mga/mgalib.h | 1 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h | 50 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c | 14 | ||||
-rw-r--r-- | xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c | 268 |
18 files changed, 581 insertions, 779 deletions
diff --git a/xc/lib/GL/mesa/dri/dri_mesa.c b/xc/lib/GL/mesa/dri/dri_mesa.c index ea2f05b07..b679b41a4 100644 --- a/xc/lib/GL/mesa/dri/dri_mesa.c +++ b/xc/lib/GL/mesa/dri/dri_mesa.c @@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> - * Brian Paul <brian@precisioninsight.com> + * Brian E. Paul <brian@precisioninsight.com> */ #ifdef GLX_DIRECT_RENDERING @@ -39,16 +39,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <Xext.h> #include <extutil.h> #include "glxclient.h" -#include "GL/xmesa.h" #include "xf86dri.h" #include "sarea.h" #include "dri_mesaint.h" #include "dri_xmesaapi.h" - - -#if XMESA_MAJOR_VERSION != 3 || XMESA_MINOR_VERSION != 3 -#error using wrong version of Mesa (need 3.3) -#endif +#include "../src/context.h" +#include "../src/mmath.h" /* Context binding */ @@ -109,6 +105,8 @@ static __DRIdrawable *__driMesaFindDrawable(GLXDrawable draw) return pdraw; } +#if 0 +/* not used yet */ static void __driMesaRemoveDrawable(__DRIdrawable *pdraw) { int retcode; @@ -122,23 +120,22 @@ static void __driMesaRemoveDrawable(__DRIdrawable *pdraw) drmHashDelete(drawHash, pdp->draw); } } +#endif /*****************************************************************/ -static void driMesaInitAPI(__XMESAapi *XMesaAPI) +static void driMesaInitAPI(__MesaAPI *MesaAPI) { - XMesaAPI->InitDriver = XMesaInitDriver; - XMesaAPI->ResetDriver = XMesaResetDriver; - XMesaAPI->CreateVisual = XMesaCreateVisual; - XMesaAPI->DestroyVisual = XMesaDestroyVisual; - XMesaAPI->CreateContext = XMesaCreateContext; - XMesaAPI->DestroyContext = XMesaDestroyContext; - XMesaAPI->CreateWindowBuffer = XMesaCreateWindowBuffer; - XMesaAPI->CreatePixmapBuffer = XMesaCreatePixmapBuffer; - XMesaAPI->DestroyBuffer = XMesaDestroyBuffer; - XMesaAPI->SwapBuffers = XMesaSwapBuffers; - XMesaAPI->MakeCurrent = XMesaMakeCurrent; - XMesaAPI->UnbindContext = XMesaUnbindContext; + MesaAPI->InitDriver = XMesaInitDriver; + MesaAPI->ResetDriver = XMesaResetDriver; + MesaAPI->CreateVisual = XMesaCreateVisual; + MesaAPI->CreateContext = XMesaCreateContext; + MesaAPI->DestroyContext = XMesaDestroyContext; + MesaAPI->CreateWindowBuffer = XMesaCreateWindowBuffer; + MesaAPI->CreatePixmapBuffer = XMesaCreatePixmapBuffer; + MesaAPI->SwapBuffers = XMesaSwapBuffers; + MesaAPI->MakeCurrent = XMesaMakeCurrent; + MesaAPI->UnbindContext = XMesaUnbindContext; } /*****************************************************************/ @@ -176,7 +173,7 @@ static Bool driMesaUnbindContext(Display *dpy, int scrn, } /* Unbind Mesa's drawable from Mesa's context */ - (*psp->XMesaAPI.UnbindContext)(pcp->xm_ctx); + (*psp->MesaAPI.UnbindContext)(pcp); if (pdp->refcount == 0) { /* ERROR!!! */ @@ -279,7 +276,7 @@ static Bool driMesaBindContext(Display *dpy, int scrn, } /* Bind Mesa's drawable to Mesa's context */ - (*psp->XMesaAPI.MakeCurrent)(pcp->xm_ctx, pdp->xm_buf); + (*psp->MesaAPI.MakeCurrent)(pcp, pdp, pdp); return GL_TRUE; } @@ -344,7 +341,7 @@ static void *driMesaCreateDrawable(Display *dpy, int scrn, GLXDrawable draw, __DRIscreenPrivate *psp; __DRIdrawablePrivate *pdp; int i; - XMesaVisual xm_vis = NULL; + GLvisual *mesaVis = NULL; pdp = (__DRIdrawablePrivate *)Xmalloc(sizeof(__DRIdrawablePrivate)); if (!pdp) { @@ -377,20 +374,19 @@ static void *driMesaCreateDrawable(Display *dpy, int scrn, GLXDrawable draw, for (i = 0; i < psp->numVisuals; i++) { if (vid == psp->visuals[i].vid) { - xm_vis = psp->visuals[i].xm_vis; + mesaVis = psp->visuals[i].mesaVisual; break; } } - if (1 /* NOT_DONE: Determine if it is a pixmap or not */) { - pdp->xm_buf = (*psp->XMesaAPI.CreateWindowBuffer)(xm_vis, draw, pdp); - } else { - XMesaVisual xm_vis = NULL; - XMesaColormap cmap = 0; - pdp->xm_buf = (*psp->XMesaAPI.CreatePixmapBuffer)(xm_vis, draw, cmap, - pdp); + /* XXX pixmap rendering not implemented yet */ + if (1) { + pdp->mesaBuffer = (*psp->MesaAPI.CreateWindowBuffer)(dpy, psp, pdp, mesaVis); } - if (!pdp->xm_buf) { + else { + pdp->mesaBuffer = (*psp->MesaAPI.CreatePixmapBuffer)(dpy, psp, pdp, mesaVis); + } + if (!pdp->mesaBuffer) { (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw); Xfree(pdp); return NULL; @@ -416,7 +412,7 @@ static void driMesaSwapBuffers(Display *dpy, void *private) __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)private; __DRIscreenPrivate *psp = pdp->driScreenPriv; - (*psp->XMesaAPI.SwapBuffers)(pdp->xm_buf); + (*psp->MesaAPI.SwapBuffers)(pdp); } static void driMesaDestroyDrawable(Display *dpy, void *private) @@ -426,7 +422,7 @@ static void driMesaDestroyDrawable(Display *dpy, void *private) int scrn = psp->myNum; if (pdp) { - (*psp->XMesaAPI.DestroyBuffer)(pdp->xm_buf); + gl_destroy_framebuffer(pdp->mesaBuffer); (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw); if (pdp->pClipRects) Xfree(pdp->pClipRects); @@ -441,8 +437,6 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, { __DRIcontextPrivate *pcp; __DRIcontextPrivate *pshare = (__DRIcontextPrivate *)shared; - XMesaContext shared_xm_ctx = (pshare ? - pshare->xm_ctx : (XMesaContext)NULL); __DRIscreenPrivate *psp; __DRIscreen *pDRIScreen; int i; @@ -457,7 +451,7 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, return NULL; } psp->dummyContextPriv.driScreenPriv = psp; - psp->dummyContextPriv.xm_ctx = NULL; + psp->dummyContextPriv.mesaContext = NULL; psp->dummyContextPriv.driDrawablePriv = NULL; /* No other fields should be used! */ } @@ -467,8 +461,9 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, return NULL; } + pcp->display = dpy; pcp->driScreenPriv = psp; - pcp->xm_ctx = NULL; + pcp->mesaContext = NULL; pcp->driDrawablePriv = NULL; if (!XF86DRICreateContext(dpy, vis->screen, vis->visual, @@ -477,12 +472,28 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, return NULL; } - for (i = 0; i < psp->numVisuals; i++) - if (psp->visuals[i].vid == vis->visualid) - pcp->xm_ctx = (*psp->XMesaAPI.CreateContext) - (psp->visuals[i].xm_vis, shared_xm_ctx, pcp); - - if (!pcp->xm_ctx) { + for (i = 0; i < psp->numVisuals; i++) { + if (psp->visuals[i].vid == vis->visualid) { + GLvisual *mesaVis = psp->visuals[i].mesaVisual; + GLcontext *sharedMesaCtx = pshare ? pshare->mesaContext : NULL; + pcp->mesaContext = gl_create_context(mesaVis, + sharedMesaCtx, + NULL, /* set below */ + GL_TRUE); + if (pcp->mesaContext) { + /* Driver now creates its private context data */ + if ((*psp->MesaAPI.CreateContext)(dpy, mesaVis, pcp)) { + pcp->mesaContext->DriverCtx = pcp->driverPrivate; + } + else { + gl_destroy_context(pcp->mesaContext); + pcp->mesaContext = NULL; + } + } + } + } + + if (!pcp->mesaContext) { (void)XF86DRIDestroyContext(dpy, vis->screen, pcp->contextID); Xfree(pcp); return NULL; @@ -501,7 +512,8 @@ static void driMesaDestroyContext(Display *dpy, int scrn, void *private) if (pcp) { (void)XF86DRIDestroyContext(dpy, scrn, pcp->contextID); - (*pcp->driScreenPriv->XMesaAPI.DestroyContext)(pcp->xm_ctx); + (*pcp->driScreenPriv->MesaAPI.DestroyContext)(pcp); + gl_destroy_context(pcp->mesaContext); Xfree(pcp); } } @@ -579,7 +591,7 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, return NULL; } - driMesaInitAPI(&psp->XMesaAPI); + driMesaInitAPI(&psp->MesaAPI); if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, @@ -641,27 +653,13 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, for (i = 0; i < numConfigs; i++, config++) { psp->visuals[i].vid = visinfo[i].visualid; - psp->visuals[i].xm_vis = - (*psp->XMesaAPI.CreateVisual)(dpy, - &visinfo[i], - config->rgba, - (config->alphaSize > 0), - config->doubleBuffer, - config->stereo, - GL_TRUE, /* ximage_flag */ - config->depthSize, - config->stencilSize, - config->accumRedSize, - config->accumGreenSize, - config->accumBlueSize, - config->accumAlphaSize, - 0, /* num samples */ - config->level, - GLX_NONE_EXT /* caveat */); - if (!psp->visuals[i].xm_vis) { + psp->visuals[i].mesaVisual = + (*psp->MesaAPI.CreateVisual) (dpy, psp, &visinfo[i], config); + + if (!psp->visuals[i].mesaVisual) { /* Free the visuals so far created */ while (--i >= 0) { - (*psp->XMesaAPI.DestroyVisual)(psp->visuals[i].xm_vis); + _mesa_destroy_visual(psp->visuals[i].mesaVisual); } Xfree(psp->visuals); XFree(visinfo); @@ -677,11 +675,10 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, XFree(visinfo); /* Initialize the screen specific GLX driver */ - if (psp->XMesaAPI.InitDriver) { - if (!(*psp->XMesaAPI.InitDriver)(psp)) { + if (psp->MesaAPI.InitDriver) { + if (!(*psp->MesaAPI.InitDriver)(psp)) { while (--psp->numVisuals >= 0) { - (*psp->XMesaAPI.DestroyVisual) - (psp->visuals[psp->numVisuals].xm_vis); + _mesa_destroy_visual(psp->visuals[psp->numVisuals].mesaVisual); } Xfree(psp->visuals); (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); @@ -718,11 +715,10 @@ static void driMesaDestroyScreen(Display *dpy, int scrn, void *private) (void)XF86DRIDestroyContext(dpy, scrn, psp->dummyContextPriv.contextID); } - if (psp->XMesaAPI.ResetDriver) - (*psp->XMesaAPI.ResetDriver)(psp); + if (psp->MesaAPI.ResetDriver) + (*psp->MesaAPI.ResetDriver)(psp); while (--psp->numVisuals >= 0) { - (*psp->XMesaAPI.DestroyVisual) - (psp->visuals[psp->numVisuals].xm_vis); + _mesa_destroy_visual(psp->visuals[psp->numVisuals].mesaVisual); } Xfree(psp->visuals); (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); diff --git a/xc/lib/GL/mesa/dri/dri_mesaint.h b/xc/lib/GL/mesa/dri/dri_mesaint.h index 16c483f01..e8918724c 100644 --- a/xc/lib/GL/mesa/dri/dri_mesaint.h +++ b/xc/lib/GL/mesa/dri/dri_mesaint.h @@ -29,6 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> + * Brian E. Paul <brian@precisioninsight.com> * */ @@ -40,10 +41,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <GL/glx.h> #include "xf86dri.h" #include "sarea.h" -#include "GL/xmesa.h" #include "dri_mesa.h" #include "dri_xmesaapi.h" + #define DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy,scrn,pDrawPriv) \ do { \ if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \ @@ -59,9 +60,9 @@ struct __DRIdrawablePrivateRec { drmDrawable hHWDrawable; /* - ** Mesa's private context information. This structure is opaque. + ** Mesa's private frame buffer information. This structure is opaque. */ - XMesaBuffer xm_buf; + GLframebuffer *mesaBuffer; /* ** X's drawable ID associated with this private drawable. @@ -138,7 +139,17 @@ struct __DRIcontextPrivateRec { /* ** Mesa's private context information. This structure is opaque. */ - XMesaContext xm_ctx; + GLcontext *mesaContext; + + /* + ** Device driver's private context data. This structure is opaque. + */ + void *driverPrivate; + + /* + ** This context's display pointer. + */ + Display *display; /* ** Pointer to drawable currently bound to this context. @@ -155,7 +166,7 @@ struct __DRIvisualPrivateRec { /* ** Mesa's private visual information. This structure is opaque. */ - XMesaVisual xm_vis; + GLvisual *mesaVisual; /* ** X's visual ID associated with this private visual. @@ -179,7 +190,7 @@ struct __DRIscreenPrivateRec { /* ** Function pointers associated with Mesa's GLX functions. */ - __XMESAapi XMesaAPI; + __MesaAPI MesaAPI; /* ** Core rendering library's driver version information. diff --git a/xc/lib/GL/mesa/dri/dri_xmesaapi.h b/xc/lib/GL/mesa/dri/dri_xmesaapi.h index 19aa95d58..54f22df70 100644 --- a/xc/lib/GL/mesa/dri/dri_xmesaapi.h +++ b/xc/lib/GL/mesa/dri/dri_xmesaapi.h @@ -29,53 +29,110 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> - * + * Brian E. Paul <brian@precisioninsight.com> */ + #ifndef _DRI_XMESAAPI_H_ #define _DRI_XMESAAPI_H_ -#ifdef GLX_DIRECT_RENDERING - -#include "GL/xmesa.h" +#include "glxclient.h" #include "dri_mesa.h" +#include "../src/types.h" + + +extern GLboolean XMesaInitDriver( __DRIscreenPrivate *driScrnPriv ); + +extern void XMesaResetDriver( __DRIscreenPrivate *driScrnPriv ); + +/* Driver creates a GLvisual and returns pointer to it. + */ +extern GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config); + +/* Driver creates its private context struct and hooks it into + * the driContextPriv->driverPrivate field. Return true/false for + * success/error. + */ +extern GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ); + +/* Driver frees data attached to driContextPriv->driverPrivate pointer. + */ +extern void XMesaDestroyContext( __DRIcontextPrivate *driContextPriv ); + +/* Driver creates a GLframebuffer struct indicating which ancillary + * buffers are in hardware or software. + */ +extern GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis); -typedef struct __XMESAapiRec __XMESAapi; +extern GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis); -struct __XMESAapiRec { +extern GLboolean XMesaMakeCurrent( __DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv ); + +extern GLboolean XMesaUnbindContext( __DRIcontextPrivate *driContextPriv ); + +extern void XMesaSwapBuffers( __DRIdrawablePrivate *driDrawPriv ); + + + + + +#define XMESA_VALIDATE_DRAWABLE_INFO(dpy, psp, pdp) \ +do { \ + while (*(pdp->pStamp) != pdp->lastStamp) { \ + DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, \ + pdp->driContextPriv->hHWContext); \ + \ + DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ + DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy, psp->myNum, pdp); \ + DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ + \ + DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, \ + pdp->driContextPriv->hHWContext); \ + } \ +} while (0) + + + +typedef struct __MesaAPIRec __MesaAPI; + +struct __MesaAPIRec { /* XMESA Functions */ GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv); void (*ResetDriver)(__DRIscreenPrivate *driScrnPriv); - XMesaVisual (*CreateVisual)(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ); - void (*DestroyVisual)(XMesaVisual v); - XMesaContext (*CreateContext)(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv); - void (*DestroyContext)(XMesaContext c); - XMesaBuffer (*CreateWindowBuffer)(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv); - XMesaBuffer (*CreatePixmapBuffer)(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv); - void (*DestroyBuffer)(XMesaBuffer b); - void (*SwapBuffers)(XMesaBuffer b); - GLboolean (*MakeCurrent)(XMesaContext c, XMesaBuffer b); - GLboolean (*UnbindContext)(XMesaContext c); + GLvisual * (*CreateVisual)(Display *display, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config); + GLboolean (*CreateContext)(Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv); + void (*DestroyContext)(__DRIcontextPrivate *driContextPriv); + GLframebuffer * (*CreateWindowBuffer)(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis); + GLframebuffer * (*CreatePixmapBuffer)(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis); + void (*SwapBuffers)(__DRIdrawablePrivate *driDrawPriv); + GLboolean (*MakeCurrent)(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv); + GLboolean (*UnbindContext)(__DRIcontextPrivate *driContextPriv); }; -#endif + + #endif /* _DRI_XMESAAPI_H_ */ diff --git a/xc/lib/GL/mesa/src/Imakefile b/xc/lib/GL/mesa/src/Imakefile index 386b58c69..5917f81b7 100644 --- a/xc/lib/GL/mesa/src/Imakefile +++ b/xc/lib/GL/mesa/src/Imakefile @@ -364,9 +364,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) #endif #if GlxBuiltInMesa || GlxDriverUsesMesa || !GlxUseBuiltInDRIDriver -# We have to go into X to make the xmesaP.h symbolic link - MESASUBDIRS = X - + MESASUBDIRS = ASMSUBDIRS = X86 #include <Library.tmpl> @@ -384,14 +382,4 @@ SUBDIRS = $(MESASUBDIRS) $(ASMSUBDIRS) drv MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) - -XCOMM #if !GlxUseBuiltInDRIDriver && !GlxDriverUsesMesa -#if 0 -LIBNAME = mesa_dri.so -ALL_OBJS = $(CORE_OBJS) X/?*.o X86/?*.o -ALL_DEPS = $(SUBDIRS) DONE X/DONE X86/DONE -SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) -InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.) -#endif - DependTarget() diff --git a/xc/lib/GL/mesa/src/drv/gamma/Imakefile b/xc/lib/GL/mesa/src/drv/gamma/Imakefile index d55eeb64b..71db46e19 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/Imakefile +++ b/xc/lib/GL/mesa/src/drv/gamma/Imakefile @@ -7,7 +7,6 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.8 2000/03/02 16:07:35 #define DoDebugLib DebugLibGlx #define DoProfileLib ProfileLibGlx -LinkSourceFile(xmesaP.h, ../../../../../../extras/Mesa/src/X) LinkSourceFile(glapi.h, ../../../../../../extras/Mesa/src) diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c index 3bd2fd0f3..17644089d 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c @@ -361,7 +361,7 @@ void _gamma_Clear(GLbitfield mask) unsigned int depth = 0; int do_clear = 0; #ifdef DO_VALIDATE - __DRIscreenPrivate *driScrnPriv = gCC->driContextPriv->driScreenPriv; + __DRIscreenPrivate *driScrnPriv = gCC->driScreenPriv; #endif DEBUG_GLCMDS(("Clear: %04x\n", (int)mask)); @@ -3280,10 +3280,10 @@ void _gamma_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) DEBUG_GLCMDS(("Viewport: %d %d %d %d\n", (int)x, (int)y, (int)width, (int)height)); - gCCPriv->x = gCC->driContextPriv->driDrawablePriv->x + x; - gCCPriv->y = gCC->driContextPriv->driScreenPriv->fbHeight - - (gCC->driContextPriv->driDrawablePriv->y + - gCC->driContextPriv->driDrawablePriv->h) + y; + gCCPriv->x = gCC->driDrawablePriv->x + x; + gCCPriv->y = gCC->driScreenPriv->fbHeight - + (gCC->driDrawablePriv->y + + gCC->driDrawablePriv->h) + y; gCCPriv->w = width; gCCPriv->h = height; diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h index ce804d018..3e2b14a0b 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h @@ -43,7 +43,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "gamma_regs.h" #include "gamma_macros.h" #include "gamma_texture.h" -#include "xmesaP.h" typedef struct { int regionCount; /* Count of register regions */ @@ -140,8 +139,8 @@ extern void gammaLoadHWMatrix(void); extern void gammaInitHW(gammaContextPrivate *gcp); extern float IdentityMatrix[16]; -extern XMesaContext nullCC; -extern XMesaContext gCC; +extern __DRIcontextPrivate *nullCC; +extern __DRIcontextPrivate *gCC; extern gammaContextPrivate *gCCPriv; #endif diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h index ae923c7bf..c458bf642 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h @@ -228,14 +228,14 @@ do { \ #ifdef DO_VALIDATE #define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcc,gcp) \ do { \ - __DRIcontextPrivate *pcp = gcc->driContextPriv; \ + __DRIcontextPrivate *pcp = gcc; \ __DRIscreenPrivate *psp = pcp->driScreenPriv; \ __DRIdrawablePrivate *pdp = pcp->driDrawablePriv; \ \ if (*(pdp->pStamp) != pdp->lastStamp) { \ int old_index = pdp->index; \ while (*(pdp->pStamp) != pdp->lastStamp) { \ - DRI_MESA_VALIDATE_DRAWABLE_INFO(gcc->display, psp->myNum, pdp);\ + DRI_MESA_VALIDATE_DRAWABLE_INFO(pcp->display, psp->myNum, pdp);\ } \ \ if (pdp->index != old_index) { \ @@ -303,7 +303,7 @@ do { \ #define VALIDATE_DRAWABLE_INFO(gcc,gcp) \ do { \ - __DRIcontextPrivate *pcp = gcc->driContextPriv; \ + __DRIcontextPrivate *pcp = gcc; \ __DRIscreenPrivate *psp = pcp->driScreenPriv; \ \ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \ diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c index e0415cf9b..1b6cf6141 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c @@ -39,24 +39,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "gamma_gl.h" #include "glapi.h" #include "context.h" +#include "mmath.h" -XMesaContext nullCC = NULL; -XMesaContext gCC = NULL; +__DRIcontextPrivate *nullCC = NULL; +__DRIcontextPrivate *gCC = NULL; gammaContextPrivate *gCCPriv = NULL; static struct _glapi_table *Dispatch = NULL; -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv) { @@ -85,82 +76,37 @@ void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv) Xfree(driScrnPriv->private); } -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - XMesaVisual v; - - /* Only RGB visuals are supported on the GMX2000 */ - if (!rgb_flag) { - return NULL; - } - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) { - return NULL; - } - - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return NULL; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - v->VisualCaveat = visualCaveat; - v->gl_visual = _mesa_create_visual(rgb_flag, - GL_FALSE, /* alpha flag */ - db_flag, stereo_flag, - count_bits(visinfo->red_mask), - count_bits(visinfo->green_mask), - count_bits(visinfo->blue_mask), - 0, /* alpha bits */ - 0, /* index bits */ - depth_size, - stencil_size, - accum_red_size, - accum_green_size, - accum_blue_size, - accum_alpha_size, - 0 /* num samples */ ); - - if (!v->gl_visual) { - XFree(v); - return NULL; - } - else { - return v; - } + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -void XMesaDestroyVisual(XMesaVisual v) -{ - Xfree(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); -} -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) +GLboolean XMesaCreateContext( Display *dpy, + GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ) { int i; - XMesaContext c; gammaContextPrivate *cPriv; __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; gammaScreenPrivate *gPriv = (gammaScreenPrivate *)driScrnPriv->private; @@ -171,20 +117,9 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, _gamma_init_dispatch(Dispatch); } - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) { - return NULL; - } - - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = NULL; /* Set by MakeCurrent */ - c->display = v->display; - cPriv = (gammaContextPrivate *)Xmalloc(sizeof(gammaContextPrivate)); if (!cPriv) { - Xfree(c); - return NULL; + return GL_FALSE; } cPriv->hHWContext = driContextPriv->hHWContext; @@ -347,17 +282,17 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, #ifdef FORCE_DEPTH32 cPriv->DepthSize = 32; #else - cPriv->DepthSize = v->gl_visual->DepthBits; + cPriv->DepthSize = mesaVis->DepthBits; #endif cPriv->zNear = 0.0; cPriv->zFar = 1.0; cPriv->Flags = GAMMA_FRONT_BUFFER; - cPriv->Flags |= (v->gl_visual->DBflag ? GAMMA_BACK_BUFFER : 0); + cPriv->Flags |= (mesaVis->DBflag ? GAMMA_BACK_BUFFER : 0); cPriv->Flags |= (cPriv->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0); cPriv->EnabledFlags = GAMMA_FRONT_BUFFER; - cPriv->EnabledFlags |= (v->gl_visual->DBflag ? GAMMA_BACK_BUFFER : 0); + cPriv->EnabledFlags |= (mesaVis->DBflag ? GAMMA_BACK_BUFFER : 0); cPriv->DepthMode = (DepthModeDisable | DM_WriteMask | @@ -383,36 +318,60 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, cPriv->gammaScrnPriv = gPriv; - c->private = (void *)cPriv; + driContextPriv->driverPrivate = cPriv; /* Initialize the HW to a known state */ gammaInitHW(cPriv); - return c; + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { + gammaContextPrivate *cPriv; + cPriv = (gammaContextPrivate *) driContextPriv->driverPrivate; + if (cPriv) { + /* XXX free driver context data? */ + } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer b) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { /* ** NOT_DONE: This assumes buffer is currently bound to a context. @@ -429,11 +388,9 @@ void XMesaSwapBuffers(XMesaBuffer b) if (gCCPriv->EnabledFlags & GAMMA_BACK_BUFFER) { int src, dst, x0, y0, x1, h; int i; - __DRIdrawablePrivate *driDrawPriv = - gCC->driContextPriv->driDrawablePriv; int nRect = driDrawPriv->numClipRects; XF86DRIClipRectPtr pRect = driDrawPriv->pClipRects; - __DRIscreenPrivate *driScrnPriv = gCC->driContextPriv->driScreenPriv; + __DRIscreenPrivate *driScrnPriv = gCC->driScreenPriv; #ifdef DO_VALIDATE DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock, @@ -496,14 +453,17 @@ void XMesaSwapBuffers(XMesaBuffer b) } } -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { - if (c) { - gCC = c; - gCCPriv = (gammaContextPrivate *)c->private; + + if (driContextPriv) { + gCC = driContextPriv; + gCCPriv = (gammaContextPrivate *) driContextPriv->driverPrivate; gCCPriv->Window &= ~W_GIDMask; - gCCPriv->Window |= (gCC->driContextPriv->driDrawablePriv->index << 5); + gCCPriv->Window |= (driDrawPriv->index << 5); CHECK_DMA_BUFFER(gCC, gCCPriv, 1); WRITE(gCCPriv->buf, GLINTWindow, gCCPriv->Window); @@ -517,7 +477,7 @@ GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) } -GLboolean XMesaUnbindContext( XMesaContext c ) +GLboolean XMesaUnbindContext( __DRIcontextPrivate *driContextPriv ) { /* XXX not 100% sure what's supposed to be done here */ return GL_TRUE; diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_init.h b/xc/lib/GL/mesa/src/drv/i810/i810_init.h index 804f66889..df5362787 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810_init.h +++ b/xc/lib/GL/mesa/src/drv/i810/i810_init.h @@ -41,7 +41,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri_mesaint.h" #include "dri_mesa.h" #include "types.h" -#include "xmesaP.h" typedef struct { drmHandle handle; diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c index 18976a23e..4cdbe4c7a 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c @@ -76,38 +76,6 @@ static i810ContextPtr i810Ctx = 0; i810Glx_t i810glx; -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} - -/* These functions are accessed by dlsym from dri_mesa_init.c: - * - * XMesaInitDriver - * XMesaResetDriver - * XMesaCreateVisual - * XMesaDestroyVisual - * XMesaCreateContext - * XMesaDestroyContext - * XMesaCreateWindowBuffer - * XMesaCreatePixmapBuffer - * XMesaDestroyBuffer - * XMesaSwapBuffers - * XMesaMakeCurrent - * - * So this is kind of the public interface to the driver. The driver - * uses the X11 mesa driver context as a kind of wrapper around its - * own driver context - but there isn't much justificiation for doing - * it that way - the DRI might as well use a (void *) to refer to the - * driver contexts. Nothing in the X context really gets used. - */ - GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { @@ -211,111 +179,48 @@ void XMesaResetDriver(__DRIscreenPrivate *sPriv) Xfree(i810Screen); } -/* Accessed by dlsym from dri_mesa_init.c - */ -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ) -{ - XMesaVisual v; - - /* Only RGB visuals are supported on the I810 boards */ - if (!rgb_flag) return 0; - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return 0; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - v->VisualCaveat = visualCaveat; - v->gl_visual = _mesa_create_visual(rgb_flag, - GL_FALSE, /* alpha flag */ - db_flag, - stereo_flag, - count_bits(visinfo->red_mask), - count_bits(visinfo->green_mask), - count_bits(visinfo->blue_mask), - 0, /* alpha bits */ - 0, /* index bits */ - depth_size, - stencil_size, - accum_red_size, - accum_green_size, - accum_blue_size, - accum_alpha_size, - 0 /* num samples */ ); - if (!v->gl_visual) { - Xfree(v->visinfo); - Xfree(v); - return NULL; - } - else - return v; -} - -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - _mesa_destroy_visual(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ) { - GLcontext *ctx; - XMesaContext c; + GLcontext *ctx = driContextPriv->mesaContext; i810ContextPtr imesa; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private; drm_i810_sarea_t *saPriv=(drm_i810_sarea_t *)(((char*)sPriv->pSAREA)+ sizeof(XF86DRISAREARec)); - GLcontext *shareCtx = 0; - - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) { - return 0; - } - imesa = (i810ContextPtr)Xcalloc(sizeof(i810Context), 1); if (!imesa) { - Xfree(c); - return 0; + return GL_FALSE; } - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = 0; /* Set by MakeCurrent */ - c->display = v->display; - c->private = (void *)imesa; - - if (share_list) - shareCtx=((i810ContextPtr)(share_list->private))->glCtx; - - ctx = imesa->glCtx = gl_create_context(v->gl_visual, shareCtx, - (void*)imesa, GL_TRUE); - /* Set the maximum texture size small enough that we can guarentee * that both texture units can bind a maximal texture and have them @@ -335,7 +240,7 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, /* Dri stuff */ - imesa->display = v->display; + imesa->display = dpy; imesa->hHWContext = driContextPriv->hHWContext; imesa->driFd = sPriv->fd; imesa->driHwLock = &sPriv->pSAREA->lock; @@ -343,13 +248,7 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, imesa->i810Screen = i810Screen; imesa->driScreen = sPriv; imesa->sarea = saPriv; - - imesa->glBuffer = gl_create_framebuffer(v->gl_visual, - GL_FALSE, - v->gl_visual->StencilBits > 0, - v->gl_visual->AccumRedBits > 0, - v->gl_visual->AlphaBits > 0); - + imesa->glBuffer = NULL; imesa->texHeap = mmInit( 0, i810Screen->textureSize ); @@ -366,6 +265,9 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, imesa->TextureMode = ctx->Texture.Unit[0].EnvMode; imesa->CurrentTexObj[0] = 0; imesa->CurrentTexObj[1] = 0; + + ctx->DriverCtx = (void *) imesa; + imesa->glCtx = ctx; i810DDExtensionsInit( ctx ); @@ -398,18 +300,19 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, i810DDInitState( imesa ); - return c; + driContextPriv->driverPrivate = (void *) imesa; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { - i810ContextPtr imesa = (i810ContextPtr) c->private; + i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate; if (imesa) { i810TextureObjectPtr next_t, t; gl_destroy_context(imesa->glCtx); - gl_destroy_framebuffer(imesa->glBuffer); foreach_s (t, next_t, &(imesa->TexObjList)) i810DestroyTexObj(imesa, t); @@ -418,30 +321,47 @@ void XMesaDestroyContext(XMesaContext c) i810DestroyTexObj(imesa, t); Xfree(imesa); - - c->private = 0; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -void XMesaDestroyBuffer(XMesaBuffer b) +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer bogus) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { + /* XXX should do swap according to the buffer, not the context! */ i810ContextPtr imesa = i810Ctx; FLUSH_VB( imesa->glCtx, "swap buffers" ); @@ -542,10 +462,11 @@ static void i810XMesaWindowMoved( i810ContextPtr imesa ) } -GLboolean XMesaUnbindContext(XMesaContext c) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { - if (c->private) - ((i810ContextPtr)c->private)->dirty = ~0; + i810ContextPtr i810 = (i810ContextPtr) driContextPriv->driverPrivate; + if (i810) + i810->dirty = ~0; return GL_TRUE; } @@ -555,27 +476,25 @@ GLboolean XMesaUnbindContext(XMesaContext c) * Hmm - It seems that the drawable is already hooked in to * driDrawablePriv. */ -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { + if (driContextPriv) { + i810Ctx = (i810ContextPtr) driContextPriv->driverPrivate; - if (c->private==(void *)i810Ctx) return GL_TRUE; + gl_make_current2(i810Ctx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); - if (c) { - __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv; - - i810Ctx = (i810ContextPtr)c->private; - - gl_make_current(i810Ctx->glCtx, i810Ctx->glBuffer); - - i810Ctx->driDrawable = dPriv; + i810Ctx->driDrawable = driDrawPriv; i810Ctx->dirty = ~0; i810XMesaWindowMoved( i810Ctx ); if (!i810Ctx->glCtx->Viewport.Width) - gl_Viewport(i810Ctx->glCtx, 0, 0, dPriv->w, dPriv->h); + gl_Viewport(i810Ctx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); - } else { + } + else { gl_make_current(0,0); i810Ctx = NULL; } diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.h b/xc/lib/GL/mesa/src/drv/i810/i810context.h index 6a7ffa968..c3458e4fa 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810context.h +++ b/xc/lib/GL/mesa/src/drv/i810/i810context.h @@ -33,7 +33,6 @@ typedef struct i810_context_t *i810ContextPtr; #include "dri_tmm.h" #include "dri_mesaint.h" #include "dri_mesa.h" -#include "xmesaP.h" #include "types.h" #include "i810_init.h" diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c index 985ae7ca2..b3eaa6376 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c @@ -41,6 +41,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "context.h" #include "vbxform.h" #include "matrix.h" +#include "mmath.h" #include "simple_list.h" #include "mgadd.h" @@ -77,38 +78,6 @@ static mgaContextPtr mgaCtx = 0; mgaGlx_t mgaglx; -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} - -/* These functions are accessed by dlsym from dri_mesa_init.c: - * - * XMesaInitDriver - * XMesaResetDriver - * XMesaCreateVisual - * XMesaDestroyVisual - * XMesaCreateContext - * XMesaDestroyContext - * XMesaCreateWindowBuffer - * XMesaCreatePixmapBuffer - * XMesaDestroyBuffer - * XMesaSwapBuffers - * XMesaMakeCurrent - * - * So this is kind of the public interface to the driver. The driver - * uses the X11 mesa driver context as a kind of wrapper around its - * own driver context - but there isn't much justificiation for doing - * it that way - the DRI might as well use a (void *) to refer to the - * driver contexts. Nothing in the X context really gets used. - */ - GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { @@ -209,114 +178,53 @@ void XMesaResetDriver(__DRIscreenPrivate *sPriv) Xfree(sPriv->private); } -/* Accessed by dlsym from dri_mesa_init.c - */ -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ) -{ - XMesaVisual v; - - /* Only RGB visuals are supported on the MGA boards */ - if (!rgb_flag) return 0; - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; - - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return 0; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - v->VisualCaveat = visualCaveat; - v->gl_visual = _mesa_create_visual(rgb_flag, - GL_FALSE, /* alpha flag */ - db_flag, - stereo_flag, - count_bits(visinfo->red_mask), - count_bits(visinfo->green_mask), - count_bits(visinfo->blue_mask), - 0, /* alpha bits */ - 0, /* index bits */ - depth_size, - stencil_size, - accum_red_size, - accum_green_size, - accum_blue_size, - accum_alpha_size, - 0 /* num samples */ ); - if (!v->gl_visual) { - Xfree(v->visinfo); - Xfree(v); - return NULL; - } - else - return v; -} -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - _mesa_destroy_visual(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ) { int i; GLcontext *ctx; - XMesaContext c; mgaContextPtr mmesa; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private; drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+ sizeof(XF86DRISAREARec)); - GLcontext *shareCtx = 0; - /*fprintf(stderr, "XMesaCreateContext\n");*/ - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) { - return 0; - } - mmesa = (mgaContextPtr)Xcalloc(sizeof(mgaContext), 1); if (!mmesa) { - Xfree(c); - return 0; + return GL_FALSE; } - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = 0; /* Set by MakeCurrent */ - c->display = v->display; - c->private = (void *)mmesa; + ctx = driContextPriv->mesaContext; - if (share_list) - shareCtx=((mgaContextPtr)(share_list->private))->glCtx; - - ctx = mmesa->glCtx = gl_create_context(v->gl_visual, shareCtx, - (void*)mmesa, GL_TRUE); - - mmesa->display = v->display; + mmesa->display = dpy; mmesa->hHWContext = driContextPriv->hHWContext; mmesa->driFd = sPriv->fd; mmesa->driHwLock = &sPriv->pSAREA->lock; @@ -324,13 +232,7 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, mmesa->mgaScreen = mgaScreen; mmesa->driScreen = sPriv; mmesa->sarea = saPriv; - - mmesa->glBuffer=gl_create_framebuffer(v->gl_visual, - GL_FALSE, /* software depth buffer? */ - v->gl_visual->StencilBits > 0, - v->gl_visual->AccumRedBits > 0, - v->gl_visual->AlphaBits > 0); - + mmesa->glBuffer = NULL; make_empty_list(&mmesa->SwappedOut); @@ -351,6 +253,8 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, mmesa->texAge[0] = 0; mmesa->texAge[1] = 0; + ctx->DriverCtx = (void *) mmesa; + mmesa->glCtx = ctx; mgaDDExtensionsInit( ctx ); @@ -384,19 +288,18 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, mgaInitState( mmesa ); - return c; + driContextPriv->driverPrivate = (void *) mmesa; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { - mgaContextPtr mmesa = (mgaContextPtr) c->private; + mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; if (mmesa) { /* mgaTextureObjectPtr next_t, t; */ - gl_destroy_context(mmesa->glCtx); - gl_destroy_framebuffer(mmesa->glBuffer); - /* foreach_s (t, next_t, &(mmesa->TexObjList)) */ /* mgaDestroyTexObj(mmesa, t); */ @@ -405,41 +308,60 @@ void XMesaDestroyContext(XMesaContext c) Xfree(mmesa); - c->private = 0; + driContextPriv->driverPrivate = NULL; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer bogus_value_do_not_use) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { + /* XXX should do swap according to the buffer, not the context! */ mgaContextPtr mmesa = mgaCtx; FLUSH_VB( mmesa->glCtx, "swap buffers" ); mgaSwapBuffers(mmesa); } - - -GLboolean XMesaUnbindContext(XMesaContext c) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { - if (c->private) - ((mgaContextPtr)c->private)->dirty = ~0; + mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; + if (mmesa) + mmesa->dirty = ~0; return GL_TRUE; } @@ -451,27 +373,24 @@ GLboolean XMesaUnbindContext(XMesaContext c) * * But why are we doing context initialization here??? */ -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { + if (driContextPriv) { + mgaCtx = (mgaContextPtr) driContextPriv->driverPrivate; - if (c->private==(void *)mgaCtx) return GL_TRUE; - - if (c) { - __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv; - - mgaCtx = (mgaContextPtr)c->private; - + gl_make_current2(mgaCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); - gl_make_current(mgaCtx->glCtx, mgaCtx->glBuffer); - - mgaCtx->driDrawable = dPriv; + mgaCtx->driDrawable = driDrawPriv; mgaCtx->dirty = ~0; mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); if (!mgaCtx->glCtx->Viewport.Width) - gl_Viewport(mgaCtx->glCtx, 0, 0, dPriv->w, dPriv->h); + gl_Viewport(mgaCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); - } else { + } + else { gl_make_current(0,0); mgaCtx = NULL; } @@ -513,8 +432,4 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) } - - - - #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h index 1379f48d9..0e0378b64 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h @@ -41,7 +41,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri_mesaint.h" #include "dri_mesa.h" #include "types.h" -#include "xmesaP.h" #include "mgaregs.h" typedef struct { diff --git a/xc/lib/GL/mesa/src/drv/mga/mgalib.h b/xc/lib/GL/mesa/src/drv/mga/mgalib.h index 176c126bd..6459a3353 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgalib.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgalib.h @@ -32,7 +32,6 @@ #include "dri_tmm.h" #include "dri_mesaint.h" #include "dri_mesa.h" -#include "xmesaP.h" #include "types.h" diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h index 3759512ee..251992d00 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_init.h @@ -41,9 +41,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "dri_tmm.h" #include "dri_mesaint.h" #include "dri_mesa.h" -#include "types.h" -#include "xmesaP.h" -/* #include "fxdrv.h" */ +#include "dri_xmesaapi.h" + typedef struct { drmHandle handle; @@ -98,7 +97,8 @@ typedef struct tfxMesaContext tdfxContextPrivate; extern GLboolean tdfxMapAllRegions(__DRIscreenPrivate *driScrnPriv); extern void tdfxUnmapAllRegions(__DRIscreenPrivate *driScrnPriv); -extern GLboolean tdfxInitHW(XMesaContext c); +extern GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPrivate, + tdfxContextPrivate *cPriv); extern void XMesaWindowMoved(void); extern void XMesaUpdateState(int windowMoved); @@ -119,8 +119,8 @@ extern void grDRIImportFifo(int fifoPtr, int fifoRead); extern void grDRIInvalidateAll(void); extern void grDRIResetSAREA(void); -extern XMesaContext gCC; -extern tdfxContextPrivate *gCCPriv; +extern __DRIcontextPrivate *gCC; +/*000extern tdfxContextPrivate *gCCPriv;*/ /* You can turn this on to find locking conflicts. #define DEBUG_LOCKING @@ -167,7 +167,7 @@ extern int prevLockLine; #define LOCK_HARDWARE() \ do { \ char __ret=0; \ - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ DEBUG_CHECK_LOCK(); \ DRM_CAS(&sPriv->pSAREA->lock, dPriv->driContextPriv->hHWContext, \ @@ -186,7 +186,7 @@ extern int prevLockLine; /* Unlock the hardware using the global current context */ #define UNLOCK_HARDWARE() \ do { \ - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; \ XMesaSetSAREA(); \ DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, \ @@ -202,24 +202,26 @@ extern int prevLockLine; so it is not self contained and doesn't have the nice single statement semantics of most macros */ -#define BEGIN_CLIP_LOOP() \ - do { \ - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; \ - int _nc; \ - LOCK_HARDWARE(); \ - _nc = dPriv->numClipRects; \ - while (_nc--) { \ - if (gCCPriv->needClip) { \ - gCCPriv->clipMinX=dPriv->pClipRects[_nc].x1; \ - gCCPriv->clipMaxX=dPriv->pClipRects[_nc].x2; \ - gCCPriv->clipMinY=dPriv->pClipRects[_nc].y1; \ - gCCPriv->clipMaxY=dPriv->pClipRects[_nc].y2; \ - fxSetScissorValues(gCCPriv->glCtx); \ +#define BEGIN_CLIP_LOOP() \ + do { \ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; \ + int _nc; \ + LOCK_HARDWARE(); \ + _nc = dPriv->numClipRects; \ + while (_nc--) { \ + tdfxContextPrivate *gCCPriv = \ + (tdfxContextPrivate *) gCC->driverPrivate; \ + if (gCCPriv->needClip) { \ + gCCPriv->clipMinX=dPriv->pClipRects[_nc].x1; \ + gCCPriv->clipMaxX=dPriv->pClipRects[_nc].x2; \ + gCCPriv->clipMinY=dPriv->pClipRects[_nc].y1; \ + gCCPriv->clipMaxY=dPriv->pClipRects[_nc].y2; \ + fxSetScissorValues(gCCPriv->glCtx); \ } -#define END_CLIP_LOOP() \ - } \ - UNLOCK_HARDWARE(); \ +#define END_CLIP_LOOP() \ + } \ + UNLOCK_HARDWARE(); \ } while (0) #endif diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c index a225fec89..7d74318e1 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c @@ -36,13 +36,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tdfx_init.h" #include <glide.h> -GLboolean tdfxInitHW(XMesaContext c) +GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPriv, + tdfxContextPrivate *fxMesa) { /* KW: Would be nice to make one of these a member of the other. */ - tdfxContextPrivate *cPriv = (tdfxContextPrivate*)c->private; - tdfxContextPrivate *fxMesa = cPriv; - __DRIdrawablePrivate *driDrawPriv = c->driContextPriv->driDrawablePriv; __DRIscreenPrivate *driScrnPriv = driDrawPriv->driScreenPriv; tdfxScreenPrivate *sPriv = (tdfxScreenPrivate*)driScrnPriv->private; @@ -50,10 +48,10 @@ GLboolean tdfxInitHW(XMesaContext c) fprintf(stderr, "Debug locking enabled\n"); #endif - if (cPriv->initDone) return GL_TRUE; + if (fxMesa->initDone) return GL_TRUE; - cPriv->width=driDrawPriv->w; - cPriv->height=driDrawPriv->h; + fxMesa->width=driDrawPriv->w; + fxMesa->height=driDrawPriv->h; /* We have to use a light lock here, because we can't do any glide operations yet. No use of FX_* functions in this function. */ @@ -95,7 +93,7 @@ GLboolean tdfxInitHW(XMesaContext c) fxInitPixelTables(fxMesa, GL_FALSE); /* Load tables of pixel colors */ - cPriv->initDone=GL_TRUE; + fxMesa->initDone=GL_TRUE; return GL_TRUE; } diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c index 0581d7cc8..e99c57a07 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c @@ -28,7 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Daryll Strauss <daryll@precisioninsight.com> - * + * Brian E. Paul <brian@precisioninsight.com> */ #ifdef GLX_DIRECT_RENDERING @@ -37,23 +37,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <glide.h> #include "tdfx_init.h" #include "context.h" -#include "vbxform.h" #include "matrix.h" +#include "mmath.h" +#include "vbxform.h" -XMesaContext nullCC = 0; -XMesaContext gCC = 0; -tdfxContextPrivate *gCCPriv = 0; -static int count_bits(unsigned int n) -{ - int bits = 0; +__DRIcontextPrivate *gCC = 0; - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv) { @@ -81,120 +71,54 @@ void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv) Xfree(driScrnPriv->private); } -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ) -{ - XMesaVisual v; - /* Only RGB visuals are supported on the TDFX boards */ - if (!rgb_flag) return 0; - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; - - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return 0; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - v->VisualCaveat = visualCaveat; - v->gl_visual = _mesa_create_visual(rgb_flag, - GL_FALSE, /* alpha flag */ - db_flag, - stereo_flag, - count_bits(visinfo->red_mask), - count_bits(visinfo->green_mask), - count_bits(visinfo->blue_mask), - 0, /* alpha bits */ - 0, /* index bits */ - depth_size, - stencil_size, - accum_red_size, - accum_green_size, - accum_blue_size, - accum_alpha_size, - 0 /* num samples */ ); - if (!v->gl_visual) { - Xfree(v->visinfo); - Xfree(v); - return NULL; - } - else - return v; -} - -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - _mesa_destroy_visual(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv) { - XMesaContext c; tdfxContextPrivate *cPriv; __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; tdfxScreenPrivate *sPriv = (tdfxScreenPrivate *)driScrnPriv->private; TDFXSAREAPriv *saPriv; - GLcontext *shareCtx; /*int **fifoPtr;*/ - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) return 0; - - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = 0; /* Set by MakeCurrent */ - c->display = v->display; - cPriv = (tdfxContextPrivate *)Xmalloc(sizeof(tdfxContextPrivate)); if (!cPriv) { - Xfree(c); - return NULL; + return GL_FALSE; } cPriv->hHWContext = driContextPriv->hHWContext; cPriv->tdfxScrnPriv = sPriv; - c->private = (void *)cPriv; - - cPriv->glVis=v->gl_visual; - cPriv->glBuffer=gl_create_framebuffer(v->gl_visual, - GL_FALSE, /* software depth buffer? */ - v->gl_visual->StencilBits > 0, - v->gl_visual->AccumRedBits > 0, - v->gl_visual->AlphaBits > 0 - ); - cPriv->screen_width=sPriv->width; cPriv->screen_height=sPriv->height; - cPriv->new_state = ~0; - if (share_list) - shareCtx=((tdfxContextPrivate*)(share_list->private))->glCtx; - else - shareCtx=0; - cPriv->glCtx=gl_create_context(v->gl_visual, shareCtx, (void*)cPriv, GL_TRUE); + cPriv->glCtx = driContextPriv->mesaContext; cPriv->initDone=GL_FALSE; saPriv=(TDFXSAREAPriv*)((char*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec)); @@ -204,41 +128,63 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, sPriv->backOffset, sPriv->depthOffset, sPriv->textureOffset, sPriv->textureSize, &saPriv->fifoPtr, &saPriv->fifoRead); - return c; + driContextPriv->driverPrivate = (void *) cPriv; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { tdfxContextPrivate *cPriv; - cPriv=(tdfxContextPrivate*)c->private; + cPriv = (tdfxContextPrivate *) driContextPriv->driverPrivate; if (cPriv) { - gl_destroy_context(cPriv->glCtx); - gl_destroy_framebuffer(cPriv->glBuffer); + /* XXX XFree the tdfxContextPrivate struct? */ + driContextPriv->driverPrivate = NULL; } - if (c==gCC) { - gCC=0; - gCCPriv=0; + + if (driContextPriv == gCC) { + gCC = 0; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer b) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { FxI32 result; #ifdef STATS @@ -246,15 +192,20 @@ void XMesaSwapBuffers(XMesaBuffer b) extern int texSwaps; static int prevStalls=0; #endif + tdfxContextPrivate *gCCPriv; + /* ** NOT_DONE: This assumes buffer is currently bound to a context. ** This needs to be able to swap buffers when not currently bound. */ - if (gCC == NULL || gCCPriv == NULL) return; + if (gCC == NULL) + return; + + gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; FLUSH_VB( gCCPriv->glCtx, "swap buffers" ); - if (gCC->xm_visual->gl_visual->DBflag) { + if (gCC->mesaContext->Visual->DBflag) { #ifdef STATS stalls=grFifoGetStalls(); if (stalls!=prevStalls) { @@ -274,51 +225,59 @@ void XMesaSwapBuffers(XMesaBuffer b) } } -GLboolean XMesaUnbindContext(XMesaContext c) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { - if (c && c==gCC && gCCPriv) FX_grGlideGetState((GrState*)gCCPriv->state); - return GL_TRUE; + if (driContextPriv && driContextPriv == gCC) { + tdfxContextPrivate *gCCPriv; + gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; + FX_grGlideGetState((GrState*)gCCPriv->state); + } + return GL_TRUE; } -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { - __DRIdrawablePrivate *driDrawPriv; + if (driContextPriv) { + tdfxContextPrivate *gCCPriv; - if (c) { - if (c==gCC) return GL_TRUE; - gCC = c; - gCCPriv = (tdfxContextPrivate *)c->private; + gCC = driContextPriv; + gCCPriv = (tdfxContextPrivate *)driContextPriv->driverPrivate; - driDrawPriv = gCC->driContextPriv->driDrawablePriv; if (!gCCPriv->initDone) { - if (!tdfxInitHW(c)) return GL_FALSE; + if (!tdfxInitHW(driDrawPriv, gCCPriv)) + return GL_FALSE; gCCPriv->width=0; XMesaWindowMoved(); FX_grGlideGetState((GrState*)gCCPriv->state); - } else { + } + else { FX_grSstSelect(gCCPriv->board); FX_grGlideSetState((GrState*)gCCPriv->state); XMesaWindowMoved(); } - gl_make_current(gCCPriv->glCtx, gCCPriv->glBuffer); + gl_make_current2(gCCPriv->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); + fxSetupDDPointers(gCCPriv->glCtx); if (!gCCPriv->glCtx->Viewport.Width) gl_Viewport(gCCPriv->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); - } else { + } + else { gl_make_current(0,0); - gCC = NULL; - gCCPriv = NULL; + gCC = NULL; } return GL_TRUE; } -void -XMesaWindowMoved() { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; - GLcontext *ctx; - - ctx=gCCPriv->glCtx; + +void XMesaWindowMoved(void) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; + tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; + GLcontext *ctx = gCCPriv->glCtx; + grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h, dPriv->numClipRects, dPriv->pClipRects); gCCPriv->numClipRects=dPriv->numClipRects; @@ -354,9 +313,11 @@ XMesaWindowMoved() { } /* This is called from within the LOCK_HARDWARE routine */ -void XMesaUpdateState(int windowMoved) { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; +void XMesaUpdateState(int windowMoved) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; + tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */ @@ -381,8 +342,9 @@ void XMesaUpdateState(int windowMoved) { XMesaWindowMoved(); } -void XMesaSetSAREA() { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; +void XMesaSetSAREA(void) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); |