diff options
Diffstat (limited to 'xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c')
-rw-r--r-- | xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c | 251 |
1 files changed, 83 insertions, 168 deletions
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 |