diff options
Diffstat (limited to 'xc/lib/GL/mesa/src')
26 files changed, 1303 insertions, 1487 deletions
diff --git a/xc/lib/GL/mesa/src/drv/i810/Imakefile b/xc/lib/GL/mesa/src/drv/i810/Imakefile index 0b0bad1b3..5f5815a17 100644 --- a/xc/lib/GL/mesa/src/drv/i810/Imakefile +++ b/xc/lib/GL/mesa/src/drv/i810/Imakefile @@ -25,7 +25,6 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL MESA_INCLUDES = -I. -I.. -I../../include \ -I../../../../dri/drm - DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) @@ -229,7 +228,7 @@ MESA_INCLUDES = -I. -I.. -I../../include \ MMX_OBJS = ../../X86/mmx_blend.o XCOMM Disabling 3Dnow code for the time being. -#if 0 +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ 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 5934b9ebc..035e78de3 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c @@ -395,9 +395,6 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, */ ctx->TriangleCaps |= DD_CLIP_FOG_COORD; - ctx->Shared->DefaultD[2][0].DriverData = 0; - ctx->Shared->DefaultD[2][1].DriverData = 0; - if (ctx->VB) i810DDRegisterVB( ctx->VB ); diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.c b/xc/lib/GL/mesa/src/drv/i810/i810tex.c index 4bdeb4847..299a2ce86 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810tex.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.c @@ -734,7 +734,7 @@ static void i810UpdateTex0State( GLcontext *ctx ) MA_OP_ARG1 ); - if (!(ctx->Texture.Enabled & 0xf) || !tObj || !tObj->Complete) { + if (!(ctx->Texture.ReallyEnabled & 0xf) || !tObj || !tObj->Complete) { return; } @@ -977,7 +977,7 @@ static void i810UpdateTex1State( GLcontext *ctx ) MA_UPDATE_OP | MA_OP_ARG1 ); - if (!(ctx->Texture.Enabled & 0xf0) || !tObj || !tObj->Complete) { + if (!(ctx->Texture.ReallyEnabled & 0xf0) || !tObj || !tObj->Complete) { return; } diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.c b/xc/lib/GL/mesa/src/drv/i810/i810tris.c index 2b55a8d7b..b05affec2 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810tris.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.c @@ -98,7 +98,7 @@ void i810DDTrifuncInit() -#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK) +#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK | DD_STENCIL) #define POINT_FALLBACK (ALL_FALLBACK) #define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_STIPPLE) #define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_UNFILLED) diff --git a/xc/lib/GL/mesa/src/drv/i810/i810vb.c b/xc/lib/GL/mesa/src/drv/i810/i810vb.c index 5c6e1455e..37514dd8d 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810vb.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810vb.c @@ -24,14 +24,14 @@ */ /* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.c,v 1.5 2000/08/28 02:43:12 tsi Exp $ */ +#include <stdio.h> +#include <stdlib.h> #include "i810context.h" #include "i810vb.h" #include "i810log.h" - +#include "mem.h" #include "stages.h" -#include <stdio.h> -#include <stdlib.h> #define TEX0 { \ @@ -265,10 +265,10 @@ void i810ChooseRasterSetupFunc(GLcontext *ctx) imesa->vertsize = 8; imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0; - if (ctx->Texture.Enabled & 0xf) + if (ctx->Texture.ReallyEnabled & 0xf) funcindex |= I810_TEX0_BIT; - if (ctx->Texture.Enabled & 0xf0) { + if (ctx->Texture.ReallyEnabled & 0xf0) { funcindex |= I810_TEX1_BIT; imesa->vertsize = 10; imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0T1; @@ -387,8 +387,8 @@ void i810DDResizeVB( struct vertex_buffer *VB, GLuint size ) exit(1); } - free( VB->ClipMask ); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size); + ALIGN_FREE( VB->ClipMask ); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "i810-glx: out of memory !\n"); exit(1); @@ -429,8 +429,8 @@ void i810DDRegisterVB( struct vertex_buffer *VB ) exit(1); } - free( VB->ClipMask ); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * mvb->size); + ALIGN_FREE( VB->ClipMask ); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "i810-glx: out of memory !\n"); exit(1); diff --git a/xc/lib/GL/mesa/src/drv/mga/Imakefile b/xc/lib/GL/mesa/src/drv/mga/Imakefile index 90ccceecf..1fdd283a7 100644 --- a/xc/lib/GL/mesa/src/drv/mga/Imakefile +++ b/xc/lib/GL/mesa/src/drv/mga/Imakefile @@ -34,7 +34,6 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL MESA_INCLUDES = -I. -I.. -I../../include \ -I../../../../dri/drm - DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) @@ -56,17 +55,15 @@ MESA_INCLUDES = -I. -I.. -I../../include \ ../../../../dri/drm/xf86drmSL.o - MGASRCS = mgaclear.c mgacnvtex.c mgadd.c \ - mgafastpath.c mgaeltpath.c \ - mgapipeline.c \ - mgaspan.c mgastate.c mgatex.c \ - mgatris.c mgavb.c mgaioctl.c mga_xmesa.c mgabuffers.c + MGASRCS = mgatexcnv.c mgadd.c mgafastpath.c \ + mgaeltpath.c mgapipeline.c mgaspan.c mgastate.c \ + mgatex.c mgatexmem.c mgatris.c mgavb.c mgaioctl.c \ + mga_xmesa.c mgabuffers.c - MGAOBJS = mgaclear.o mgacnvtex.o mgadd.o \ - mgafastpath.o mgaeltpath.o \ - mgapipeline.o \ - mgaspan.o mgastate.o mgatex.o \ - mgatris.o mgavb.o mgaioctl.o mga_xmesa.o mgabuffers.o + MGAOBJS = mgatexcnv.o mgadd.o mgafastpath.o \ + mgaeltpath.o mgapipeline.o mgaspan.o mgastate.o \ + mgatex.o mgatexmem.o mgatris.o mgavb.o mgaioctl.o \ + mga_xmesa.o mgabuffers.o MESASRCS = ../../aatriangle.c \ ../../accum.c \ @@ -279,7 +276,7 @@ MESA_INCLUDES = -I. -I.. -I../../include \ OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) \ $(COMMONOBJS) $(MGAOBJS) $(HIOBJS) -REQUIREDLIBS += -lm +REQUIREDLIBS += -lm #if !GlxBuiltInMga REQUIREDLIBS += -L../../../.. -lGL -L../../../../../X11 -lX11 #endif 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 edcad5800..7d8da52da 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c @@ -44,6 +44,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "matrix.h" #include "mmath.h" #include "simple_list.h" +#include "mem.h" #include "mgadd.h" #include "mgastate.h" @@ -76,7 +77,6 @@ int MGA_DEBUG = (0 static mgaContextPtr mgaCtx = 0; -mgaGlx_t mgaglx; /* These functions are accessed externally to the driver: * @@ -99,6 +99,9 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) mgaScreenPrivate *mgaScreen; MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv; + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaInitDriver\n"); + /* Check the DRI version */ { int major, minor, patch; @@ -123,27 +126,23 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) } /* Check that the DRM driver version is compatible */ - if (sPriv->drmMajor != 1 || + if (sPriv->drmMajor != 2 || sPriv->drmMinor != 0 || sPriv->drmPatch < 0) { char msg[1000]; - sprintf(msg, "MGA DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + sprintf(msg, "MGA DRI driver expected DRM driver version 2.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); __driMesaMessage(msg); return GL_FALSE; } /* Allocate the private area */ - mgaScreen = (mgaScreenPrivate *)Xmalloc(sizeof(mgaScreenPrivate)); + mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate)); if (!mgaScreen) return GL_FALSE; mgaScreen->sPriv = sPriv; sPriv->private = (void *)mgaScreen; - /* - fprintf(stderr, "serverInfo->chipset: %d\n", serverInfo->chipset); - */ - if (serverInfo->chipset != MGA_CARD_TYPE_G200 && serverInfo->chipset != MGA_CARD_TYPE_G400) { XFree(mgaScreen); @@ -182,12 +181,6 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) mgaScreen->textureOffset[MGA_AGP_HEAP] = (serverInfo->agpTextureOffset | PDEA_pagpxfer_enable | 1); - /* - fprintf(stderr, "CARD texture size %x, granul %d --> %x\n", - serverInfo->textureSize, serverInfo->logTextureGranularity, - 1<<serverInfo->logTextureGranularity); - */ - mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize; mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize; @@ -208,12 +201,6 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) */ mgaScreen->dmaOffset = serverInfo->agpBufferOffset; - /* - fprintf(stderr, "\n\n\nbackOffset: %x pitch %x\n", - mgaScreen->backOffset, - mgaScreen->backPitch); - */ - mgaScreen->bufs = drmMapBufs(sPriv->fd); if (!mgaScreen->bufs) { /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ @@ -222,10 +209,6 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) return GL_FALSE; } - /* Other mgaglx stuff, too?? - */ - memset(&mgaglx, 0, sizeof(mgaglx)); - mgaDDFastPathInit(); mgaDDEltPathInit(); mgaDDTrifuncInit(); @@ -240,6 +223,10 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) void XMesaResetDriver(__DRIscreenPrivate *sPriv) { mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private; + + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaResetDriver\n"); + /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ Xfree(mgaScreen); sPriv->private = NULL; @@ -251,6 +238,9 @@ GLvisual *XMesaCreateVisual(Display *dpy, const XVisualInfo *visinfo, const __GLXvisualConfig *config) { + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaCreateVisual\n"); + /* Drivers may change the args to _mesa_create_visual() in order to * setup special visuals. */ @@ -282,9 +272,11 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private; drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+ sizeof(XF86DRISAREARec)); - /*fprintf(stderr, "XMesaCreateContext\n");*/ - mmesa = (mgaContextPtr)Xcalloc(sizeof(mgaContext), 1); + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaCreateContext\n"); + + mmesa = (mgaContextPtr)CALLOC(sizeof(mgaContext)); if (!mmesa) { return GL_FALSE; } @@ -310,7 +302,6 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, make_empty_list(&mmesa->TexObjList[i]); } - /* Set the maximum texture size small enough that we can guarentee * that both texture units can bind a maximal texture and have them * on the card at once. @@ -333,11 +324,37 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, } } - if (mgaScreen->cpp == 2) - mmesa->depth_scale = 1.0/(GLdouble)0xffff; - else - mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; - + mmesa->hw_stencil = mesaVis->StencilBits && mesaVis->DepthBits == 24; + +/* fprintf(stderr, */ +/* "mesaVis->DepthBits: %d " */ +/* "mmesa->glCtx->Visual->DepthBits: %d " */ +/* "mmesa->glCtx->Visual->DepthMax: %x\n", */ +/* mesaVis->DepthBits, */ +/* ctx->Visual->DepthBits, */ +/* ctx->Visual->DepthMax); */ + + switch (mesaVis->DepthBits) { + case 16: + mmesa->depth_scale = 1.0/(GLdouble)0xffff; + mmesa->depth_clear_mask = ~0; + mmesa->ClearDepth = 0xffff; + break; + case 24: + mmesa->depth_scale = 1.0/(GLdouble)0xffffff; + if (mmesa->hw_stencil) { + mmesa->depth_clear_mask = 0xffffff00; + mmesa->stencil_clear_mask = 0x000000ff; + } else + mmesa->depth_clear_mask = ~0; + mmesa->ClearDepth = 0xffffff00; + break; + case 32: + mmesa->depth_scale = 1.0/(GLdouble)0xffffffff; + mmesa->depth_clear_mask = ~0; + mmesa->ClearDepth = 0xffffffff; + break; + }; mmesa->renderindex = -1; /* impossible value */ @@ -372,9 +389,6 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, */ ctx->TriangleCaps |= DD_CLIP_FOG_COORD; - ctx->Shared->DefaultD[2][0].DriverData = 0; - ctx->Shared->DefaultD[2][1].DriverData = 0; - if (ctx->VB) mgaDDRegisterVB( ctx->VB ); @@ -395,17 +409,11 @@ void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; - if (mmesa) { -/* mgaTextureObjectPtr next_t, t; */ - -/* foreach_s (t, next_t, &(mmesa->TexObjList)) */ -/* mgaDestroyTexObj(mmesa, t); */ - -/* foreach_s (t, next_t, &(mmesa->SwappedOut)) */ -/* mgaDestroyTexObj(mmesa, t); */ + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaDestroyContext\n"); + if (mmesa) { Xfree(mmesa); - driContextPriv->driverPrivate = NULL; } } @@ -416,6 +424,9 @@ GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, __DRIdrawablePrivate *driDrawPriv, GLvisual *mesaVis) { + if (MGA_DEBUG&DEBUG_VERBOSE_DRI) + fprintf(stderr, "XMesaCreateWindowBuffer\n"); + return gl_create_framebuffer(mesaVis, GL_FALSE, /* software depth buffer? */ mesaVis->StencilBits > 0, @@ -480,9 +491,11 @@ GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, gl_make_current2(mgaCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); - mgaCtx->driDrawable = driDrawPriv; - mgaCtx->dirty = ~0; - mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); + if (mgaCtx->driDrawable != driDrawPriv) { + mgaCtx->driDrawable = driDrawPriv; + mgaCtx->dirty = ~0; + mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); + } if (!mgaCtx->glCtx->Viewport.Width) gl_Viewport(mgaCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); @@ -531,4 +544,5 @@ 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 013c004f5..2e9877eb2 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h @@ -50,7 +50,7 @@ typedef struct { char *map; } mgaRegion, *mgaRegionPtr; -typedef struct { +typedef struct mga_screen_private_s { int chipset; int width; @@ -88,7 +88,7 @@ typedef struct { } mgaScreenPrivate; -#include "mgalib.h" +#include "mgacontext.h" extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags ); extern void mgaEmitHwStateLocked( mgaContextPtr mmesa ); diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c index da288e3c9..d37027473 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c @@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <stdio.h> -#include "mgalib.h" +#include "mgacontext.h" #include "mgabuffers.h" #include "mgastate.h" #include "mgaioctl.h" @@ -88,37 +88,29 @@ static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa ) if (sarea->exported_buffers & MGA_BACK) { - XF86DRIClipRectPtr boxes = - (XF86DRIClipRectPtr)malloc( sarea->exported_nback * sizeof(*boxes) ); - - if (driDrawable->pBackClipRects) - free(driDrawable->pBackClipRects); driDrawable->numBackClipRects = sarea->exported_nback; - driDrawable->pBackClipRects = boxes; + driDrawable->pBackClipRects = mmesa->tmp_boxes[0]; top = sarea->exported_nback; for (i = 0 ; i < top ; i++) - boxes[i] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); + driDrawable->pBackClipRects[i] = + *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); } if (sarea->exported_buffers & MGA_FRONT) { int start = top; - XF86DRIClipRectPtr boxes = - (XF86DRIClipRectPtr)malloc( sarea->exported_nfront * sizeof(*boxes) ); - - if (driDrawable->pClipRects) - free(driDrawable->pClipRects); driDrawable->numClipRects = sarea->exported_nfront; - driDrawable->pClipRects = boxes; + driDrawable->pClipRects = mmesa->tmp_boxes[1]; top += sarea->exported_nfront; for ( ; i < top ; i++) - boxes[i-start] = *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); - + driDrawable->pClipRects[i-start] = + *(XF86DRIClipRectPtr)&(sarea->exported_boxes[i]); + } @@ -223,7 +215,8 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) */ if (0) printSareaRects(mmesa); - if (sarea->exported_drawable == driDrawable->draw && + if (0 && + sarea->exported_drawable == driDrawable->draw && (sarea->exported_buffers & buffers) == buffers) { mgaUpdateRectsFromSarea( mmesa ); diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadd.c b/xc/lib/GL/mesa/src/drv/mga/mgadd.c index 70e53efa8..0e89a928f 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgadd.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgadd.c @@ -35,10 +35,8 @@ #include <stdlib.h> #include "mm.h" -#include "mgalib.h" -#include "mgaclear.h" +#include "mgacontext.h" #include "mgadd.h" -#include "mgalog.h" #include "mgastate.h" #include "mgaspan.h" #include "mgatex.h" @@ -74,24 +72,28 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name ) static GLint mgaGetParameteri(const GLcontext *ctx, GLint param) { - switch (param) { - case DD_HAVE_HARDWARE_FOG: - return 1; - default: - mgaError("mgaGetParameteri(): unknown parameter!\n"); - return 0; - } + switch (param) { + case DD_HAVE_HARDWARE_FOG: + return 1; + default: + fprintf(stderr, "mgaGetParameteri(): unknown parameter!\n"); + return 0; + } } static void mgaBufferSize(GLcontext *ctx, GLuint *width, GLuint *height) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - -/* LOCK_HARDWARE( mmesa ); */ + + /* Need to lock to make sure the driDrawable is uptodate. This + * information is used to resize Mesa's software buffers, so it has + * to be correct. + */ + LOCK_HARDWARE( mmesa ); *width = mmesa->driDrawable->w; *height = mmesa->driDrawable->h; -/* UNLOCK_HARDWARE( mmesa ); */ + UNLOCK_HARDWARE( mmesa ); } void mgaDDExtensionsInit( GLcontext *ctx ) @@ -104,8 +106,6 @@ void mgaDDExtensionsInit( GLcontext *ctx ) */ if (1 || !MGA_IS_G400(MGA_CONTEXT(ctx))) { - gl_extensions_disable( ctx, "GL_EXT_multitexture" ); - gl_extensions_disable( ctx, "GL_SGIS_multitexture" ); gl_extensions_disable( ctx, "GL_ARB_multitexture" ); } @@ -141,10 +141,6 @@ void mgaDDExtensionsInit( GLcontext *ctx ) - - - - void mgaDDInitDriverFuncs( GLcontext *ctx ) { ctx->Driver.GetBufferSize = mgaBufferSize; diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c b/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c index b0db7dba3..3dcfa5eed 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c @@ -32,7 +32,7 @@ #include "mmath.h" #include "xform.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgapipeline.h" #include "mgatris.h" #include "mgastate.h" diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c index ea12c20b4..ad69cf8f6 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c @@ -31,7 +31,7 @@ #include "vertices.h" #include "mmath.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgapipeline.h" #include "mgatris.h" #include "mgastate.h" @@ -487,8 +487,10 @@ void mgaDDFastPath( struct vertex_buffer *VB ) struct mga_fast_tab *tab = &mgaFastTab[mmesa->setupindex & VALID_SETUP]; GLuint do_cliptest = 1; + gl_prepare_arrays_cva( VB ); /* still need this */ +#if 1 if (gl_reduce_prim[prim] == GL_TRIANGLES && VB->Count < (MGA_DMA_BUF_SZ / 48) && (ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL| @@ -498,6 +500,7 @@ void mgaDDFastPath( struct vertex_buffer *VB ) mgaDDEltPath( VB ); return; } +#endif /* Reserve enough space for the pathological case. */ diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c index 059284405..8dcb8f988 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c @@ -7,11 +7,10 @@ #include "dd.h" #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgadd.h" #include "mgastate.h" #include "mgatex.h" -#include "mgalog.h" #include "mgavb.h" #include "mgatris.h" #include "mgabuffers.h" @@ -55,6 +54,7 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa, int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags ) { drm_lock_t lock; + int retcode; lock.flags = 0; @@ -67,13 +67,15 @@ int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags ) if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH; if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL; - + if (!lock.flags) return 0; - if(ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock)) { + retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH, &lock); + if(retcode != 0) { fprintf(stderr, "Lockupdate failed\n"); - return -1; + if(retcode == EACCES) exit(1); + else return -1; } if(flags & DRM_LOCK_QUIESCENT) @@ -136,10 +138,10 @@ drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ) if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "drmDMA (get) returns size[0] 0x%x idx[0] %d\n" - "dma_buffer now: buf idx: %d size: %d used: %d\n", + "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n", dma.request_sizes[0], dma.request_list[0], buf->idx, buf->total, - buf->used); + buf->used, buf->address); if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "finished getbuffer\n"); @@ -155,7 +157,6 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); __DRIdrawablePrivate *dPriv = mmesa->driDrawable; - const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); drm_mga_clear_t clear; int retcode; int i; @@ -165,30 +166,40 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, clear.flags = 0; clear.clear_color = mmesa->ClearColor; + clear.clear_depth = 0; + clear.clear_depth_mask = 0; - if (mmesa->mgaScreen->cpp == 2) - clear.clear_depth = ctx->Depth.Clear * (GLdouble)0xffff; - else { - clear.clear_depth = ctx->Depth.Clear * (GLdouble)0xffffffff; - } FLUSH_BATCH( mmesa ); - if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) { + if (mask & DD_FRONT_LEFT_BIT) { clear.flags |= MGA_FRONT; + clear.clear_color_mask = mmesa->Setup[MGA_CTXREG_PLNWT]; mask &= ~DD_FRONT_LEFT_BIT; } - if ((mask & DD_BACK_LEFT_BIT) && colorMask == ~0) { + if (mask & DD_BACK_LEFT_BIT) { clear.flags |= MGA_BACK; + clear.clear_color_mask = mmesa->Setup[MGA_CTXREG_PLNWT]; mask &= ~DD_BACK_LEFT_BIT; } if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) { clear.flags |= MGA_DEPTH; + clear.clear_depth_mask |= mmesa->depth_clear_mask; + clear.clear_depth = (mmesa->ClearDepth & + mmesa->depth_clear_mask); mask &= ~DD_DEPTH_BIT; } + if ((mask & DD_STENCIL_BIT) && mmesa->hw_stencil) { + clear.flags |= MGA_DEPTH; + clear.clear_depth_mask |= mmesa->stencil_clear_mask; + clear.clear_depth |= (ctx->Stencil.Clear & + mmesa->stencil_clear_mask); + mask &= ~DD_STENCIL_BIT; + } + if (!clear.flags) return mask; @@ -267,6 +278,8 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, } +int nrswaps; + /* @@ -278,7 +291,6 @@ void mgaSwapBuffers( mgaContextPtr mmesa ) XF86DRIClipRectPtr pbox; int nbox; drm_mga_swap_t swap; - static int nrswaps; int retcode; int i; int tmp; @@ -312,12 +324,16 @@ void mgaSwapBuffers( mgaContextPtr mmesa ) if (0) fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n"); +#if 1 if((retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_SWAP, &swap))) { printf("send swap retcode = %d\n", retcode); exit(1); } +#else + mgaUpdateLock( mmesa, DRM_LOCK_FLUSH ); +#endif - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) + if (0) fprintf(stderr, "finished swap %d\n", ++nrswaps); } @@ -525,10 +541,10 @@ void mgaFlushElts( mgaContextPtr mmesa ) } -mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) +GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) { int bytes = dwords * 4; - mgaUI32 *head; + GLuint *head; if (!mmesa->vertex_dma_buffer) { LOCK_HARDWARE( mmesa ); @@ -546,7 +562,7 @@ mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) UNLOCK_HARDWARE( mmesa ); } - head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + + head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address + mmesa->vertex_dma_buffer->used); mmesa->vertex_dma_buffer->used += bytes; @@ -565,7 +581,10 @@ void mgaFireILoadLocked( mgaContextPtr mmesa, if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "mgaFireILoad idx %d ofs 0x%x length %d\n", mmesa->iload_buffer->idx, (int)offset, (int)length ); - + + /* HACK + */ + mgaUpdateLock( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH); mga_iload_dma_ioctl( mmesa, offset, length ); } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h index 0aafb1e37..f84ec731a 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h @@ -3,7 +3,7 @@ #ifndef MGA_IOCTL_H #define MGA_IOCTL_H -#include "mgalib.h" +#include "mgacontext.h" #include "mga_xmesa.h" GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, @@ -14,7 +14,7 @@ void mgaSwapBuffers( mgaContextPtr mmesa ); -mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ); +GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ); void mgaGetILoadBufferLocked( mgaContextPtr mmesa ); @@ -46,6 +46,7 @@ void mgaFlushElts( mgaContextPtr mmesa ) ; /* upload texture */ +void mgaDDFlush( GLcontext *ctx ); void mgaDDFinish( GLcontext *ctx ); void mgaDDInitIoctlFuncs( GLcontext *ctx ); @@ -60,10 +61,10 @@ void mgaDDInitIoctlFuncs( GLcontext *ctx ); extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ); static __inline -mgaUI32 *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords ) +GLuint *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords ) { int bytes = dwords * 4; - mgaUI32 *head; + GLuint *head; if (!mmesa->vertex_dma_buffer) { LOCK_HARDWARE( mmesa ); @@ -81,12 +82,11 @@ mgaUI32 *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords ) UNLOCK_HARDWARE( mmesa ); } - head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + + head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address + mmesa->vertex_dma_buffer->used); mmesa->vertex_dma_buffer->used += bytes; return head; } - #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c index 5400510fb..b3442d3fa 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c @@ -2,8 +2,7 @@ #include "types.h" #include "mgadd.h" -#include "mgalib.h" -#include "mgalog.h" +#include "mgacontext.h" #include "mgaspan.h" #include "mgaioctl.h" @@ -18,13 +17,13 @@ GLuint height = dPriv->h; \ char *read_buf = (char *)(sPriv->pFB + \ mmesa->readOffset + \ - dPriv->x * mgaScreen->cpp + \ - dPriv->y * pitch); \ + dPriv->x * mgaScreen->cpp + \ + dPriv->y * pitch); \ char *buf = (char *)(sPriv->pFB + \ mmesa->drawOffset + \ - dPriv->x * mgaScreen->cpp + \ - dPriv->y * pitch); \ - GLushort p = MGA_CONTEXT( ctx )->MonoColor; \ + dPriv->x * mgaScreen->cpp + \ + dPriv->y * pitch); \ + GLushort p = MGA_CONTEXT( ctx )->MonoColor; \ (void) read_buf; (void) buf; (void) p @@ -40,6 +39,8 @@ dPriv->x * 2 + \ dPriv->y * pitch) +#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS + #define INIT_MONO_PIXEL(p) #define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ @@ -150,21 +151,48 @@ do { \ +/* 32 bit depthbuffer functions. + */ +#define WRITE_DEPTH( _x, _y, d ) \ + *(GLuint *)(buf + _x*4 + _y*pitch) = d; +#define READ_DEPTH( d, _x, _y ) \ + d = *(GLuint *)(buf + _x*4 + _y*pitch); +#define TAG(x) mga##x##_32 +#include "depthtmp.h" -/* 32 bit depthbuffer functions. + +/* 24/8 bit interleaved depth/stencil functions */ -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + _x*4 + _y*pitch) = d; +#define WRITE_DEPTH( _x, _y, d ) { \ + GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ + tmp &= 0xff; \ + tmp |= (d) & 0xffffff00; \ + *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ +} #define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + _x*4 + _y*pitch); + d = *(GLuint *)(buf + _x*4 + _y*pitch) >> 8; -#define TAG(x) mga##x##_32 + +#define TAG(x) mga##x##_24_8 #include "depthtmp.h" +#define WRITE_STENCIL( _x, _y, d ) { \ + GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ + tmp &= 0xffffff00; \ + tmp |= d & 0xff; \ + *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ +} + +#define READ_STENCIL( d, _x, _y ) \ + d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff; + +#define TAG(x) mga##x##_24_8 +#include "stenciltmp.h" + @@ -196,20 +224,32 @@ void mgaDDInitSpanFuncs( GLcontext *ctx ) ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_8888; ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_8888; ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_8888; - - ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_32; - ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_32; - ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_32; - ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_32; + + if (mmesa->hw_stencil) { + ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_32; + ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_32; + ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_32; + ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_32; + } else { + ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_24_8; + ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_24_8; + ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_24_8; + ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_24_8; + + ctx->Driver.ReadStencilSpan = mgaReadStencilSpan_24_8; + ctx->Driver.WriteStencilSpan = mgaWriteStencilSpan_24_8; + ctx->Driver.ReadStencilPixels = mgaReadStencilPixels_24_8; + ctx->Driver.WriteStencilPixels = mgaWriteStencilPixels_24_8; + } break; } - ctx->Driver.WriteCI8Span =NULL; - ctx->Driver.WriteCI32Span =NULL; - ctx->Driver.WriteMonoCISpan =NULL; - ctx->Driver.WriteCI32Pixels =NULL; - ctx->Driver.WriteMonoCIPixels =NULL; - ctx->Driver.ReadCI32Span =NULL; - ctx->Driver.ReadCI32Pixels =NULL; + ctx->Driver.WriteCI8Span = 0; + ctx->Driver.WriteCI32Span = 0; + ctx->Driver.WriteMonoCISpan = 0; + ctx->Driver.WriteCI32Pixels = 0; + ctx->Driver.WriteMonoCIPixels = 0; + ctx->Driver.ReadCI32Span = 0; + ctx->Driver.ReadCI32Pixels = 0; } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.c b/xc/lib/GL/mesa/src/drv/mga/mgastate.c index 4b344b8c3..84a4b8135 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgastate.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.c @@ -7,11 +7,10 @@ #include "dd.h" #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgadd.h" #include "mgastate.h" #include "mgatex.h" -#include "mgalog.h" #include "mgavb.h" #include "mgatris.h" #include "mgaregs.h" @@ -33,6 +32,156 @@ static GLuint mgarop_NoBLK[16] = { #endif +static void mgaUpdateStencil(const GLcontext *ctx) +{ + mgaContextPtr mmesa = MGA_CONTEXT(ctx); + GLuint stencil = 0, stencilctl = 0; + + if (ctx->Stencil.Enabled) + { + stencil = ctx->Stencil.Ref | + ( ctx->Stencil.ValueMask << 8 ) | + ( ctx->Stencil.WriteMask << 16 ); + + switch (ctx->Stencil.Function) + { + case GL_NEVER: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_snever); + break; + case GL_LESS: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_slt); + break; + case GL_LEQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_slte); + break; + case GL_GREATER: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sgt); + break; + case GL_GEQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sgte); + break; + case GL_NOTEQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_sne); + break; + case GL_EQUAL: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_se); + break; + case GL_ALWAYS: + MGA_SET_FIELD(stencilctl, SC_smode_MASK, SC_smode_salways); + default: + break; + } + + switch (ctx->Stencil.FailFunc) + { + case GL_KEEP: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_keep); + break; + case GL_ZERO: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_zero); + break; + case GL_REPLACE: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_replace); + break; + case GL_INCR: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_incrsat); + break; + case GL_DECR: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_decrsat); + break; + case GL_INVERT: + MGA_SET_FIELD(stencilctl, SC_sfailop_MASK, SC_sfailop_invert); + break; + default: + break; + } + + switch (ctx->Stencil.ZFailFunc) + { + case GL_KEEP: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_keep); + break; + case GL_ZERO: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_zero); + break; + case GL_REPLACE: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_replace); + break; + case GL_INCR: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_incrsat); + break; + case GL_DECR: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_decrsat); + break; + case GL_INVERT: + MGA_SET_FIELD(stencilctl, SC_szfailop_MASK, SC_szfailop_invert); + break; + default: + break; + } + + switch (ctx->Stencil.ZPassFunc) + { + case GL_KEEP: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_keep); + break; + case GL_ZERO: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_zero); + break; + case GL_REPLACE: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_replace); + break; + case GL_INCR: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_incrsat); + break; + case GL_DECR: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_decrsat); + break; + case GL_INVERT: + MGA_SET_FIELD(stencilctl, SC_szpassop_MASK, SC_szpassop_invert); + break; + default: + break; + } + } + + mmesa->Setup[MGA_CTXREG_STENCIL] = stencil; + mmesa->Setup[MGA_CTXREG_STENCILCTL] = stencilctl; + mmesa->dirty |= MGA_UPLOAD_CTX; +} + +static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, + GLuint mask) +{ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL; +} + +static void mgaDDStencilMask(GLcontext *ctx, GLuint mask) +{ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL; +} + +static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, + GLenum zpass) +{ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_STENCIL; +} + +static void mgaDDClearDepth(GLcontext *ctx, GLclampd d) +{ + mgaContextPtr mmesa = MGA_CONTEXT(ctx); + + switch (mmesa->Setup[MGA_CTXREG_MACCESS] & MA_zwidth_MASK) { + case MA_zwidth_16: mmesa->ClearDepth = d * 0x0000ffff; break; + case MA_zwidth_24: mmesa->ClearDepth = d * 0xffffff00; break; + case MA_zwidth_32: mmesa->ClearDepth = d * 0xffffffff; break; + default: return; + } +} + static void mgaUpdateZMode(const GLcontext *ctx) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); @@ -122,11 +271,8 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname, static void mgaDDShadeModel(GLcontext *ctx, GLenum mode) { - if (1) { - FLUSH_BATCH( MGA_CONTEXT(ctx) ); - MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; - mgaMsg(8, "mgaDDShadeModel: %x\n", mode); - } + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; } @@ -167,9 +313,9 @@ static void mgaUpdateFogAttrib( GLcontext *ctx ) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - mgaUI32 color = MGAPACKCOLOR888((mgaUI8)(ctx->Fog.Color[0]*255.0F), - (mgaUI8)(ctx->Fog.Color[1]*255.0F), - (mgaUI8)(ctx->Fog.Color[2]*255.0F)); + GLuint color = MGAPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F), + (GLubyte)(ctx->Fog.Color[1]*255.0F), + (GLubyte)(ctx->Fog.Color[2]*255.0F)); if (color != mmesa->Setup[MGA_CTXREG_FOGCOLOR]) mmesa->Setup[MGA_CTXREG_FOGCOLOR] = color; @@ -202,7 +348,7 @@ static void mgaUpdateAlphaMode(GLcontext *ctx) int a = 0; /* determine source of alpha for blending and testing */ - if ( !ctx->Texture.Enabled ) + if ( !ctx->Texture.ReallyEnabled ) a |= AC_alphasel_diffused; else { switch (ctx->Texture.Unit[0].EnvMode) { @@ -433,7 +579,7 @@ static void mgaUpdateCull( GLcontext *ctx ) mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); if (ctx->Polygon.FrontFace != GL_CCW) mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); - if (mmesa->multitex) + if (mmesa->warp_pipe & MGA_TEX1_BIT) mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* why??? */ } @@ -564,9 +710,6 @@ static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask ) /* ============================================================= */ - - - static void mgaDDPrintDirty( const char *msg, GLuint state ) { fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s\n", @@ -582,11 +725,80 @@ static void mgaDDPrintDirty( const char *msg, GLuint state ) ); } +/* static int tex0[11] = { */ +/* 0x2050003, */ +/* 0x90, */ +/* 0x82100000, */ +/* 0x0, */ +/* 0xc6d000, */ +/* 0xc7d000, */ +/* 0xc81000, */ +/* 0xc82000, */ +/* 0xc82400, */ +/* 0x3fc7413, */ +/* 0x1fc7612 */ +/* }; */ + +/* static int tex1[11] = { */ +/* 0x2040003, */ +/* 0x90, */ +/* 0x82100000, */ +/* 0x0, */ +/* 0xc82500, */ +/* 0xc8a500, */ +/* 0xc8c500, */ +/* 0xc8cd00, */ +/* 0xc8cf00, */ +/* 0x1fc7612, */ +/* 0x1fc7612 */ +/* }; */ + +/* static int tex0_single[11] = { */ +/* 0x2040003, */ +/* 0x10, */ +/* 0x82100000, */ +/* 0x0, */ +/* 0x196d000, */ +/* 0x1975000, */ +/* 0x1977000, */ +/* 0x1977800, */ +/* 0x1977a00, */ +/* 0x1fc7612, */ +/* 0x1fc7612, */ +/* }; */ + +/* static int ctx_single[] = { */ +/* 0x727000, */ +/* 0x1, */ +/* 0xffffffff, */ +/* 0xc4436, */ +/* 0x101, */ +/* 0x7fff7f, */ +/* 0x0, */ +/* 0x0, */ +/* 0x0, */ +/* 0x0 */ +/* }; */ + +/* static int ctx_multi[] = { */ +/* 0x727000, */ +/* 0x1, */ +/* 0xffffffff, */ +/* 0xc4076, */ +/* 0x2000101, */ +/* 0x0, */ +/* 0x0, */ +/* 0xc0600000, */ +/* 0xc3600013, */ +/* 0x0 */ +/* }; */ /* Push the state into the sarea and/or texture memory. */ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) { + drm_mga_sarea_t *sarea = mmesa->sarea; + if (MGA_DEBUG & DEBUG_VERBOSE_MSG) mgaDDPrintDirty( "mgaEmitHwStateLocked", mmesa->dirty ); @@ -596,28 +808,40 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) if ((mmesa->dirty & MGA_UPLOAD_TEX1IMAGE) && mmesa->CurrentTexObj[1]) mgaUploadTexImages(mmesa, mmesa->CurrentTexObj[1]); - if (mmesa->dirty & MGA_UPLOAD_CTX) - memcpy( mmesa->sarea->ContextState, - mmesa->Setup, - sizeof(mmesa->Setup)); + if (mmesa->dirty & MGA_UPLOAD_CTX) { + memcpy( sarea->ContextState, mmesa->Setup, sizeof(mmesa->Setup)); + } - if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) - memcpy(mmesa->sarea->TexState[0], - mmesa->CurrentTexObj[0]->Setup, - sizeof(mmesa->sarea->TexState[0])); + if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) { + memcpy(sarea->TexState[0], + mmesa->CurrentTexObj[0]->Setup, + sizeof(sarea->TexState[0])); + } - if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) - memcpy(mmesa->sarea->TexState[1], - mmesa->CurrentTexObj[1]->Setup, - sizeof(mmesa->sarea->TexState[1])); + if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) { + memcpy(sarea->TexState[1], + mmesa->CurrentTexObj[1]->Setup, + sizeof(sarea->TexState[1])); + } + + if (sarea->TexState[0][MGA_TEXREG_CTL2] != + sarea->TexState[1][MGA_TEXREG_CTL2]) { + memcpy(sarea->TexState[1], + sarea->TexState[0], + sizeof(sarea->TexState[0])); + mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0; + } mmesa->sarea->WarpPipe = mmesa->warp_pipe; + mmesa->sarea->vertexsize = mmesa->vertsize; +/* mmesa->sarea->vertexsize = 10; */ mmesa->sarea->dirty |= mmesa->dirty; #if 0 - mgaPrintSetupFlags("warp pipe", mmesa->sarea->WarpPipe); - fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n", - mmesa->sarea->dirty); + if (mmesa->dirty & MGA_UPLOAD_PIPE) + mgaPrintSetupFlags("warp pipe", mmesa->sarea->WarpPipe); +/* fprintf(stderr, "in mgaEmitHwStateLocked: dirty now %x\n", */ +/* mmesa->sarea->dirty); */ #endif mmesa->dirty &= (MGA_UPLOAD_CLIPRECTS|MGA_WAIT_AGE); @@ -686,6 +910,14 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) mmesa->new_state |= MGA_NEW_DEPTH; #endif break; + case GL_STENCIL_TEST: + FLUSH_BATCH( mmesa ); + if (mmesa->hw_stencil) + mmesa->new_state |= MGA_NEW_STENCIL; + else if (state) + mmesa->Fallback |= MGA_FALLBACK_STENCIL; + else + mmesa->Fallback &= ~MGA_FALLBACK_STENCIL; default: break; } @@ -704,7 +936,11 @@ static void mgaWarpUpdateState( GLcontext *ctx ) int index = mmesa->setupindex; index &= ~(MGA_WIN_BIT|MGA_TEX0_BIT|MGA_RGBA_BIT); - index |= MGA_ALPHA_BIT | MGA_SPEC_BIT | MGA_FOG_BIT; + index |= (MGA_ALPHA_BIT | + MGA_SPEC_BIT | + MGA_FOG_BIT | +/* MGA_TEX1_BIT | */ + 0); if (index != mmesa->warp_pipe) { @@ -722,7 +958,7 @@ static void mgaWarpUpdateState( GLcontext *ctx ) static void mgaDDPrintState( const char *msg, GLuint state ) { - mgaMsg(1, "%s (0x%x): %s%s%s%s%s%s%s%s\n", + fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s%s\n", msg, state, (state & MGA_NEW_DEPTH) ? "depth, " : "", @@ -761,6 +997,9 @@ void mgaDDUpdateHwState( GLcontext *ctx ) if (new_state & MGA_NEW_CLIP) mgaUpdateClipping(ctx); + if (new_state & MGA_NEW_STENCIL) + mgaUpdateStencil(ctx); + if (new_state & (MGA_NEW_WARP|MGA_NEW_CULL)) mgaUpdateCull(ctx); @@ -800,7 +1039,6 @@ void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim ) void mgaDDUpdateState( GLcontext *ctx ) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaglx.c_setupPointers++; if (ctx->NewState & INTERESTED) { mgaDDChooseRenderState(ctx); @@ -848,22 +1086,35 @@ void mgaInitState( mgaContextPtr mmesa ) mmesa->Setup[MGA_CTXREG_DSTORG] = mgaScreen->frontOffset; } - if (mgaScreen->cpp == 2) + switch (mmesa->glCtx->Visual->DepthBits) { + case 16: mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_16 | - MA_zwidth_16 | + MA_zwidth_16 | /* 1bit stencil? */ MA_memreset_disable | MA_fogen_disable | MA_tlutload_disable | MA_nodither_disable | MA_dit555_disable); - else + break; + case 24: + mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_32 | + MA_zwidth_24 | + MA_memreset_disable | + MA_fogen_disable | + MA_tlutload_disable | + MA_nodither_enable | + MA_dit555_disable); + break; + case 32: mmesa->Setup[MGA_CTXREG_MACCESS] = (MA_pwidth_32 | - MA_zwidth_32 | /* stencil? */ + MA_zwidth_32 | MA_memreset_disable | MA_fogen_disable | MA_tlutload_disable | MA_nodither_enable | MA_dit555_disable); + break; + } mmesa->Setup[MGA_CTXREG_DWGCTL] = (DC_opcod_trap | DC_atype_i | @@ -928,14 +1179,18 @@ void mgaDDInitStateFuncs( GLcontext *ctx ) ctx->Driver.SetReadBuffer = mgaDDSetReadBuffer; ctx->Driver.Color = mgaDDSetColor; ctx->Driver.ClearColor = mgaDDClearColor; + ctx->Driver.ClearDepth = mgaDDClearDepth; ctx->Driver.Dither = mgaDDDither; ctx->Driver.LogicOpcode = mgaDDLogicOp; ctx->Driver.PolygonStipple = mgaDDPolygonStipple; + ctx->Driver.StencilFunc = mgaDDStencilFunc; + ctx->Driver.StencilMask = mgaDDStencilMask; + ctx->Driver.StencilOp = mgaDDStencilOp; + ctx->Driver.Index = 0; ctx->Driver.ClearIndex = 0; ctx->Driver.IndexMask = 0; - } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.c b/xc/lib/GL/mesa/src/drv/mga/mgatex.c index 3286744da..964157d19 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgatex.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.c @@ -1,4 +1,3 @@ -/* -*- mode: C; c-basic-offset:8 -*- */ /* * GLX Hardware Device Driver for Matrox Millenium G200 * Copyright (C) 1999 Wittawat Yamwong @@ -33,369 +32,115 @@ #include <GL/gl.h> #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgatex.h" -#include "mgalog.h" #include "mgaregs.h" #include "mgaioctl.h" +#include "enums.h" #include "simple_list.h" +#include "mem.h" +#define TEX_0 1 +#define TEX_1 2 /* * mgaDestroyTexObj * Free all memory associated with a texture and NULL any pointers * to it. */ -static void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) { - - if ( !t ) return; +void +mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ) +{ + if ( !t ) return; - /* free the texture memory */ - if (t->MemBlock) { - mmFreeMem( t->MemBlock ); - t->MemBlock = 0; - - if (t->age > mmesa->dirtyAge) - mmesa->dirtyAge = t->age; - } + /* free the texture memory */ + if (t->MemBlock) { + mmFreeMem( t->MemBlock ); + t->MemBlock = 0; + + if (t->age > mmesa->dirtyAge) + mmesa->dirtyAge = t->age; + } - /* free mesa's link */ - if (t->tObj) - t->tObj->DriverData = NULL; + /* free mesa's link */ + if (t->tObj) + t->tObj->DriverData = NULL; - /* see if it was the driver's current object */ - if (t->bound) - mmesa->CurrentTexObj[t->bound - 1] = 0; + /* see if it was the driver's current object */ + if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0; + if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0; - remove_from_list(t); - free( t ); -} - -static void mgaSwapOutTexObj(mgaContextPtr mmesa, mgaTextureObjectPtr t) -{ - if (t->MemBlock) { - mmFreeMem(t->MemBlock); - t->MemBlock = 0; - - if (t->age > mmesa->dirtyAge) - mmesa->dirtyAge = t->age; - } - - t->dirty_images = ~0; - move_to_tail(&(mmesa->SwappedOut), t); + remove_from_list(t); + FREE( t ); } -static void mgaPrintLocalLRU( mgaContextPtr mmesa, int heap ) -{ - mgaTextureObjectPtr t; - int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]); - - fprintf(stderr, "\nLocal LRU, heap %d:\n", heap); - - foreach( t, &(mmesa->TexObjList[heap]) ) { - if (!t->tObj) - fprintf(stderr, "Placeholder %d at %x sz %x\n", - t->MemBlock->ofs / sz, - t->MemBlock->ofs, - t->MemBlock->size); - else - fprintf(stderr, "Texture (bound %d) at %x sz %x\n", - t->bound, - t->MemBlock->ofs, - t->MemBlock->size); - - } - - fprintf(stderr, "\n\n"); -} - -static void mgaPrintGlobalLRU( mgaContextPtr mmesa, int heap ) +/* + * mgaSetTexWrappings + */ +static void mgaSetTexWrapping( mgaTextureObjectPtr t, + GLenum sWrap, + GLenum tWrap ) { - int i, j; - drm_mga_tex_region_t *list = mmesa->sarea->texList[heap]; + GLuint val = 0; - fprintf(stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list); - - for (i = 0, j = MGA_NR_TEX_REGIONS ; i < MGA_NR_TEX_REGIONS ; i++) { - fprintf(stderr, "list[%d] age %d next %d prev %d\n", - j, list[j].age, list[j].next, list[j].prev); - j = list[j].next; - if (j == MGA_NR_TEX_REGIONS) break; - } - - if (j != MGA_NR_TEX_REGIONS) { - fprintf(stderr, "Loop detected in global LRU\n\n\n"); - for (i = 0 ; i < MGA_NR_TEX_REGIONS ; i++) { - fprintf(stderr, "list[%d] age %d next %d prev %d\n", - i, list[i].age, list[i].next, list[i].prev); - } - } + if (sWrap != GL_REPEAT) + val |= TMC_clampu_enable; - fprintf(stderr, "\n\n"); -} - - -static void mgaResetGlobalLRU( mgaContextPtr mmesa, GLuint heap ) -{ - drm_mga_tex_region_t *list = mmesa->sarea->texList[heap]; - int sz = 1 << mmesa->mgaScreen->logTextureGranularity[heap]; - int i; - - mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap]; - - if (0) fprintf(stderr, "mgaResetGlobalLRU %d\n", (int)heap); - - /* (Re)initialize the global circular LRU list. The last element - * in the array (MGA_NR_TEX_REGIONS) is the sentinal. Keeping it - * at the end of the array allows it to be addressed rationally - * when looking up objects at a particular location in texture - * memory. - */ - for (i = 0 ; (i+1) * sz <= mmesa->mgaScreen->textureSize[heap] ; i++) { - list[i].prev = i-1; - list[i].next = i+1; - list[i].age = mmesa->sarea->texAge[heap]; - } - - i--; - list[0].prev = MGA_NR_TEX_REGIONS; - list[i].prev = i-1; - list[i].next = MGA_NR_TEX_REGIONS; - list[MGA_NR_TEX_REGIONS].prev = i; - list[MGA_NR_TEX_REGIONS].next = 0; + if (tWrap != GL_REPEAT) + val |= TMC_clampv_enable; + t->Setup[MGA_TEXREG_CTL] &= ~(TMC_clampu_enable|TMC_clampv_enable); + t->Setup[MGA_TEXREG_CTL] |= val; } -static void mgaUpdateTexLRU( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - int i; - int heap = t->heap; - int logsz = mmesa->mgaScreen->logTextureGranularity[heap]; - int start = t->MemBlock->ofs >> logsz; - int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz; - drm_mga_tex_region_t *list = mmesa->sarea->texList[heap]; - - mmesa->texAge[heap] = ++mmesa->sarea->texAge[heap]; - - if (!t->MemBlock) { - fprintf(stderr, "no memblock\n\n"); - return; - } - - /* Update our local LRU - */ - move_to_head( &(mmesa->TexObjList[heap]), t ); - - - if (0) - fprintf(stderr, "mgaUpdateTexLRU heap %d list %p\n", heap, list); - - - /* Update the global LRU - */ - for (i = start ; i <= end ; i++) { - - list[i].in_use = 1; - list[i].age = mmesa->texAge[heap]; - - /* remove_from_list(i) - */ - list[(unsigned)list[i].next].prev = list[i].prev; - list[(unsigned)list[i].prev].next = list[i].next; - - /* insert_at_head(list, i) - */ - list[i].prev = MGA_NR_TEX_REGIONS; - list[i].next = list[MGA_NR_TEX_REGIONS].next; - list[(unsigned)list[MGA_NR_TEX_REGIONS].next].prev = i; - list[MGA_NR_TEX_REGIONS].next = i; - } - - if (0) { - mgaPrintGlobalLRU(mmesa, t->heap); - mgaPrintLocalLRU(mmesa, t->heap); - } -} - -/* Called for every shared texture region which has increased in age - * since we last held the lock. - * - * Figures out which of our textures have been ejected by other clients, - * and pushes a placeholder texture onto the LRU list to represent - * the other client's textures. +/* + * mgaSetTexFilter */ -static void mgaTexturesGone( mgaContextPtr mmesa, - GLuint heap, - GLuint offset, - GLuint size, - GLuint in_use ) +static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf) { - mgaTextureObjectPtr t, tmp; - - - - foreach_s ( t, tmp, &(mmesa->TexObjList[heap]) ) { - - if (t->MemBlock->ofs >= offset + size || - t->MemBlock->ofs + t->MemBlock->size <= offset) - continue; - - - - - /* It overlaps - kick it off. Need to hold onto the currently bound - * objects, however. - */ - if (t->bound) - mgaSwapOutTexObj( mmesa, t ); - else - mgaDestroyTexObj( mmesa, t ); + GLuint val = 0; + + switch (minf) { + case GL_NEAREST: val = TF_minfilter_nrst; break; + case GL_LINEAR: val = TF_minfilter_bilin; break; + case GL_NEAREST_MIPMAP_NEAREST: val = TF_minfilter_mm1s; break; + case GL_LINEAR_MIPMAP_NEAREST: val = TF_minfilter_mm4s; break; + case GL_NEAREST_MIPMAP_LINEAR: val = TF_minfilter_mm2s; break; + case GL_LINEAR_MIPMAP_LINEAR: val = TF_minfilter_mm8s; break; + default: val = TF_minfilter_nrst; break; } - - if (in_use) { - t = (mgaTextureObjectPtr) calloc(1,sizeof(*t)); - if (!t) return; - - t->heap = heap; - t->MemBlock = mmAllocMem( mmesa->texHeap[heap], size, 0, offset); - if (!t->MemBlock) { - fprintf(stderr, "Couldn't alloc placeholder sz %x ofs %x\n", - (int)size, (int)offset); - mmDumpMemInfo( mmesa->texHeap[heap]); - return; - } - insert_at_head( &(mmesa->TexObjList[heap]), t ); + switch (magf) { + case GL_NEAREST: val |= TF_magfilter_nrst; break; + case GL_LINEAR: val |= TF_magfilter_bilin; break; + default: val |= TF_magfilter_nrst; break; } -} - - -void mgaAgeTextures( mgaContextPtr mmesa, int heap ) -{ - drm_mga_sarea_t *sarea = mmesa->sarea; - int sz = 1 << (mmesa->mgaScreen->logTextureGranularity[heap]); - int idx, nr = 0; - - /* Have to go right round from the back to ensure stuff ends up - * LRU in our local list... Fix with a cursor pointer. - */ - for (idx = sarea->texList[heap][MGA_NR_TEX_REGIONS].prev ; - idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ; - idx = sarea->texList[heap][idx].prev, nr++) - { - if (sarea->texList[heap][idx].age > mmesa->texAge[heap]) { - mgaTexturesGone(mmesa, heap, idx * sz, sz, 1); - } - } - - if (nr == MGA_NR_TEX_REGIONS) { - mgaTexturesGone(mmesa, heap, 0, - mmesa->mgaScreen->textureSize[heap], 0); - mgaResetGlobalLRU( mmesa, heap ); - } - - - if (0) { - mgaPrintGlobalLRU( mmesa, heap ); - mgaPrintLocalLRU( mmesa, heap ); - } - - mmesa->texAge[heap] = sarea->texAge[heap]; - mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE; -} - - -/* - * mgaSetTexWrappings - */ -static void mgaSetTexWrapping( mgaTextureObjectPtr t, - GLenum sWrap, GLenum tWrap ) { - if (sWrap == GL_REPEAT) { - t->Setup[MGA_TEXREG_CTL] &= ~TMC_clampu_enable; - } else { - t->Setup[MGA_TEXREG_CTL] |= TMC_clampu_enable; - } - if (tWrap == GL_REPEAT) { - t->Setup[MGA_TEXREG_CTL] &= ~TMC_clampv_enable; - } else { - t->Setup[MGA_TEXREG_CTL] |= TMC_clampv_enable; - } -} - -/* - * mgaSetTexFilter - */ -static void mgaSetTexFilter(mgaTextureObjectPtr t, GLenum minf, GLenum magf) { - switch (minf) { - case GL_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_nrst); - break; - case GL_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_bilin); - break; - case GL_NEAREST_MIPMAP_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm1s); - break; - case GL_LINEAR_MIPMAP_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm4s); - break; - case GL_NEAREST_MIPMAP_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm2s); - break; - case GL_LINEAR_MIPMAP_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_minfilter_MASK, TF_minfilter_mm8s); - break; - default: - mgaError("mgaSetTexFilter(): not supported min. filter %d\n", - (int)minf); - break; - } - - switch (magf) { - case GL_NEAREST: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_magfilter_MASK,TF_magfilter_nrst); - break; - case GL_LINEAR: - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER], - TF_magfilter_MASK,TF_magfilter_bilin); - break; - default: - mgaError("mgaSetTexFilter(): not supported mag. filter %d\n", - (int)magf); - break; - } - /* See OpenGL 1.2 specification */ - if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || - minf == GL_NEAREST_MIPMAP_LINEAR)) { - /* c = 0.5 */ - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],TF_fthres_MASK, - 0x20 << TF_fthres_SHIFT); - } else { - /* c = 0 */ - MGA_SET_FIELD(t->Setup[MGA_TEXREG_FILTER],TF_fthres_MASK, - 0x10 << TF_fthres_SHIFT); - } + /* See OpenGL 1.2 specification */ + if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST || + minf == GL_NEAREST_MIPMAP_LINEAR)) { + val |= (0x20 << TF_fthres_SHIFT); /* c = 0.5 */ + } else { + val |= (0x10 << TF_fthres_SHIFT); /* c = 0 */ + } + + t->Setup[MGA_TEXREG_FILTER] &= (TF_minfilter_MASK | + TF_magfilter_MASK | + TF_fthres_MASK); + t->Setup[MGA_TEXREG_FILTER] |= val; } /* * mgaSetTexBorderColor */ -static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) { - t->Setup[MGA_TEXREG_BORDERCOL] = - MGAPACKCOLOR8888(color[0],color[1],color[2],color[3]); - +static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) +{ + t->Setup[MGA_TEXREG_BORDERCOL] = MGAPACKCOLOR8888(color[0],color[1], + color[2],color[3]); } @@ -404,152 +149,6 @@ static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4]) { -/* - * mgaUploadSubImageLocked - * - * Perform an iload based update of a resident buffer. This is used for - * both initial loading of the entire image, and texSubImage updates. - * - * Performed with the hardware lock held. - */ -static void mgaUploadSubImageLocked( mgaContextPtr mmesa, - mgaTextureObjectPtr t, - int level, - int x, int y, int width, int height ) { - int x2; - int dwords; - int offset; - struct gl_texture_image *image; - int texelBytes, texelsPerDword, texelMaccess, length; - - if ( level < 0 || level >= MGA_TEX_MAXLEVELS ) { - mgaMsg( 1, "mgaUploadSubImage: bad level: %i\n", level ); - return; - } - - image = t->tObj->Image[level]; - if ( !image ) { - mgaError( "mgaUploadSubImage: NULL image\n" ); - return; - } - - /* find the proper destination offset for this level */ - offset = (t->MemBlock->ofs + - t->offsets[level]); - - texelBytes = t->texelBytes; - switch( texelBytes ) { - case 1: - texelsPerDword = 4; - texelMaccess = 0; - break; - case 2: - texelsPerDword = 2; - texelMaccess = 1; - break; - case 4: - texelsPerDword = 1; - texelMaccess = 2; - break; - default: - return; - } - - - /* We can't do a subimage update if pitch is < 32 texels due - * to hardware XY addressing limits, so we will need to - * linearly upload all modified rows. - */ - if ( image->Width < 32 ) { - x = 0; - width = image->Width * height; - height = 1; - - /* Assume that 1x1 textures aren't going to cause a - * bus error if we read up to four texels from that - * location: - */ - if ( width < texelsPerDword ) { - width = texelsPerDword; - } - } else { - /* pad the size out to dwords. The image is a pointer - to the entire image, so we can safely reference - outside the x,y,width,height bounds if we need to */ - x2 = x + width; - x2 = (x2 + (texelsPerDword-1)) & ~(texelsPerDword-1); - x = (x + (texelsPerDword-1)) & ~(texelsPerDword-1); - width = x2 - x; - } - - /* we may not be able to upload the entire texture in one - batch due to register limits or dma buffer limits. - Recursively split it up. */ - while ( 1 ) { - dwords = height * width / texelsPerDword; - if ( dwords * 4 <= MGA_DMA_BUF_SZ ) { - break; - } - mgaMsg(10, "mgaUploadSubImage: recursively subdividing\n" ); - - mgaUploadSubImageLocked( mmesa, t, level, x, y, - width, height >> 1 ); - y += ( height >> 1 ); - height -= ( height >> 1 ); - } - - mgaMsg(10, "mgaUploadSubImage: %i,%i of %i,%i at %i,%i\n", - width, height, image->Width, image->Height, x, y ); - - /* bump the performance counter */ - mgaglx.c_textureSwaps += ( dwords << 2 ); - - length = dwords * 4; - - /* Fill in the secondary buffer with properly converted texels - * from the mesa buffer. */ - if(t->heap == MGA_CARD_HEAP) { - mgaGetILoadBufferLocked( mmesa ); - mgaConvertTexture( (mgaUI32 *)mmesa->iload_buffer->address, - texelBytes, image, x, y, width, height ); - if(length < 64) length = 64; - mgaMsg(10, "TexelBytes : %d, offset: %d, length : %d\n", - texelBytes, - mmesa->mgaScreen->textureOffset[t->heap] + - offset + - y * width * 4/texelsPerDword, - length); - - mgaFireILoadLocked( mmesa, - mmesa->mgaScreen->textureOffset[t->heap] + - offset + - y * width * 4/texelsPerDword, - length); - } else { - /* This works, is slower for uploads to card space and needs - * additional synchronization with the dma stream. - */ - mgaConvertTexture( (mgaUI32 *) - (mmesa->mgaScreen->texVirtual[t->heap] + - offset + - y * width * 4/texelsPerDword), - texelBytes, image, x, y, width, height ); - } -} - - -static void mgaUploadTexLevel( mgaContextPtr mmesa, - mgaTextureObjectPtr t, - int l ) -{ - mgaUploadSubImageLocked( mmesa, - t, - l, - 0, 0, - t->tObj->Image[l]->Width, - t->tObj->Image[l]->Height); -} - /* @@ -558,502 +157,337 @@ static void mgaUploadTexLevel( mgaContextPtr mmesa, * This will happen before drawing with a new texture, or drawing with a * texture after it was swapped out or teximaged again. */ -static void mgaCreateTexObj(mgaContextPtr mmesa, struct gl_texture_object *tObj) +static void mgaCreateTexObj(mgaContextPtr mmesa, + struct gl_texture_object *tObj) { - mgaTextureObjectPtr t; - int i, ofs, size; - struct gl_texture_image *image; - int LastLevel; - int s, s2; - int textureFormat; - - mgaMsg( 10,"mgaCreateTexObj( %p )\n", tObj ); - - t = malloc( sizeof( *t ) ); - if ( !t ) { - mgaError( "mgaCreateTexObj: Failed to malloc mgaTextureObject\n" ); - return; - } - memset( t, 0, sizeof( *t ) ); - - image = tObj->Image[ 0 ]; - if ( !image ) { - return; - } - - if ( 0 ) { - /* G400 texture format options */ - - } else { - /* G200 texture format options */ - - switch( image->Format ) { - case GL_RGB: - case GL_LUMINANCE: - if ( image->IntFormat != GL_RGB5 && - ( image->IntFormat == GL_RGB8 || - mgaglx.default32BitTextures ) ) { - t->texelBytes = 4; - textureFormat = TMC_tformat_tw32; - } else { - t->texelBytes = 2; - textureFormat = TMC_tformat_tw16; - } - break; - case GL_ALPHA: - case GL_LUMINANCE_ALPHA: - case GL_INTENSITY: - case GL_RGBA: - if ( image->IntFormat != GL_RGBA4 && - ( image->IntFormat == GL_RGBA8 || - mgaglx.default32BitTextures ) ) { - t->texelBytes = 4; - textureFormat = TMC_tformat_tw32; - } else { - t->texelBytes = 2; - textureFormat = TMC_tformat_tw12; - } - break; - case GL_COLOR_INDEX: - textureFormat = TMC_tformat_tw8; - t->texelBytes = 1; - break; - default: - mgaError( "mgaCreateTexObj: bad image->Format\n" ); - free( t ); - return; - } - } - - /* we are going to upload all levels that are present, even if - later levels wouldn't be used by the current filtering mode. This - allows the filtering mode to change without forcing another upload - of the images */ - LastLevel = MGA_TEX_MAXLEVELS-1; - - ofs = 0; - for ( i = 0 ; i <= LastLevel ; i++ ) { - int levelWidth, levelHeight; - - t->offsets[i] = ofs; - image = tObj->Image[ i ]; - if ( !image ) { - LastLevel = i - 1; - mgaMsg( 10, " missing images after LastLevel: %i\n", - LastLevel ); - break; - } - /* the G400 doesn't work with textures less than 8 - units in size */ - levelWidth = image->Width; - levelHeight = image->Height; - if ( levelWidth < 8 ) { - levelWidth = 8; - } - if ( levelHeight < 8 ) { - levelHeight = 8; - } - size = levelWidth * levelHeight * t->texelBytes; - size = ( size + 31 ) & ~31; /* 32 byte aligned */ - ofs += size; - t->dirty_images |= (1<<i); - } - t->totalSize = ofs; - t->lastLevel = LastLevel; + const struct gl_texture_image *image = tObj->Image[ 0 ]; + mgaTextureObjectPtr t; + int i, ofs; + int LastLevel; + int s, s2; + int textureFormat; - /* fill in our mga texture object */ - t->tObj = tObj; - t->ctx = mmesa; - t->age = 0; - t->bound = 0; + if (!image) return; - - insert_at_tail(&(mmesa->SwappedOut), t); - - t->MemBlock = 0; - /* base image */ - image = tObj->Image[ 0 ]; + tObj->DriverData = t = CALLOC( sizeof( *t ) ); + if (!t) { + fprintf(stderr, "mgaCreateTexObj: Failed to malloc mgaTextureObject\n" ); + return; + } - /* setup hardware register values */ - t->Setup[MGA_TEXREG_CTL] = (TMC_takey_1 | - TMC_tamask_0 | - textureFormat ); + switch( image->Format ) { + case GL_RGB: + case GL_LUMINANCE: + if ( image->IntFormat != GL_RGB5 && ( image->IntFormat == GL_RGB8 || + mmesa->default32BitTextures ) ) { + t->texelBytes = 4; + textureFormat = TMC_tformat_tw32; + } else { + t->texelBytes = 2; + textureFormat = TMC_tformat_tw16; + } + break; + case GL_ALPHA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + case GL_RGBA: + if ( image->IntFormat != GL_RGBA4 && ( image->IntFormat == GL_RGBA8 || + mmesa->default32BitTextures ) ) { + t->texelBytes = 4; + textureFormat = TMC_tformat_tw32; + } else { + t->texelBytes = 2; + textureFormat = TMC_tformat_tw12; + } + break; + case GL_COLOR_INDEX: + textureFormat = TMC_tformat_tw8; + t->texelBytes = 1; + break; + default: + fprintf(stderr, "mgaCreateTexObj: bad image->Format %x/%s\n", + image->Format, + gl_lookup_enum_by_nr(image->Format)); + FREE( t ); + tObj->DriverData = 0; + return; + } + + /* We are going to upload all levels that are present, even if + * later levels wouldn't be used by the current filtering mode. This + * allows the filtering mode to change without forcing another upload + * of the images. + */ + LastLevel = MGA_TEX_MAXLEVELS-1; - if (image->WidthLog2 >= 3) { - t->Setup[MGA_TEXREG_CTL] |= ((image->WidthLog2 - 3) << - TMC_tpitch_SHIFT); - } else { - t->Setup[MGA_TEXREG_CTL] |= (TMC_tpitchlin_enable | - (image->Width << - TMC_tpitchext_SHIFT)); - } + ofs = 0; + for ( i = 0 ; i <= LastLevel ; i++ ) { + if ( !tObj->Image[i] ) { + LastLevel = i - 1; + break; + } + t->offsets[i] = ofs; + t->dirty_images |= (1<<i); - t->Setup[MGA_TEXREG_CTL2] = TMC_ckstransdis_enable; + ofs += ((MAX2( tObj->Image[i]->Width, 8 ) * + MAX2( tObj->Image[i]->Height, 8 ) * + t->texelBytes) + 31) & ~31; + } - if ( mmesa->glCtx->Light.Model.ColorControl == - GL_SEPARATE_SPECULAR_COLOR ) - { - t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; - } - - t->Setup[MGA_TEXREG_FILTER] = (TF_minfilter_nrst | - TF_magfilter_nrst | - TF_filteralpha_enable | - (0x10 << TF_fthres_SHIFT) | - (LastLevel << TF_mapnb_SHIFT)); - - /* warp texture registers */ - if (MGA_IS_G200(mmesa)) { - ofs = 28; - } else { - ofs = 11; - } - - s = image->Width; - s2 = image->WidthLog2; - t->Setup[MGA_TEXREG_WIDTH] = - MGA_FIELD(TW_twmask, s - 1) | - MGA_FIELD(TW_rfw, (10 - s2 - 8) & 63 ) | - MGA_FIELD(TW_tw, (s2 + ofs ) | 0x40 ); + t->totalSize = ofs; + t->lastLevel = LastLevel; + t->tObj = tObj; + t->ctx = mmesa; + t->age = 0; + t->bound = 0; + t->MemBlock = 0; + insert_at_tail(&(mmesa->SwappedOut), t); - s = image->Height; - s2 = image->HeightLog2; - t->Setup[MGA_TEXREG_HEIGHT] = - MGA_FIELD(TH_thmask, s - 1) | - MGA_FIELD(TH_rfh, (10 - s2 - 8) & 63 ) | - MGA_FIELD(TH_th, (s2 + ofs ) | 0x40 ); - - - /* set all the register values for filtering, border, etc */ - mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT ); - mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); - mgaSetTexBorderColor( t, tObj->BorderColor ); - - tObj->DriverData = t; -} - -static void mgaMigrateTexture( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - /* NOT DONE */ -} - -static int mgaChooseTexHeap( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - return 0; -} + /* setup hardware register values */ + t->Setup[MGA_TEXREG_CTL] = (TMC_takey_1 | + TMC_tamask_0 | + textureFormat ); + if (image->WidthLog2 >= 3) + t->Setup[MGA_TEXREG_CTL] |= ((image->WidthLog2 - 3) << TMC_tpitch_SHIFT); + else + t->Setup[MGA_TEXREG_CTL] |= (TMC_tpitchlin_enable | + (image->Width << TMC_tpitchext_SHIFT)); -int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t ) -{ - int heap; - int i; - int ofs; - mgaglx.c_textureSwaps++; - - heap = t->heap = mgaChooseTexHeap( mmesa, t ); - - /* Do we need to eject LRU texture objects? - */ - if (!t->MemBlock) { - while (1) - { - mgaTextureObjectPtr tmp = mmesa->TexObjList[heap].prev; - - t->MemBlock = mmAllocMem( mmesa->texHeap[heap], - t->totalSize, - 6, 0 ); - if (t->MemBlock) - break; - - if (mmesa->TexObjList[heap].prev->bound) { - fprintf(stderr, - "Hit bound texture in upload\n"); - return -1; - } - - if (mmesa->TexObjList[heap].prev == - &(mmesa->TexObjList[heap])) - { - fprintf(stderr, "Failed to upload texture, " - "sz %d\n", t->totalSize); - mmDumpMemInfo( mmesa->texHeap[heap] ); - return -1; - } - - mgaDestroyTexObj( mmesa, tmp ); - } - - ofs = t->MemBlock->ofs - + mmesa->mgaScreen->textureOffset[heap] - ; - t->Setup[MGA_TEXREG_ORG] = ofs; - t->Setup[MGA_TEXREG_ORG1] = ofs + t->offsets[1]; - t->Setup[MGA_TEXREG_ORG2] = ofs + t->offsets[2]; - t->Setup[MGA_TEXREG_ORG3] = ofs + t->offsets[3]; - t->Setup[MGA_TEXREG_ORG4] = ofs + t->offsets[4]; + t->Setup[MGA_TEXREG_CTL2] = TMC_ckstransdis_enable; - mmesa->dirty |= MGA_UPLOAD_CTX; - } - - /* Let the world know we've used this memory recently. - */ - mgaUpdateTexLRU( mmesa, t ); + if ( mmesa->glCtx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ) + t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; - if (MGA_DEBUG&DEBUG_VERBOSE_LRU) - fprintf(stderr, "dispatch age: %d age freed memory: %d\n", - GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge); - - if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa)) - mgaWaitAgeLocked( mmesa, mmesa->dirtyAge ); - - if (t->dirty_images) { - if (MGA_DEBUG&DEBUG_VERBOSE_LRU) - fprintf(stderr, "*"); + t->Setup[MGA_TEXREG_FILTER] = (TF_minfilter_nrst | + TF_magfilter_nrst | + TF_filteralpha_enable | + (0x10 << TF_fthres_SHIFT) | + (LastLevel << TF_mapnb_SHIFT)); + + /* warp texture registers */ + ofs = MGA_IS_G200(mmesa) ? 28 : 11; + s = image->Width; + s2 = image->WidthLog2; + t->Setup[MGA_TEXREG_WIDTH] = (MGA_FIELD(TW_twmask, s - 1) | + MGA_FIELD(TW_rfw, (10 - s2 - 8) & 63 ) | + MGA_FIELD(TW_tw, (s2 + ofs ) | 0x40 )); - for (i = 0 ; i <= t->lastLevel ; i++) - if (t->dirty_images & (1<<i)) - mgaUploadTexLevel( mmesa, t, i ); - } + + s = image->Height; + s2 = image->HeightLog2; + t->Setup[MGA_TEXREG_HEIGHT] = (MGA_FIELD(TH_thmask, s - 1) | + MGA_FIELD(TH_rfh, (10 - s2 - 8) & 63 ) | + MGA_FIELD(TH_th, (s2 + ofs ) | 0x40 )); - t->dirty_images = 0; - return 0; + /* set all the register values for filtering, border, etc */ + mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT ); + mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); + mgaSetTexBorderColor( t, tObj->BorderColor ); } -/* -============================================================================ - -PUBLIC MGA FUNCTIONS - -============================================================================ -*/ static void mgaUpdateTextureEnvG200( GLcontext *ctx ) { - struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current; - mgaTextureObjectPtr t; - - if (!tObj || !tObj->DriverData) - return; - - t = (mgaTextureObjectPtr)tObj->DriverData; - - switch (ctx->Texture.Unit[0].EnvMode) { - case GL_REPLACE: - t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable; - break; - case GL_MODULATE: - t->Setup[MGA_TEXREG_CTL] |= TMC_tmodulate_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable; - break; - case GL_DECAL: - t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_decaldis_enable; - break; - case GL_BLEND: - t->ctx->Fallback |= MGA_FALLBACK_TEXTURE; - break; - default: - break; - } + struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current; + mgaTextureObjectPtr t; + + if (!tObj || !tObj->DriverData) + return; + + t = (mgaTextureObjectPtr)tObj->DriverData; + + switch (ctx->Texture.Unit[0].EnvMode) { + case GL_REPLACE: + t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; + break; + case GL_MODULATE: + t->Setup[MGA_TEXREG_CTL] |= TMC_tmodulate_enable; + break; + case GL_DECAL: + t->Setup[MGA_TEXREG_CTL] &= ~TMC_tmodulate_enable; + break; + case GL_BLEND: + t->ctx->Fallback |= MGA_FALLBACK_TEXTURE; + break; + default: + break; + } } -static void mgaUpdateTextureStage( GLcontext *ctx, int unit ) +static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit]; - GLuint source = mmesa->tmu_source[unit]; - struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current; - - *reg = 0; - if (unit == 1) - *reg = mmesa->Setup[MGA_CTXREG_TDUAL0]; - - if ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) - return; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + GLuint *reg = &mmesa->Setup[MGA_CTXREG_TDUAL0 + unit]; + GLuint source = mmesa->tmu_source[unit]; + struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current; + + if ( tObj != ctx->Texture.Unit[source].CurrentD[2] || + !tObj || + !tObj->Complete || + ((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D ) + return; - if ( ((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D ) - return; - - if (!tObj || !tObj->Complete) - return; - - switch (ctx->Texture.Unit[source].EnvMode) { - case GL_REPLACE: - *reg = (TD0_color_sel_arg1 | - TD0_alpha_sel_arg1 ); - break; - - case GL_MODULATE: - if (unit == 0) - *reg = ( TD0_color_arg2_diffuse | - TD0_color_sel_mul | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_mul); - else - *reg = ( TD0_color_arg2_prevstage | - TD0_color_alpha_prevstage | - TD0_color_sel_mul | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_mul); - break; - case GL_DECAL: - if (unit == 0) - *reg = (TD0_color_arg2_diffuse | - TD0_color_alpha_currtex | - TD0_color_alpha2inv_enable | - TD0_color_arg2mul_alpha2 | - TD0_color_arg1mul_alpha1 | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg2 ); - else - *reg = (TD0_color_arg2_prevstage | - TD0_color_alpha_currtex | - TD0_color_alpha2inv_enable | - TD0_color_arg2mul_alpha2 | - TD0_color_arg1mul_alpha1 | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2 ); - - break; - - case GL_ADD: - if (unit == 0) - *reg = ( TD0_color_arg2_diffuse | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_add); - else - *reg = ( TD0_color_arg2_prevstage | - TD0_color_alpha_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_add); - break; - - case GL_BLEND: - if (0) - fprintf(stderr, "GL_BLEND unit %d flags %x\n", unit, - mmesa->blend_flags); - - if (mmesa->blend_flags) - mmesa->Fallback |= MGA_FALLBACK_TEXTURE; - return; - - /* Do singletexture GL_BLEND with 'all ones' env-color - * by using both texture units. Multitexture gl_blend - * is a fallback. - */ - if (unit == 0) { - /* Part 1: R1 = Rf ( 1 - Rt ) - * A1 = Af At - */ - *reg = ( TD0_color_arg2_diffuse | - TD0_color_arg1_inv_enable | - TD0_color_sel_mul | - TD0_alpha_arg2_diffuse | - TD0_alpha_sel_arg1); - } else { - /* Part 2: R2 = R1 + Rt - * A2 = A1 - */ - *reg = ( TD0_color_arg2_prevstage | - TD0_color_add_add | - TD0_color_sel_add | - TD0_alpha_arg2_prevstage | - TD0_alpha_sel_arg2); - } - - break; - default: - break; - } -} + switch (ctx->Texture.Unit[source].EnvMode) { + case GL_REPLACE: + *reg = (TD0_color_sel_arg1 | + TD0_alpha_sel_arg1 ); + break; + + case GL_MODULATE: + if (unit == 0) + *reg = ( TD0_color_arg2_diffuse | + TD0_color_sel_mul | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_mul); + else + *reg = ( TD0_color_arg2_prevstage | + TD0_color_alpha_prevstage | + TD0_color_sel_mul | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_mul); + break; + case GL_DECAL: + if (tObj->Image[0]->Format == GL_RGB) + *reg = (TD0_color_sel_arg1 | + TD0_alpha_sel_arg1 ); + else if (unit == 0) + *reg = (TD0_color_arg2_diffuse | + TD0_color_alpha_currtex | + TD0_color_alpha2inv_enable | + TD0_color_arg2mul_alpha2 | + TD0_color_arg1mul_alpha1 | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_arg2 ); + else + *reg = (TD0_color_arg2_prevstage | + TD0_color_alpha_currtex | + TD0_color_alpha2inv_enable | + TD0_color_arg2mul_alpha2 | + TD0_color_arg1mul_alpha1 | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_arg2 ); + + break; + + case GL_ADD: + if (unit == 0) + *reg = ( TD0_color_arg2_diffuse | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_add); + else + *reg = ( TD0_color_arg2_prevstage | + TD0_color_alpha_prevstage | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_add); + break; + + case GL_BLEND: + if (mmesa->blend_flags) + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + + /* Do singletexture GL_BLEND with 'all ones' env-color + * by using both texture units. Multitexture gl_blend + * is a fallback. + */ + if (unit == 0) { + /* Part 1: R1 = Rf ( 1 - Rt ) + * A1 = Af At + */ + *reg = ( TD0_color_arg2_diffuse | + TD0_color_arg1_inv_enable | + TD0_color_sel_mul | + TD0_alpha_arg2_diffuse | + TD0_alpha_sel_arg1); + } else { + /* Part 2: R2 = R1 + Rt + * A2 = A1 + */ + *reg = ( TD0_color_arg2_prevstage | + TD0_color_add_add | + TD0_color_sel_add | + TD0_alpha_arg2_prevstage | + TD0_alpha_sel_arg2); + } + break; + default: + break; + } +} -static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) { - mgaTextureObjectPtr t; - struct gl_texture_object *tObj; - GLuint enabled; - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - GLuint source = mmesa->tmu_source[unit]; - - mgaMsg(15,"mgaUpdateTextureState %d\n", unit); - - /* disable texturing until it is known to be good */ - mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK; - mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_trap; - - enabled = (ctx->Texture.Enabled>>(source*4))&TEXTURE0_ANY; - if (enabled != TEXTURE0_2D) { - if (enabled) - mmesa->Fallback |= MGA_FALLBACK_TEXTURE; - return; - } - tObj = ctx->Texture.Unit[source].Current; +static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) +{ + mgaTextureObjectPtr t; + struct gl_texture_object *tObj; + GLuint enabled; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + GLuint source = mmesa->tmu_source[unit]; - if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) - return; -/* fprintf(stderr, "unit %d: %d\n", unit, tObj->Name); */ - - /* if the texture object doesn't exist at all (never used or - swapped out), create it now, uploading all texture images */ + enabled = (ctx->Texture.ReallyEnabled>>(source*4))&TEXTURE0_ANY; + tObj = ctx->Texture.Unit[source].Current; - if ( !tObj->DriverData ) { - /* clear the current pointer so that texture object can be - swapped out if necessary to make room */ - mgaCreateTexObj( mmesa, tObj ); + if (enabled != TEXTURE0_2D) { + if (enabled) + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + return; + } - if ( !tObj->DriverData ) { - mgaMsg( 5, "mgaUpdateTextureState: create failed\n" ); - mmesa->Fallback |= MGA_FALLBACK_TEXTURE; - return; /* can't create a texture object */ - } - } + if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) { + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + return; + } - /* we definately have a valid texture now */ - mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK; - mmesa->Setup[MGA_CTXREG_DWGCTL] |= DC_opcod_texture_trap; +/* if (!tObj) tObj = ctx->Texture.Unit[0].Current; */ +/* if (!tObj) return; */ - t = (mgaTextureObjectPtr)tObj->DriverData; + if ( !tObj->DriverData ) { + mgaCreateTexObj( mmesa, tObj ); + if ( !tObj->DriverData ) { + mmesa->Fallback |= MGA_FALLBACK_TEXTURE; + return; + } + } - if (t->dirty_images) - mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit); + t = (mgaTextureObjectPtr)tObj->DriverData; - mmesa->CurrentTexObj[unit] = t; - t->bound = unit+1; + if (t->dirty_images) + mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit); - if (t->MemBlock) - mgaUpdateTexLRU( mmesa, t ); + mmesa->CurrentTexObj[unit] = t; + t->bound |= unit+1; +/* if (t->MemBlock) */ +/* mgaUpdateTexLRU( mmesa, t ); */ - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable; - if (ctx->Texture.Enabled == (TEXTURE0_2D|TEXTURE1_2D)) - t->Setup[MGA_TEXREG_CTL2] |= TMC_dualtex_enable; + t->Setup[MGA_TEXREG_CTL2] &= ~TMC_dualtex_enable; + if (mmesa->multitex) + t->Setup[MGA_TEXREG_CTL2] |= TMC_dualtex_enable; - t->Setup[MGA_TEXREG_CTL2] &= ~TMC_specen_enable; - if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; - + t->Setup[MGA_TEXREG_CTL2] &= ~TMC_specen_enable; + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + t->Setup[MGA_TEXREG_CTL2] |= TMC_specen_enable; } @@ -1065,278 +499,259 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit ) { */ void mgaUpdateTextureState( GLcontext *ctx ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE; - - if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->bound = 0; - if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->bound = 0; - mmesa->CurrentTexObj[0] = 0; - mmesa->CurrentTexObj[1] = 0; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE; - if (MGA_IS_G400(mmesa)) { - mgaUpdateTextureObject( ctx, 0 ); - mgaUpdateTextureStage( ctx, 0 ); + if (mmesa->CurrentTexObj[0]) { + mmesa->CurrentTexObj[0]->bound = 0; + mmesa->CurrentTexObj[0] = 0; + } - mmesa->Setup[MGA_CTXREG_TDUAL1] = - mmesa->Setup[MGA_CTXREG_TDUAL0]; + if (mmesa->CurrentTexObj[1]) { + mmesa->CurrentTexObj[1]->bound = 0; + mmesa->CurrentTexObj[1] = 0; + } - if (mmesa->multitex) { - mgaUpdateTextureObject( ctx, 1 ); - mgaUpdateTextureStage( ctx, 1 ); - } - - mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1; - } else { - mgaUpdateTextureObject( ctx, 0 ); - mgaUpdateTextureEnvG200( ctx ); - } - - /* schedule the register writes */ - mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0; -} + if (MGA_IS_G400(mmesa)) { + mgaUpdateTextureObject( ctx, 0 ); + mgaUpdateTextureEnvG400( ctx, 0 ); + + mmesa->Setup[MGA_CTXREG_TDUAL1] = mmesa->Setup[MGA_CTXREG_TDUAL0]; + + if (mmesa->multitex || 1) { + mgaUpdateTextureObject( ctx, 1 ); + mgaUpdateTextureEnvG400( ctx, 1 ); + } +/* else */ +/* mmesa->Setup[MGA_CTXREG_TDUAL1] = ( TD0_color_arg2_prevstage | */ +/* TD0_color_sel_arg2 | */ +/* TD0_alpha_arg2_prevstage | */ +/* TD0_alpha_sel_arg2); */ + + + mmesa->dirty |= MGA_UPLOAD_TEX1; + } else { + mgaUpdateTextureObject( ctx, 0 ); + mgaUpdateTextureEnvG200( ctx ); + } + mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0; + mmesa->Setup[MGA_CTXREG_DWGCTL] &= DC_opcod_MASK; + mmesa->Setup[MGA_CTXREG_DWGCTL] |= (ctx->Texture.ReallyEnabled + ? DC_opcod_texture_trap + : DC_opcod_trap); +} -/* -============================================================================ -Driver functions called directly from mesa -============================================================================ -*/ -/* - * mgaTexEnv - */ -void mgaTexEnv( GLcontext *ctx, GLenum target, - GLenum pname, const GLfloat *param ) +static void mgaDDTexEnv( GLcontext *ctx, GLenum target, + GLenum pname, const GLfloat *param ) { - mgaContextPtr mmesa = MGA_CONTEXT(ctx); - mgaMsg( 10, "mgaTexEnv( %i )\n", pname ); - - - if (pname == GL_TEXTURE_ENV_MODE) { - /* force the texture state to be updated */ - FLUSH_BATCH( MGA_CONTEXT(ctx) ); - MGA_CONTEXT(ctx)->new_state |= (MGA_NEW_TEXTURE | - MGA_NEW_ALPHA); - } - else if (pname == GL_TEXTURE_ENV_COLOR) - { - struct gl_texture_unit *texUnit = - &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - GLfloat *fc = texUnit->EnvColor; - GLubyte c[4]; - GLuint col; - - - c[0] = fc[0]; - c[1] = fc[1]; - c[2] = fc[2]; - c[3] = fc[3]; + mgaContextPtr mmesa = MGA_CONTEXT(ctx); - col = mgaPackColor( mmesa->mgaScreen->cpp, - c[0], c[1], c[2], c[3] ); - mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]); + if (pname == GL_TEXTURE_ENV_MODE) { + /* force the texture state to be updated */ + FLUSH_BATCH( MGA_CONTEXT(ctx) ); + MGA_CONTEXT(ctx)->new_state |= (MGA_NEW_TEXTURE | + MGA_NEW_ALPHA); + } + else if (pname == GL_TEXTURE_ENV_COLOR) + { + struct gl_texture_unit *texUnit = + &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + GLfloat *fc = texUnit->EnvColor; + GLubyte c[4]; + GLuint col; + + COPY_4V(c, fc); + col = mgaPackColor( mmesa->mgaScreen->cpp, c[0], c[1], c[2], c[3] ); + mmesa->envcolor = (c[3]<<24) | (c[0]<<16) | (c[1]<<8) | (c[2]); - if (mmesa->Setup[MGA_CTXREG_FCOL] != col) { - FLUSH_BATCH(mmesa); - mmesa->Setup[MGA_CTXREG_FCOL] = col; - mmesa->dirty |= MGA_UPLOAD_CTX; - - mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR; - - /* Actually just require all four components to be - * equal. This permits a single-pass GL_BLEND. - * - * More complex multitexture/multipass fallbacks - * for blend can be done later. - */ - if (mmesa->envcolor != 0x0 && - mmesa->envcolor != 0xffffffff) - mmesa->blend_flags |= MGA_BLEND_ENV_COLOR; - } - } - + if (mmesa->Setup[MGA_CTXREG_FCOL] != col) { + FLUSH_BATCH(mmesa); + mmesa->Setup[MGA_CTXREG_FCOL] = col; + mmesa->dirty |= MGA_UPLOAD_CTX; + + mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR; + + /* Actually just require all four components to be + * equal. This permits a single-pass GL_BLEND. + * + * More complex multitexture/multipass fallbacks + * for blend can be done later. + */ + if (mmesa->envcolor != 0x0 && mmesa->envcolor != 0xffffffff) + mmesa->blend_flags |= MGA_BLEND_ENV_COLOR; + } + } } -/* - * mgaTexImage - */ -void mgaTexImage( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint internalFormat, - const struct gl_texture_image *image ) + +static void mgaDDTexImage( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint internalFormat, + const struct gl_texture_image *image ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t; - mgaMsg( 10,"mgaTexImage( %p, level %i )\n", tObj, level ); - - /* just free the mga texture if it exists, it will be recreated at - mgaUpdateTextureState time. */ - t = (mgaTextureObjectPtr) tObj->DriverData; - if ( t ) { - if (t->bound) FLUSH_BATCH(mmesa); - /* if this is the current object, it will force an update */ - mgaDestroyTexObj( mmesa, t ); - mmesa->new_state |= MGA_NEW_TEXTURE; - } + /* just free the mga texture if it exists, it will be recreated at + mgaUpdateTextureState time. */ + t = (mgaTextureObjectPtr) tObj->DriverData; + if ( t ) { + if (t->bound) FLUSH_BATCH(mmesa); + /* if this is the current object, it will force an update */ + mgaDestroyTexObj( mmesa, t ); + mmesa->new_state |= MGA_NEW_TEXTURE; + } + + if (0) + fprintf(stderr, "mgaDDTexImage tObj %p, level %d, image %p\n", + tObj, level, image); + } -/* - * mgaTexSubImage - */ -void mgaTexSubImage( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLint internalFormat, - const struct gl_texture_image *image ) +static void mgaDDTexSubImage( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLint internalFormat, + const struct gl_texture_image *image ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t; - - mgaMsg(10,"mgaTexSubImage() Size: %d,%d of %d,%d; Level %d\n", - width, height, image->Width,image->Height, level); + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t; - t = (mgaTextureObjectPtr) tObj->DriverData; + t = (mgaTextureObjectPtr) tObj->DriverData; - /* just free the mga texture if it exists, it will be recreated at - mgaUpdateTextureState time. */ - t = (mgaTextureObjectPtr) tObj->DriverData; - if ( t ) { - if (t->bound) FLUSH_BATCH(mmesa); - /* if this is the current object, it will force an update */ - mgaDestroyTexObj( mmesa, t ); - mmesa->new_state |= MGA_NEW_TEXTURE; - } + /* just free the mga texture if it exists, it will be recreated at + mgaUpdateTextureState time. */ + t = (mgaTextureObjectPtr) tObj->DriverData; + if ( t ) { + if (t->bound) FLUSH_BATCH(mmesa); + /* if this is the current object, it will force an update */ + mgaDestroyTexObj( mmesa, t ); + mmesa->new_state |= MGA_NEW_TEXTURE; + } #if 0 - /* the texture currently exists, so directly update it */ - mgaUploadSubImage( t, level, xoffset, yoffset, width, height ); + /* the texture currently exists, so directly update it */ + mgaUploadSubImage( t, level, xoffset, yoffset, width, height ); #endif } + + /* * mgaTexParameter * This just changes variables and flags for a state update, which * will happen at the next mgaUpdateTextureState */ -void mgaTexParameter( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) +static void +mgaDDTexParameter( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, + GLenum pname, const GLfloat *params ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t; - - mgaMsg( 10, "mgaTexParameter( %p, %i )\n", tObj, pname ); - - t = (mgaTextureObjectPtr) tObj->DriverData; - - /* if we don't have a hardware texture, it will be automatically - created with current state before it is used, so we don't have - to do anything now */ - if ( !t || target != GL_TEXTURE_2D ) { - return; - } - - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - if (t->bound) FLUSH_BATCH(mmesa); - mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - if (t->bound) FLUSH_BATCH(mmesa); - mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT); - break; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t; + + t = (mgaTextureObjectPtr) tObj->DriverData; + + /* if we don't have a hardware texture, it will be automatically + created with current state before it is used, so we don't have + to do anything now */ + if ( !t || !t->bound || target != GL_TEXTURE_2D ) { + return; + } + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + FLUSH_BATCH(mmesa); + mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter ); + break; + + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + FLUSH_BATCH(mmesa); + mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT); + break; - case GL_TEXTURE_BORDER_COLOR: - if (t->bound) FLUSH_BATCH(mmesa); - mgaSetTexBorderColor(t,tObj->BorderColor); - break; + case GL_TEXTURE_BORDER_COLOR: + FLUSH_BATCH(mmesa); + mgaSetTexBorderColor(t,tObj->BorderColor); + break; - default: - return; - } + default: + return; + } - mmesa->new_state |= MGA_NEW_TEXTURE; + mmesa->new_state |= MGA_NEW_TEXTURE; } -/* - * mgaBindTexture - */ -void mgaBindTexture( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaMsg( 10, "mgaBindTexture( %p )\n", tObj ); +static void +mgaDDBindTexture( GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj ) +{ + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + int unit = ctx->Texture.CurrentUnit; - FLUSH_BATCH(mmesa); + FLUSH_BATCH(mmesa); - if (mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]) { - mmesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0; - mmesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0; - } + if (mmesa->CurrentTexObj[unit]) { + mmesa->CurrentTexObj[unit]->bound &= ~(unit+1); + mmesa->CurrentTexObj[unit] = 0; + } - /* force the texture state to be updated - */ - MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; + /* force the texture state to be updated + */ + MGA_CONTEXT(ctx)->new_state |= MGA_NEW_TEXTURE; } -/* - * mgaDeleteTexture - */ -void mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) + +static void +mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData; + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData; + + if ( t ) { + if (t->bound) { + FLUSH_BATCH(mmesa); + if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0; + if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0; + mmesa->new_state |= MGA_NEW_TEXTURE; + } - mgaMsg( 10, "mgaDeleteTexture( %p )\n", tObj ); - - if ( t ) { - if (t->bound) { - FLUSH_BATCH(mmesa); - mmesa->CurrentTexObj[t->bound-1] = 0; - mmesa->new_state |= MGA_NEW_TEXTURE; - } - - mgaDestroyTexObj( mmesa, t ); - mmesa->new_state |= MGA_NEW_TEXTURE; - } + mgaDestroyTexObj( mmesa, t ); + mmesa->new_state |= MGA_NEW_TEXTURE; + } } -/* Have to grab the lock to find out if anyone has kicked out our - * textures. - */ -GLboolean mgaIsTextureResident( GLcontext *ctx, struct gl_texture_object *t ) +static GLboolean +mgaDDIsTextureResident( GLcontext *ctx, struct gl_texture_object *t ) { - mgaTextureObjectPtr mt; - -/* LOCK_HARDWARE; */ - mt = (mgaTextureObjectPtr)t->DriverData; -/* UNLOCK_HARDWARE; */ - - return mt && mt->MemBlock; + mgaTextureObjectPtr mt = (mgaTextureObjectPtr)t->DriverData; + return mt && mt->MemBlock; } -void mgaDDInitTextureFuncs( GLcontext *ctx ) + +void +mgaDDInitTextureFuncs( GLcontext *ctx ) { - ctx->Driver.TexEnv = mgaTexEnv; - ctx->Driver.TexImage = mgaTexImage; - ctx->Driver.TexSubImage = mgaTexSubImage; - ctx->Driver.BindTexture = mgaBindTexture; - ctx->Driver.DeleteTexture = mgaDeleteTexture; - ctx->Driver.TexParameter = mgaTexParameter; + ctx->Driver.TexEnv = mgaDDTexEnv; + ctx->Driver.TexImage = mgaDDTexImage; + ctx->Driver.TexSubImage = mgaDDTexSubImage; + ctx->Driver.BindTexture = mgaDDBindTexture; + ctx->Driver.DeleteTexture = mgaDDDeleteTexture; + ctx->Driver.TexParameter = mgaDDTexParameter; ctx->Driver.UpdateTexturePalette = 0; - ctx->Driver.IsTextureResident = mgaIsTextureResident; + ctx->Driver.IsTextureResident = mgaDDIsTextureResident; } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.c b/xc/lib/GL/mesa/src/drv/mga/mgatris.c index bf38066ee..d63796946 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgatris.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.c @@ -33,22 +33,27 @@ #include "pipeline.h" #include "mm.h" -#include "mgalib.h" +#include "mgacontext.h" #include "mgatris.h" #include "mgavb.h" -#include "mgalog.h" static void mga_null_quad( GLcontext *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint v3, GLuint pv ) { + GLuint v1, GLuint v2, GLuint v3, GLuint pv ) +{ } + static void mga_null_triangle( GLcontext *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint pv ) { + GLuint v1, GLuint v2, GLuint pv ) +{ } -static void mga_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) { + +static void mga_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) +{ } -static void mga_null_points( GLcontext *ctx, GLuint first, GLuint last ) { +static void mga_null_points( GLcontext *ctx, GLuint first, GLuint last ) +{ } @@ -66,17 +71,6 @@ static quad_func quad_tab[0x10]; static line_func line_tab[0x10]; static points_func points_tab[0x10]; -static void mgaPrintRenderState( const char *msg, GLuint state ) -{ - fprintf(stderr, "%s: (%x) %s%s%s%s%s\n", - msg, state, - (state & MGA_FLAT_BIT) ? "flat, " : "", - (state & MGA_OFFSET_BIT) ? "offset, " : "", - (state & MGA_TWOSIDE_BIT) ? "twoside, " : "", - (state & MGA_NODRAW_BIT) ? "no-draw, " : "", - (state & MGA_FALLBACK_BIT) ? "fallback" : ""); -} - #define IND (0) #define TAG(x) x #include "mgatritmp.h" @@ -148,8 +142,8 @@ void mgaDDTrifuncInit() void mgaDDChooseRenderState(GLcontext *ctx) { mgaContextPtr mmesa = MGA_CONTEXT(ctx); - GLuint flags = ctx->TriangleCaps; - CARD32 index = 0; + GLuint flags = ctx->TriangleCaps; + GLuint index = 0; if (mmesa->Fallback) { mmesa->renderindex = MGA_FALLBACK_BIT; @@ -203,8 +197,3 @@ void mgaDDChooseRenderState(GLcontext *ctx) } } } - - - - - diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.h b/xc/lib/GL/mesa/src/drv/mga/mgatris.h index 038d11689..6fcf73d58 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgatris.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.h @@ -41,47 +41,123 @@ extern void mgaDDTrifuncInit( void ); #define MGA_NODRAW_BIT 0x8 #define MGA_FALLBACK_BIT 0x10 - - +extern int nrswaps; + + +#define VERTSIZE vertsize + +/* static float _v0[] = { */ +/* 242.202515, */ +/* 250.469604, */ +/* 0.961081, */ +/* 0.013503, */ +/* 0, */ +/* 0.000000, */ +/* 2.600000, */ +/* 0.000000, */ +/* 1.000000, */ +/* 0.600000 */ +/* }; */ + +/* static float _v1[] = { */ +/* 246.448914, */ +/* 54.697876, */ +/* 0.953817, */ +/* 0.014156, */ +/* 0, */ +/* 0.000000, */ +/* 2.600000, */ +/* 2.000000, */ +/* 1.000000, */ +/* 1.600000 */ +/* }; */ + +/* static float _v2[] = { */ +/* 55.999474, */ +/* 85.196106, */ +/* 0.942609, */ +/* 0.015165, */ +/* 0, */ +/* 0.000000, */ +/* 0.600000, */ +/* 2.000000, */ +/* 0.000000, */ +/* 1.600000, */ +/* }; */ static __inline void mga_draw_triangle( mgaContextPtr mmesa, mgaVertex *v0, mgaVertex *v1, mgaVertex *v2 ) { - mgaUI32 vertsize = mmesa->vertsize; - mgaUI32 *wv = mgaAllocVertexDwordsInline( mmesa, 3 * vertsize ); + GLuint vertsize = mmesa->vertsize; + GLuint *wv = mgaAllocVertexDwordsInline( mmesa, 3 * VERTSIZE ); int j; + (void) vertsize; + +/* for (j = 0 ; j < vertsize ; j++) */ +/* fprintf(stderr, "v0 %d: %f 0x%x\n", j, v0->f[j], v0->ui[j]); */ + +/* for (j = 0 ; j < vertsize ; j++) */ +/* fprintf(stderr, "v1 %d: %f 0x%x\n", j, v1->f[j], v1->ui[j]); */ + +/* for (j = 0 ; j < vertsize ; j++) */ +/* fprintf(stderr, "v2 %d: %f 0x%x\n", j, v2->f[j], v2->ui[j]); */ + +/* v0 = (mgaVertex *)_v0; */ +/* v1 = (mgaVertex *)_v1; */ +/* v2 = (mgaVertex *)_v2; */ + + +/* if (v0->v.x < 0 || v0->v.x > 1920 || */ +/* v0->v.y < 0 || v0->v.y > 1440 || */ +/* v0->v.z < 0 || v0->v.z > 1) */ +/* fprintf(stderr, "v0 %f %f %f %f\n", v0->v.x, v0->v.y, v0->v.z, v0->v.rhw); */ + + +/* if (v1->v.x < 0 || v1->v.x > 1920 || */ +/* v1->v.y < 0 || v1->v.y > 1440 || */ +/* v1->v.z < 0 || v1->v.z > 1) */ +/* fprintf(stderr, "v1 %f %f %f %f\n", v1->v.x, v1->v.y, v1->v.z, v1->v.rhw); */ + +/* if (v2->v.x < 0 || v2->v.x > 1920 || */ +/* v2->v.y < 0 || v2->v.y > 1440 || */ +/* v2->v.z < 0 || v2->v.z > 1) */ +/* fprintf(stderr, "v2 %f %f %f %f\n", v2->v.x, v2->v.y, v2->v.z, v2->v.rhw); */ + + #if defined (USE_X86_ASM) - /* GTH: We can safely assume the vertex stride is some number of - * dwords, and thus a "rep movsd" is okay. The vb pointer is - * automagically updated with this instruction, so we don't have - * to manually take care of incrementing it. - */ - __asm__ __volatile__( "rep ; movsl" - : "=%c" (j) - : "0" (vertsize), "D" ((long)wv), "S" ((long)v0) - : "memory" ); - __asm__ __volatile__( "rep ; movsl" - : "=%c" (j) - : "0" (vertsize), "S" ((long)v1) - : "memory" ); - __asm__ __volatile__( "rep ; movsl" - : "=%c" (j) - : "0" (vertsize), "S" ((long)v2) - : "memory" ); + /* GTH: We can safely assume the vertex stride is some number of + * dwords, and thus a "rep movsd" is okay. The vb pointer is + * automagically updated with this instruction, so we don't have + * to manually take care of incrementing it. + */ + __asm__ __volatile__( "rep ; movsl" + : "=%c" (j) + : "0" (VERTSIZE), "D" ((long)wv), "S" ((long)v0) + : "memory" ); + __asm__ __volatile__( "rep ; movsl" + : "=%c" (j) + : "0" (VERTSIZE), "S" ((long)v1) + : "memory" ); + __asm__ __volatile__( "rep ; movsl" + : "=%c" (j) + : "0" (VERTSIZE), "S" ((long)v2) + : "memory" ); #else - for (j = 0 ; j < vertsize ; j++) - wv[j] = v0->ui[j]; + { + for (j = 0 ; j < vertsize ; j++) + wv[j] = v0->ui[j]; - wv += vertsize; - for (j = 0 ; j < vertsize ; j++) - wv[j] = v1->ui[j]; + wv += VERTSIZE; + for (j = 0 ; j < vertsize ; j++) + wv[j] = v1->ui[j]; - wv += vertsize; - for (j = 0 ; j < vertsize ; j++) - wv[j] = v2->ui[j]; + wv += VERTSIZE; + for (j = 0 ; j < vertsize ; j++) + wv[j] = v2->ui[j]; + } #endif } @@ -89,39 +165,39 @@ static __inline void mga_draw_triangle( mgaContextPtr mmesa, static __inline void mga_draw_point( mgaContextPtr mmesa, mgaVertex *tmp, float sz ) { - mgaUI32 vertsize = mmesa->vertsize; - mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6*vertsize); + GLuint vertsize = mmesa->vertsize; + GLuint *wv = mgaAllocVertexDwords( mmesa, 6*VERTSIZE); int j; *(float *)&wv[0] = tmp->v.x - sz; *(float *)&wv[1] = tmp->v.y - sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x + sz; *(float *)&wv[1] = tmp->v.y - sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x + sz; *(float *)&wv[1] = tmp->v.y + sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x + sz; *(float *)&wv[1] = tmp->v.y + sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x - sz; *(float *)&wv[1] = tmp->v.y + sz; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp->v.x - sz; *(float *)&wv[1] = tmp->v.y - sz; @@ -135,8 +211,8 @@ static __inline void mga_draw_line( mgaContextPtr mmesa, const mgaVertex *tmp1, float width ) { - mgaUI32 vertsize = mmesa->vertsize; - mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6 * vertsize ); + GLuint vertsize = mmesa->vertsize; + GLuint *wv = mgaAllocVertexDwords( mmesa, 6 * VERTSIZE ); float dx, dy, ix, iy; int j; @@ -156,37 +232,37 @@ static __inline void mga_draw_line( mgaContextPtr mmesa, *(float *)&wv[1] = tmp0->v.y - iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp0->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp1->v.x + ix; *(float *)&wv[1] = tmp1->v.y + iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp1->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp0->v.x + ix; *(float *)&wv[1] = tmp0->v.y + iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp0->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp0->v.x - ix; *(float *)&wv[1] = tmp0->v.y - iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp0->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp1->v.x - ix; *(float *)&wv[1] = tmp1->v.y - iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp1->ui[j]; - wv += vertsize; + wv += VERTSIZE; *(float *)&wv[0] = tmp1->v.x + ix; *(float *)&wv[1] = tmp1->v.y + iy; for (j = 2 ; j < vertsize ; j++) wv[j] = tmp1->ui[j]; - wv += vertsize; + wv += VERTSIZE; } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c index cc9066fda..dec13514a 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c @@ -25,9 +25,10 @@ */ /* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.c,v 1.5 2000/08/28 02:43:13 tsi Exp $ */ -#include "mgalib.h" +#include "mgacontext.h" #include "mgavb.h" -#include "mgalog.h" +#include "mga_xmesa.h" + #include "stages.h" #include "mem.h" @@ -83,12 +84,13 @@ } -#define COORD \ - GLfloat *win = VB->Win.data[i]; \ +#define COORD \ + GLfloat *win = VB->Win.data[i]; \ v->v.rhw = win[3]; \ v->v.z = depth_scale * win[2]; \ - v->v.x = win[0] + xoffset; \ - v->v.y = - win[1] + yoffset; + v->v.x = win[0] + xoffset; \ + v->v.y = - win[1] + yoffset; + #define NOP @@ -181,7 +183,7 @@ SETUPFUNC(rs_gfst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,FOG) static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end) { - mgaError("mgaRasterSetup(): invalid combination\n"); + fprintf(stderr, "mgaRasterSetup(): invalid combination\n"); } typedef void (*setupFunc)(struct vertex_buffer *,GLuint,GLuint); @@ -256,6 +258,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) { mgaContextPtr mmesa = MGA_CONTEXT( ctx ); int funcindex = (MGA_WIN_BIT | MGA_RGBA_BIT); + int multi = mmesa->multitex; mmesa->vertsize = 8; mmesa->tmu_source[0] = 0; @@ -265,7 +268,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) mmesa->multitex = 0; mmesa->blend_flags &= ~MGA_BLEND_MULTITEX; - if (ctx->Texture.Enabled & 0xf) { + if (ctx->Texture.ReallyEnabled & 0xf) { /* This doesn't work for non-RGBA textures if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) funcindex &= ~MGA_RGBA_BIT; @@ -282,8 +285,8 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) funcindex |= MGA_TEX0_BIT; } - if (ctx->Texture.Enabled & 0xf0) { - if (ctx->Texture.Enabled & 0xf) { + if (ctx->Texture.ReallyEnabled & 0xf0) { + if (ctx->Texture.ReallyEnabled & 0xf) { mmesa->multitex = 1; mmesa->vertsize = 10; mmesa->blend_flags |= MGA_BLEND_MULTITEX; @@ -312,6 +315,19 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) } } +/* if (mmesa->multitex == 0) { */ +/* mmesa->tmu_source[1] = mmesa->tmu_source[0]; */ +/* mmesa->tex_dest[1] = mmesa->tex_dest[0]; */ +/* mmesa->vertsize = 10; */ +/* mmesa->multitex = 1; */ +/* funcindex |= MGA_TEX0_BIT|MGA_TEX1_BIT; */ +/* } */ + +/* mmesa->vertsize = 10; */ + if (multi != mmesa->multitex) + mmesa->new_state |= MGA_NEW_WARP; + + /* Not really a good place to do this - need to make the mga state * management code more event-driven so this can be calculated for * free. @@ -423,11 +439,6 @@ static void FatalError( char *s ) } -#ifndef ALIGN_MALLOC -#define ALIGN_MALLOC(x,y) malloc(y) -#define ALIGN_FREE free -#endif - void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size ) { mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB); @@ -435,8 +446,8 @@ void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size ) while (mvb->size < size) mvb->size *= 2; - free( mvb->vert_store ); - mvb->vert_store = malloc( sizeof(mgaVertex) * mvb->size + 31); + FREE( mvb->vert_store ); + mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31); if (!mvb->vert_store) FatalError("mga-glx: out of memory !\n"); @@ -448,15 +459,15 @@ void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size ) FatalError("mga-glx: out of memory !\n"); ALIGN_FREE( VB->ClipMask ); - VB->ClipMask = (GLubyte *)ALIGN_MALLOC(4, sizeof(GLubyte) * mvb->size); + VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32); if (!VB->ClipMask) FatalError("mga-glx: out of memory !\n"); if (VB->Type == VB_IMMEDIATE) { - free( mvb->primitive ); - free( mvb->next_primitive ); - mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); - mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); + FREE( mvb->primitive ); + FREE( mvb->next_primitive ); + mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); + mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); if (!mvb->primitive || !mvb->next_primitive) FatalError("mga-glx: out of memory!"); } @@ -467,14 +478,14 @@ void mgaDDRegisterVB( struct vertex_buffer *VB ) { mgaVertexBufferPtr mvb; - mvb = (mgaVertexBufferPtr)calloc( 1, sizeof(*mvb) ); + mvb = (mgaVertexBufferPtr)MALLOC( sizeof(*mvb) ); /* This looks like it allocates a lot of memory, but it basically * just sets an upper limit on how much can be used - nothing like * this amount will ever be turned into 'real' memory. */ mvb->size = VB->Size * 5; - mvb->vert_store = malloc( sizeof(mgaVertex) * mvb->size + 31); + mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31); if (!mvb->vert_store) FatalError("mga-glx: out of memory !\n"); @@ -485,12 +496,12 @@ void mgaDDRegisterVB( struct vertex_buffer *VB ) FatalError("mga-glx: out of memory !\n"); ALIGN_FREE( VB->ClipMask ); - VB->ClipMask = (GLubyte *)ALIGN_MALLOC(4, sizeof(GLubyte) * mvb->size); + VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32); if (!VB->ClipMask) FatalError("mga-glx: out of memory !\n"); - mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); - mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size ); + mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); + mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size ); if (!mvb->primitive || !mvb->next_primitive) FatalError("mga-glx: out of memory!"); @@ -503,11 +514,11 @@ void mgaDDUnregisterVB( struct vertex_buffer *VB ) mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB); if (mvb) { - if (mvb->vert_store) free(mvb->vert_store); - if (mvb->primitive) free(mvb->primitive); - if (mvb->next_primitive) free(mvb->next_primitive); + if (mvb->vert_store) FREE(mvb->vert_store); + if (mvb->primitive) FREE(mvb->primitive); + if (mvb->next_primitive) FREE(mvb->next_primitive); gl_vector1ui_free( &mvb->clipped_elements ); - free(mvb); + FREE(mvb); VB->driver_data = 0; } } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.h b/xc/lib/GL/mesa/src/drv/mga/mgavb.h index cc902ae0f..c79fd5b6e 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgavb.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.h @@ -30,7 +30,6 @@ #include "types.h" #include "vb.h" -#include "mgacommon.h" /* common datatypes for the mga warp engines */ @@ -67,7 +66,7 @@ typedef struct mga_warp_vertex_t { union mga_vertex_t { mga_warp_vertex v; float f[16]; - mgaUI32 ui[16]; + GLuint ui[16]; }; typedef union mga_vertex_t mgaVertex; @@ -82,9 +81,9 @@ struct mga_vertex_buffer_t { void *vert_store; GLuint size; - mgaUI32 *vert_buf; - mgaUI32 *elt_buf; - mgaUI32 vert_phys_start; + GLuint *vert_buf; + GLuint *elt_buf; + GLuint vert_phys_start; }; typedef struct mga_vertex_buffer_t *mgaVertexBufferPtr; diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile b/xc/lib/GL/mesa/src/drv/r128/Imakefile index 049428b46..3b6e0a2b5 100644 --- a/xc/lib/GL/mesa/src/drv/r128/Imakefile +++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile @@ -262,8 +262,7 @@ MESA_INCLUDES = -I. -I.. -I../../include \ MMX_OBJS = ../../X86/mmx_blend.o -XCOMM Disabling 3Dnow code for the time being. -#if 0 +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c index bb846701c..326b0b6e6 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c @@ -40,7 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_cce.h" #include "r128_state.h" #include "r128_vb.h" - +#include "mem.h" #include "stages.h" #define TEX0 \ @@ -423,8 +423,8 @@ void r128DDResizeVB(struct vertex_buffer *VB, GLuint size) exit(1); } - free(VB->ClipMask); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size); + ALIGN_FREE(VB->ClipMask); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * r128vb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "Cannot allocate clipmask! Exiting...\n"); exit(1); @@ -454,8 +454,8 @@ void r128DDRegisterVB(struct vertex_buffer *VB) exit(1); } - free(VB->ClipMask); - VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size); + ALIGN_FREE(VB->ClipMask); + VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * r128vb->size, 4); if (!VB->ClipMask) { fprintf(stderr, "Cannot allocate clipmask! Exiting...\n"); exit(1); diff --git a/xc/lib/GL/mesa/src/drv/sis/Imakefile b/xc/lib/GL/mesa/src/drv/sis/Imakefile index cdcfcaf78..56f93a157 100644 --- a/xc/lib/GL/mesa/src/drv/sis/Imakefile +++ b/xc/lib/GL/mesa/src/drv/sis/Imakefile @@ -257,7 +257,7 @@ LinkSourceFile(xdriP.h, ../../X) MMX_OBJS = ../../X86/mmx_blend.o -#if MesaUse3DNow +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ diff --git a/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c b/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c index 935a220e6..e9ce26d30 100644 --- a/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c +++ b/xc/lib/GL/mesa/src/drv/sis/sis_alloc.c @@ -40,7 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # include "xf86fbman.h" #else # include "drm.h" -# include "sis_drm_public.h" +# include "sis_drm.h" # include <sys/ioctl.h> #endif diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile index 05ad70e5b..43d62f0c4 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile +++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile @@ -13,7 +13,7 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL #endif #if BuildXF86DRI - DRI_DEFINES = GlxDefines -DFX -DFX_GLIDE3 -DGLIDE3 -DDRIVERTS + DRI_DEFINES = GlxDefines -DFX_GLIDE3 -DDRIVERTS DRI_INCLUDES = -I../../../../dri -I../../../../glx \ -I../../../dri \ -I$(TOP)/include -I$(TOP)/include/GL \ @@ -25,32 +25,6 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL MESA_INCLUDES = -I. -I.. -I../../include \ -I../../../../dri/drm -LinkSourceFile(fxclip.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcliptmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcva.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcva.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxcvatmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxdd.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxddspan.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxddtex.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxdrv.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxfastpath.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxfasttmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxglidew.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxglidew.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxpipeline.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxrender.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxsanity.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxsdettmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxsetup.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxstripdet.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxtexman.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxtrifuncs.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxtritmp.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxvsetup.c, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxvsetup.h, $(MESASRCDIR)/src/FX) -LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) - DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) \ -I$(GLIDE3INCDIR) @@ -71,6 +45,14 @@ LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) ../../../../dri/drm/xf86drmRandom.o \ ../../../../dri/drm/xf86drmSL.o +#ifdef GlxSoProf + HIOBJS = ../../../../highpc.o + LOOBJS = ../../../../lowpc.o +#else + HIOBJS = + LOOBJS = +#endif + TDFXSRCS = tdfx_xmesa.c tdfx_init.c tdfx_inithw.c \ fxclip.c fxcva.c fxdd.c fxddspan.c fxddtex.c fxfastpath.c \ fxglidew.c fxpipeline.c fxrender.c fxsanity.c fxsetup.c \ @@ -246,7 +228,7 @@ LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) MMX_OBJS = ../../X86/mmx_blend.o -#if MesaUse3DNow +#ifdef MesaUse3DNow 3DNOW_SRCS = ../../X86/3dnow.c \ ../../X86/3dnow_norm_raw.S \ ../../X86/3dnow_xform_masked1.S \ @@ -272,15 +254,41 @@ LinkSourceFile(fxvs_tmp.h, $(MESASRCDIR)/src/FX) ../../X86/vertex_3dnow.o #endif +#ifdef MesaUseKatmai + KATMAI_SRCS = ../../X86/katmai.c \ + ../../X86/katmai_norm_raw.S \ + ../../X86/katmai_xform_masked1.S \ + ../../X86/katmai_xform_masked2.S \ + ../../X86/katmai_xform_masked3.S \ + ../../X86/katmai_xform_masked4.S \ + ../../X86/katmai_xform_raw1.S \ + ../../X86/katmai_xform_raw2.S \ + ../../X86/katmai_xform_raw3.S \ + ../../X86/katmai_xform_raw4.S \ + ../../X86/vertex_katmai.S + + KATMAI_OBJS = ../../X86/katmai.o \ + ../../X86/katmai_norm_raw.o \ + ../../X86/katmai_xform_masked1.o \ + ../../X86/katmai_xform_masked2.o \ + ../../X86/katmai_xform_masked3.o \ + ../../X86/katmai_xform_masked4.o \ + ../../X86/katmai_xform_raw1.o \ + ../../X86/katmai_xform_raw2.o \ + ../../X86/katmai_xform_raw3.o \ + ../../X86/katmai_xform_raw4.o \ + ../../X86/vertex_katmai.o #endif - ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) - ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) +#endif - SRCS = $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS) - OBJS = $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS) + ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) $(KATMAI_SRCS) + ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) $(KATMAI_OBJS) -REQUIREDLIBS = -l$(GLIDE3LIBNAME) MathLibrary + SRCS = $(LOSRCS) $(DRISRCS) $(DRMSRCS) $(TDFXSRCS) $(MESASRCS) $(ASMSRCS) $(HISRCS) + OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(TDFXOBJS) $(MESAOBJS) $(ASMOBJS) $(HIOBJS) + +REQUIREDLIBS = -lglide3x -lm #if !GlxBuiltInTdfx REQUIREDLIBS += -L../../../.. -lGL #endif @@ -306,6 +314,12 @@ ALL_OBJS = $(OBJS) ALL_DEPS = DONE SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri) + +#ifdef GlxSoProf +SOPROF_LIBNAME = _tdfx_dri_p +NormalDepLibraryTarget($(SOPROF_LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) +InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri) +#endif #endif DependTarget() |