g=(GLint)(ctx->Current.RasterColor[1]*255.0f);
b=(GLint)(ctx->Current.RasterColor[2]*255.0f);
a=(GLint)(ctx->Current.RasterColor[3]*255.0f);
- color=(FxU16)
- ( ((FxU16)0xf8 & b) <<(11-3)) |
- ( ((FxU16)0xfc & g) <<(5-3+1)) |
- ( ((FxU16)0xf8 & r) >> 3);
+ if (fxMesa->bgrOrder)
+ color=(FxU16)
+ ( ((FxU16)0xf8 & b) <<(11-3)) |
+ ( ((FxU16)0xfc & g) <<(5-3+1)) |
+ ( ((FxU16)0xf8 & r) >> 3);
+ else
+ color=(FxU16)
+ ( ((FxU16)0xf8 & r) <<(11-3)) |
+ ( ((FxU16)0xfc & g) <<(5-3+1)) |
+ ( ((FxU16)0xf8 & b) >> 3);
stride=info.strideInBytes>>1;
#if !defined(FXMESA_USE_ARGB)
+
+#if defined(FX_GLIDE3) && defined(XF86DRI)
+
+static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
+ FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
+ FxU32 src_width, FxU32 src_height, FxI32 src_stride,
+ void *src_data)
+{
+ int i, x, w, srcElt;
+ void *data;
+
+ if (src_width==1 && src_height==1) { /* Easy case writing a point */
+ for (i=0; i<fxMesa->numClipRects; i++) {
+ if ((dst_x>=fxMesa->pClipRects[i].x1) &&
+ (dst_x<fxMesa->pClipRects[i].x2) &&
+ (dst_y>=fxMesa->pClipRects[i].y1) &&
+ (dst_y<fxMesa->pClipRects[i].y2)) {
+ FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
+ 1, 1, src_stride, src_data);
+ return GL_TRUE;
+ }
+ }
+ } else if (src_height==1) { /* Writing a span */
+ if (src_format==GR_LFB_SRC_FMT_8888) srcElt=4;
+ else if (src_format==GR_LFB_SRC_FMT_ZA16) srcElt=2;
+ else {
+ fprintf(stderr, "Unknown src_format passed to writeRegionClipped\n");
+ return GL_FALSE;
+ }
+ for (i=0; i<fxMesa->numClipRects; i++) {
+ if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
+ if (dst_x<fxMesa->pClipRects[i].x1) {
+ x=fxMesa->pClipRects[i].x1;
+ data=((char*)src_data)+srcElt*(dst_x-x);
+ w=src_width-(x-dst_x);
+ } else {
+ x=dst_x;
+ data=src_data;
+ w=src_width;
+ }
+ if (x+w>fxMesa->pClipRects[i].x2) {
+ w=fxMesa->pClipRects[i].x2-x;
+ }
+ FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1,
+ src_stride, data);
+ }
+ }
+ } else { /* Punt on the case of arbitrary rectangles */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+}
+
+#else
+
+#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
+ FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
+
+#endif
+
+
/* KW: Rearranged the args in the call to grLfbWriteRegion().
*/
#define LFB_WRITE_SPAN_MESA(dst_buffer, \
src_data) \
-#else /* defined(FXMESA_USE_RGBA) */
+#else /* !defined(FXMESA_USE_RGBA) */
+
+#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
+ FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
+
#define MESACOLOR_TO_ARGB(c) ( \
( ((unsigned int)(c[ACOMP]))<<24 ) | \
( ((unsigned int)(c[GCOMP]))<<8 ) | \
( (unsigned int)(c[BCOMP])) )
-void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
+inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer,
FxU32 dst_x,
FxU32 dst_y,
FxU32 src_width,
{
argb[i] = MESACOLOR_TO_ARGB(rgba[i]);
}
- writeRegionClipped(fxMesa, dst_buffer,
+ writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer,
dst_x,
dst_y,
GR_LFB_SRC_FMT_8888,
src_stride,
(void*)argb);
}
+
+#endif /* !defined(FXMESA_USE_RGBA) */
-#endif
-
-#if defined(FX_GLIDE3) && defined(XF86DRI)
-
-FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer,
- FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format,
- FxU32 src_width, FxU32 src_height, FxI32 src_stride,
- void *src_data)
-{
- int i, x, w;
- void *data;
-
- if (src_width==1 && src_height==1) { /* Easy case writing a point */
- for (i=0; i<fxMesa->numClipRects; i++) {
- if ((dst_x>=fxMesa->pClipRects[i].x1) &&
- (dst_x<fxMesa->pClipRects[i].x2) &&
- (dst_y>=fxMesa->pClipRects[i].y1) &&
- (dst_y<fxMesa->pClipRects[i].y2)) {
- FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format,
- src_width, src_height, src_stride, src_data);
- return GL_TRUE;
- }
- }
- } else if (src_height==1) { /* Writing a span */
- for (i=0; i<fxMesa->numClipRects; i++) {
- if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) {
- if (dst_x<fxMesa->pClipRects[i].x1) {
- x=fxMesa->pClipRects[i].x1;
- data=((char*)src_data)+2*(dst_x-x);
- w=src_width-(x-dst_x);
- } else {
- x=dst_x;
- data=src_data;
- w=src_width;
- }
- if (x+w>fxMesa->pClipRects[i].x2) {
- w=fxMesa->pClipRects[i].x2-x;
- }
- FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, src_height,
- src_stride, data);
- }
- }
- } else { /* Punt on the case of arbitrary rectangles */
- return GL_FALSE;
- }
- return GL_TRUE;
-}
-
-#else
-
-#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
- FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data)
-
-#endif
/************************************************************************/
/***** Span functions *****/
*/
-/* fxddtex.c - 3Dfx VooDoo Texture mapping functions */
-
-
#ifdef HAVE_CONFIG_H
#include "conf.h"
#endif
ti->sClamp=GR_TEXTURECLAMP_WRAP;
ti->tClamp=GR_TEXTURECLAMP_WRAP;
- if(fxMesa->haveTwoTMUs) {
- ti->mmMode=GR_MIPMAP_NEAREST;
- ti->LODblend=FXTRUE;
- } else {
- ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
- ti->LODblend=FXFALSE;
- }
+ ti->mmMode=GR_MIPMAP_NEAREST;
+ ti->LODblend=FXFALSE;
for(i=0;i<MAX_TEXTURE_LEVELS;i++) {
ti->mipmapLevel[i].used=GL_FALSE;
#define FX_UM_E_IFMT 0x00fff000
-#define FX_UM_COLOR_ITERATED 0x00100000
-#define FX_UM_COLOR_CONSTANT 0x00200000
-#define FX_UM_ALPHA_ITERATED 0x00400000
-#define FX_UM_ALPHA_CONSTANT 0x00800000
+#define FX_UM_COLOR_ITERATED 0x01000000
+#define FX_UM_COLOR_CONSTANT 0x02000000
+#define FX_UM_ALPHA_ITERATED 0x04000000
+#define FX_UM_ALPHA_CONSTANT 0x08000000
typedef void (*tfxRenderVBFunc)(GLcontext *);
GLuint texBindNumber;
GLint tmuSrc;
GLuint lastUnitsMode;
- GLuint texStart[FX_NUM_TMU];
GLuint freeTexMem[FX_NUM_TMU];
MemRange *tmPool;
MemRange *tmFree[FX_NUM_TMU];
extern void fxTMClose(fxMesaContext ctx);
extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
+#define fxTMMoveOutTM_NoLock fxTMMoveOutTM
extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *, GLint);
extern void fxTMReloadSubMipMapLevel(fxMesaContext, struct gl_texture_object *,
extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
struct gl_texture_object *tObj,
GLint where);
-extern void fxSetupTexture_NoLock(GLcontext *ctx);
-extern void fxSetupTexture(GLcontext *ctx);
-
extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
#endif
typedef struct
{
- float x, y; /* X and Y in screen space */
- float ooz; /* 65535/Z (used for Z-buffering) */
- float oow; /* 1/W (used for W-buffering, texturing) */
- float r, g, b, a; /* R, G, B, A [0..255.0] */
- float z; /* Z is ignored */
+ float x, y, z; /* X, Y, and Z of scrn space -- Z is ignored */
+ float r, g, b; /* R, G, B, ([0..255.0]) */
+ float ooz; /* 65535/Z (used for Z-buffering) */
+ float a; /* Alpha [0..255.0] */
+ float oow; /* 1/W (used for W-buffering, texturing) */
GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
} GrVertex;
#define GR_VERTEX_X_OFFSET 0
#define GR_VERTEX_Y_OFFSET 1
-#define GR_VERTEX_OOZ_OFFSET 2
-#define GR_VERTEX_OOW_OFFSET 3
-#define GR_VERTEX_R_OFFSET 4
-#define GR_VERTEX_G_OFFSET 5
-#define GR_VERTEX_B_OFFSET 6
+#define GR_VERTEX_Z_OFFSET 2
+#define GR_VERTEX_R_OFFSET 3
+#define GR_VERTEX_G_OFFSET 4
+#define GR_VERTEX_B_OFFSET 5
+#define GR_VERTEX_OOZ_OFFSET 6
#define GR_VERTEX_A_OFFSET 7
-#define GR_VERTEX_Z_OFFSET 8
+#define GR_VERTEX_OOW_OFFSET 8
#define GR_VERTEX_SOW_TMU0_OFFSET 9
#define GR_VERTEX_TOW_TMU0_OFFSET 10
#define GR_VERTEX_OOW_TMU0_OFFSET 11
#else
#define FX_setupGrVertexLayout() do {} while (0)
#endif
-
/*
* grSstControl stuff
*/
struct gl_texture_object *tObj0,
struct gl_texture_object *tObj1);
static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset);
-static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset);
static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
struct gl_texture_object *tObj0,
struct gl_texture_object *tObj1);
+static void fxSetupTexture_NoLock(GLcontext *ctx);
+static void fxSetupTexture(GLcontext *ctx);
static void fxSetupBlend(GLcontext *ctx);
static void fxSetupDepthTest(GLcontext *ctx);
static void fxFogTableGenerate(GLcontext *ctx);
static void fxSetupScissor(GLcontext *ctx);
static void fxSetupCull(GLcontext *ctx);
static void gl_print_fx_state_flags( const char *msg, GLuint flags);
+static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);
static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint );
static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj)
case GL_REPEAT:
ti->sClamp=0;
break;
+ default:
+ ; /* silence compiler warning */
}
switch (tObj->WrapT) {
case GL_CLAMP_TO_EDGE:
case GL_REPEAT:
ti->tClamp=0;
break;
+ default:
+ ; /* silence compiler warning */
}
ti->validated=GL_TRUE;
else
unitsmode|=FX_UM_COLOR_CONSTANT;
+ /*
+ OpenGL Feeds Texture 0 into Texture 1
+ Glide Feeds Texture 1 into Texture 0
+ */
if(tObj0) {
tfxTexInfo *ti0=fxTMGetTexInfo(tObj0);
unitsmode|=(ifmt | envmode);
- if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
+ if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE))
fxPrintUnitsMode("unitsmode", unitsmode);
return unitsmode;
static void fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
{
tfxTexInfo *ti=fxTMGetTexInfo(tObj);
+ int tmu;
+
+ /* Make sure we're not loaded incorrectly */
+ if (ti->isInTM) {
+ if (ti->LODblend) {
+ if (ti->whichTMU!=FX_TMU_SPLIT)
+ fxTMMoveOutTM(fxMesa, tObj);
+ } else {
+ if (ti->whichTMU==FX_TMU_SPLIT)
+ fxTMMoveOutTM(fxMesa, tObj);
+ }
+ }
+ /* Make sure we're loaded correctly */
if (!ti->isInTM) {
if (ti->LODblend)
fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU_SPLIT);
if (fxMesa->haveTwoTMUs) {
if (fxMesa->freeTexMem[FX_TMU0] >
FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
- &(ti->info)))
- fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0);
- else
- fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU1);
+ &(ti->info))) {
+ fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU0);
+ } else {
+ fxTMMoveInTM_NoLock(fxMesa,tObj, FX_TMU1);
+ }
} else
fxTMMoveInTM_NoLock(fxMesa,tObj,FX_TMU0);
}
FX_grTexSource_NoLock(GR_TMU1,ti->tm[FX_TMU1]->startAddr,
GR_MIPMAPLEVELMASK_EVEN,&(ti->info));
} else {
+ if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0;
+ else tmu=ti->whichTMU;
+
if((ti->info.format==GR_TEXFMT_P_8) && (!fxMesa->haveGlobalPaletteTexture)) {
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: uploading texture palette\n");
}
- FX_grTexDownloadTable_NoLock(ti->whichTMU,GR_TEXTABLE_PALETTE,&(ti->palette));
+ FX_grTexDownloadTable_NoLock(tmu, GR_TEXTABLE_PALETTE, &(ti->palette));
}
/* KW: The alternative is to do the download to the other tmu. If
if (ti->LODblend && (MESA_VERBOSE&VERBOSE_DRIVER))
fprintf(stderr, "fxmesa: not blending texture - only on one tmu\n");
- FX_grTexClampMode_NoLock(ti->whichTMU,ti->sClamp,ti->tClamp);
- FX_grTexFilterMode_NoLock(ti->whichTMU,ti->minFilt,ti->maxFilt);
- FX_grTexMipMapMode_NoLock(ti->whichTMU,ti->mmMode,FXFALSE);
+ FX_grTexClampMode_NoLock(tmu, ti->sClamp, ti->tClamp);
+ FX_grTexFilterMode_NoLock(tmu, ti->minFilt, ti->maxFilt);
+ FX_grTexMipMapMode_NoLock(tmu, ti->mmMode, FXFALSE);
- FX_grTexSource_NoLock(ti->whichTMU,
- ti->tm[ti->whichTMU]->startAddr,
- GR_MIPMAPLEVELMASK_BOTH,&(ti->info));
+ FX_grTexSource_NoLock(tmu, ti->tm[tmu]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
}
}
-static void fxSetupSingleTMU(fxMesaContext fxMesa, struct gl_texture_object *tObj) {
- BEGIN_BOARD_LOCK();
- fxSetupSingleTMU_NoLock(fxMesa, tObj);
- END_BOARD_LOCK();
-}
-
-static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend)
+static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu,
+ FxBool LODblend)
{
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxSelectSingleTMUSrc(%d,%d)\n",tmu,LODblend);
GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
FXFALSE,FXFALSE);
-
fxMesa->tmuSrc=FX_TMU_SPLIT;
} else {
- if(tmu==FX_TMU0) {
+ if (tmu!=FX_TMU1) {
FX_grTexCombine_NoLock(GR_TMU0,
GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE,
FXFALSE,FXFALSE);
-
+ FX_grTexCombine_NoLock(GR_TMU1,
+ GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE,
+ GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE,
+ FXFALSE,FXFALSE);
fxMesa->tmuSrc=FX_TMU0;
} else {
FX_grTexCombine_NoLock(GR_TMU1,
/* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */
FX_grTexCombine_NoLock(GR_TMU0,
- GR_COMBINE_FUNCTION_BLEND,GR_COMBINE_FACTOR_ONE,
- GR_COMBINE_FUNCTION_BLEND,GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_ONE,
FXFALSE,FXFALSE);
fxMesa->tmuSrc=FX_TMU1;
GLint ifmt;
tfxTexInfo *ti;
struct gl_texture_object *tObj=ctx->Texture.Unit[textureset].CurrentD[2];
+ int tmu;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxSetupTextureSingleTMU(...) Start\n");
fxSetupSingleTMU_NoLock(fxMesa,tObj);
- if(fxMesa->tmuSrc!=ti->whichTMU)
- fxSelectSingleTMUSrc_NoLock(fxMesa,ti->whichTMU,ti->LODblend);
+ if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0;
+ else tmu=ti->whichTMU;
+ if (fxMesa->tmuSrc!=tmu)
+ fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend);
if(textureset==0 || !fxMesa->haveTwoTMUs)
unitsmode=fxGetTexSetConfiguration(ctx,tObj,NULL);
FXFALSE);
break;
case GL_BLEND:
+#if 0
+ FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
+ GR_COMBINE_FACTOR_LOCAL,
+ locala,
+ GR_COMBINE_OTHER_TEXTURE,
+ FXFALSE);
+ if (ifmt==GL_ALPHA)
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ localc,
+ GR_COMBINE_OTHER_NONE,
+ FXFALSE);
+ else
+ FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ GR_COMBINE_FACTOR_LOCAL,
+ localc,
+ GR_COMBINE_OTHER_TEXTURE,
+ FXTRUE);
+ ctx->Driver.MultipassFunc = fxMultipassBlend;
+#else
#ifndef FX_SILENT
fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n");
#endif
- /* TO DO (I think that the Voodoo Graphics isn't able to support GL_BLEND) */
+#endif
break;
case GL_REPLACE:
if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE))
tfxTexInfo *ti0=fxTMGetTexInfo(tObj0);
tfxTexInfo *ti1=fxTMGetTexInfo(tObj1);
GLuint tstate=0;
+ int tmu0=0, tmu1=1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxSetupDoubleTMU(...)\n");
}
- if(ti0->isInTM) {
- if(ti0->whichTMU==FX_TMU0)
+ /* We shouldn't need to do this. There is something wrong with
+ mutlitexturing when the TMUs are swapped. So, we're forcing
+ them to always be loaded correctly. !!! */
+ if (ti0->whichTMU==FX_TMU1)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj0);
+ if (ti1->whichTMU==FX_TMU0)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj1);
+
+ if (ti0->isInTM) {
+ switch (ti0->whichTMU) {
+ case FX_TMU0:
tstate|=T0_IN_TMU0;
- else if(ti0->whichTMU==FX_TMU1)
+ break;
+ case FX_TMU1:
tstate|=T0_IN_TMU1;
- else {
- fxTMMoveOutTM(fxMesa,tObj0);
+ break;
+ case FX_TMU_BOTH:
+ tstate|=T0_IN_TMU0|T0_IN_TMU1;
+ break;
+ case FX_TMU_SPLIT:
tstate|=T0_NOT_IN_TMU;
+ break;
}
- } else
- tstate|=T0_NOT_IN_TMU;
+ } else tstate|=T0_NOT_IN_TMU;
- if(ti1->isInTM) {
- if(ti1->whichTMU==FX_TMU0)
+ if (ti1->isInTM) {
+ switch (ti1->whichTMU) {
+ case FX_TMU0:
tstate|=T1_IN_TMU0;
- else if(ti1->whichTMU==FX_TMU1)
+ break;
+ case FX_TMU1:
tstate|=T1_IN_TMU1;
- else {
- fxTMMoveOutTM(fxMesa,tObj1);
+ break;
+ case FX_TMU_BOTH:
+ tstate|=T1_IN_TMU0|T1_IN_TMU1;
+ break;
+ case FX_TMU_SPLIT:
tstate|=T1_NOT_IN_TMU;
+ break;
}
- } else
- tstate|=T1_NOT_IN_TMU;
+ } else tstate|=T1_NOT_IN_TMU;
ti0->lastTimeUsed=fxMesa->texBindNumber;
ti1->lastTimeUsed=fxMesa->texBindNumber;
- /* Move texture maps in TMUs */
-
- switch(tstate) {
- case (T0_IN_TMU0 | T1_IN_TMU0):
- fxTMMoveOutTM(fxMesa,tObj1);
-
- fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1);
- break;
-
- case (T0_IN_TMU1 | T1_IN_TMU1):
- fxTMMoveOutTM(fxMesa,tObj0);
-
- fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0);
- break;
-
- case (T0_NOT_IN_TMU | T1_NOT_IN_TMU):
- fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0);
- fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1);
- break;
-
- /*** T0/T1 ***/
-
- case (T0_NOT_IN_TMU | T1_IN_TMU0):
- fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU1);
- break;
+ /* Move texture maps into TMUs */
- case (T0_NOT_IN_TMU | T1_IN_TMU1):
- fxTMMoveInTM_NoLock(fxMesa,tObj0,FX_TMU0);
- break;
-
- case (T0_IN_TMU0 | T1_NOT_IN_TMU):
- fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU1);
- break;
-
- case (T0_IN_TMU1 | T1_NOT_IN_TMU):
- fxTMMoveInTM_NoLock(fxMesa,tObj1,FX_TMU0);
- break;
-
- /*** Best Case ***/
-
- case (T0_IN_TMU1 | T1_IN_TMU0):
- case (T0_IN_TMU0 | T1_IN_TMU1):
- break;
-
- default:
- fprintf(stderr,"fx Driver: internal error in fxSetupDoubleTMU()\n");
- fxCloseHardware();
- exit(-1);
- break;
+ if (!(((tstate&T0_IN_TMU0) && (tstate&T1_IN_TMU1)) ||
+ ((tstate&T0_IN_TMU1) && (tstate&T1_IN_TMU0)))) {
+ if (tObj0==tObj1) fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH);
+ else {
+ /* Find the minimal way to correct the situation */
+ if ((tstate&T0_IN_TMU0) || (tstate&T1_IN_TMU1)) {
+ /* We have one in the standard order, setup the other */
+ if (tstate&T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+ } else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+ }
+ /* tmu0 and tmu1 are setup */
+ } else if ((tstate&T0_IN_TMU1) || (tstate&T1_IN_TMU0)) {
+ /* we have one in the reverse order, setup the other */
+ if (tstate&T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1);
+ } else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+ }
+ tmu0=1;
+ tmu1=0;
+ } else { /* Nothing is loaded */
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+ /* tmu0 and tmu1 are setup */
+ }
+ }
}
if (!fxMesa->haveGlobalPaletteTexture) {
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: uploading texture palette TMU0\n");
}
- FX_grTexDownloadTable_NoLock(ti0->whichTMU,GR_TEXTABLE_PALETTE,&(ti0->palette));
+ FX_grTexDownloadTable_NoLock(tmu0, GR_TEXTABLE_PALETTE, &(ti0->palette));
}
if (ti1->info.format==GR_TEXFMT_P_8) {
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: uploading texture palette TMU1\n");
}
- FX_grTexDownloadTable_NoLock(ti1->whichTMU, GR_TEXTABLE_PALETTE,&(ti1->palette));
+ FX_grTexDownloadTable_NoLock(tmu1, GR_TEXTABLE_PALETTE, &(ti1->palette));
}
}
- FX_grTexSource_NoLock(ti0->whichTMU,
- ti0->tm[ti0->whichTMU]->startAddr,
- GR_MIPMAPLEVELMASK_BOTH,&(ti0->info));
- FX_grTexClampMode_NoLock(ti0->whichTMU,ti0->sClamp,ti0->tClamp);
- FX_grTexFilterMode_NoLock(ti0->whichTMU,ti0->minFilt,ti0->maxFilt);
- FX_grTexMipMapMode_NoLock(ti0->whichTMU,ti0->mmMode,FXFALSE);
+ FX_grTexSource_NoLock(tmu0, ti0->tm[tmu0]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti0->info));
+ FX_grTexClampMode_NoLock(tmu0, ti0->sClamp, ti0->tClamp);
+ FX_grTexFilterMode_NoLock(tmu0, ti0->minFilt, ti0->maxFilt);
+ FX_grTexMipMapMode_NoLock(tmu0, ti0->mmMode, FXFALSE);
- FX_grTexSource_NoLock(ti1->whichTMU,
- ti1->tm[ti1->whichTMU]->startAddr,
- GR_MIPMAPLEVELMASK_BOTH,&(ti1->info));
- FX_grTexClampMode_NoLock(ti1->whichTMU,ti1->sClamp,ti1->tClamp);
- FX_grTexFilterMode_NoLock(ti1->whichTMU,ti1->minFilt,ti1->maxFilt);
- FX_grTexMipMapMode_NoLock(ti1->whichTMU,ti1->mmMode,FXFALSE);
+ FX_grTexSource_NoLock(tmu1, ti1->tm[tmu1]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));
+ FX_grTexClampMode_NoLock(tmu1, ti1->sClamp, ti1->tClamp);
+ FX_grTexFilterMode_NoLock(tmu1, ti1->minFilt, ti1->maxFilt);
+ FX_grTexMipMapMode_NoLock(tmu1, ti1->mmMode, FXFALSE);
#undef T0_NOT_IN_TMU
#undef T1_NOT_IN_TMU
struct gl_texture_object *tObj0=ctx->Texture.Unit[0].CurrentD[2];
struct gl_texture_object *tObj1=ctx->Texture.Unit[1].CurrentD[2];
GLuint envmode,ifmt,unitsmode;
+ int tmu0=0, tmu1=1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxSetupTextureDoubleTMU(...) Start\n");
gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+ if ((ti0->whichTMU==FX_TMU1) || (ti1->whichTMU==FX_TMU0)) {
+ tmu0=1;
+ tmu1=0;
+ }
fxMesa->tmuSrc=FX_TMU_BOTH;
switch(envmode) {
case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE):
GLboolean isalpha[FX_NUM_TMU];
if(ti0->baseLevelInternalFormat==GL_ALPHA)
- isalpha[ti0->whichTMU]=GL_TRUE;
+ isalpha[tmu0]=GL_TRUE;
else
- isalpha[ti0->whichTMU]=GL_FALSE;
+ isalpha[tmu0]=GL_FALSE;
if(ti1->baseLevelInternalFormat==GL_ALPHA)
- isalpha[ti1->whichTMU]=GL_TRUE;
+ isalpha[tmu1]=GL_TRUE;
else
- isalpha[ti1->whichTMU]=GL_FALSE;
+ isalpha[tmu1]=GL_FALSE;
if(isalpha[FX_TMU1])
FX_grTexCombine_NoLock(GR_TMU1,
break;
}
case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */
- if(ti1->whichTMU==FX_TMU1) {
+ if (tmu1==FX_TMU1) {
FX_grTexCombine_NoLock(GR_TMU1,
GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE,
FXFALSE);
break;
case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */
- if(ti1->whichTMU==FX_TMU1) {
+ if (tmu1==FX_TMU1) {
FX_grTexCombine_NoLock(GR_TMU1,
GR_COMBINE_FUNCTION_LOCAL,
GR_COMBINE_FACTOR_NONE,
GLboolean isalpha[FX_NUM_TMU];
if(ti0->baseLevelInternalFormat==GL_ALPHA)
- isalpha[ti0->whichTMU]=GL_TRUE;
+ isalpha[tmu0]=GL_TRUE;
else
- isalpha[ti0->whichTMU]=GL_FALSE;
+ isalpha[tmu0]=GL_FALSE;
if(ti1->baseLevelInternalFormat==GL_ALPHA)
- isalpha[ti1->whichTMU]=GL_TRUE;
+ isalpha[tmu1]=GL_TRUE;
else
- isalpha[ti1->whichTMU]=GL_FALSE;
+ isalpha[tmu1]=GL_FALSE;
if(isalpha[FX_TMU1])
FX_grTexCombine_NoLock(GR_TMU1,
FXFALSE);
break;
}
-
+ default:
+ fprintf(stderr, "Unexpected dual texture mode encountered\n");
+ break;
}
if (MESA_VERBOSE&VERBOSE_DRIVER) {
/************************** Texture Mode SetUp **************************/
/************************************************************************/
-void fxSetupTexture_NoLock(GLcontext *ctx)
+static void fxSetupTexture_NoLock(GLcontext *ctx)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint tex2Denabled;
}
}
-void fxSetupTexture(GLcontext *ctx) {
+static void fxSetupTexture(GLcontext *ctx) {
BEGIN_BOARD_LOCK();
fxSetupTexture_NoLock(ctx);
END_BOARD_LOCK();
adfact=GR_BLEND_ZERO;
break;
case GL_DST_ALPHA:
- dfact=GR_BLEND_DST_ALPHA;
+ /* dfact=GR_BLEND_DST_ALPHA; */
+ /* We can't do DST_ALPHA */
+ dfact=GR_BLEND_ONE;
adfact=GR_BLEND_ZERO;
break;
case GL_ONE_MINUS_DST_ALPHA:
- dfact=GR_BLEND_ONE_MINUS_DST_ALPHA;
+ /* dfact=GR_BLEND_ONE_MINUS_DST_ALPHA; */
+ /* We can't do DST_ALPHA */
+ dfact=GR_BLEND_ZERO;
adfact=GR_BLEND_ZERO;
break;
case GL_SRC_ALPHA_SATURATE:
}
}
+#if 0
+/*
+ Multipass to do GL_BLEND texture functions
+ Cf*(1-Ct) has already been written to the buffer during the first pass
+ Cc*Ct gets written during the second pass (in this function)
+ Everything gets reset in the third call (in this function)
+*/
+static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
+{
+ GLcontext *ctx = VB->ctx;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ switch (pass) {
+ case 1:
+ /* Add Cc*Ct */
+ fxMesa->restoreUnitsState=fxMesa->unitsState;
+ if (ctx->Depth.Mask) {
+ /* We don't want to check or change the depth buffers */
+ switch (ctx->Depth.Func) {
+ case GL_NEVER:
+ case GL_ALWAYS:
+ break;
+ default:
+ fxDDDepthFunc(ctx, GL_EQUAL);
+ break;
+ }
+ fxDDDepthMask(ctx, FALSE);
+ }
+ /* Enable Cc*Ct mode */
+ /* ??? Set the Constant Color ??? */
+ fxDDEnable(ctx, GL_BLEND, GL_TRUE);
+ fxDDBlendFunc(ctx, ???, ???);
+ fxSetupTextureSingleTMU(ctx, ???);
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
+ break;
+
+ case 2:
+ /* Reset everything back to normal */
+ fxMesa->unitsState = fxMesa->restoreUnitsState;
+ fxMesa->setupdone &= ???;
+ fxSetupTextureSingleTMU(ctx, ???);
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
+ break;
+ }
+
+ return pass==1;
+}
+#endif
+
/************************************************************************/
/******************** Fake Multitexture Support *************************/
/************************************************************************/
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint newstate = fxMesa->new_state;
- if (MESA_VERBOSE&VERBOSE_DRIVER)
+ if (MESA_VERBOSE&VERBOSE_DRIVER)
gl_print_fx_state_flags("fxmesa: fxSetupFXUnits", newstate);
if (newstate) {
#include "fxdrv.h"
+int texSwaps=0;
+
#define FX_2MB_SPLIT 0x200000
static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
int tmu);
-#if 0
+#ifdef TEXSANITY
static void fubar()
{
}
/* Sanity Check */
-static void sanity(fxMesaContext fxMesa, int tmu)
+static void sanity(fxMesaContext fxMesa)
{
- MemRange *tmp, *prev;
- int i;
+ MemRange *tmp, *prev, *pos;
prev=0;
- tmp = fxMesa->tmFree[tmu];
- i=0;
+ tmp = fxMesa->tmFree[0];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr>=tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr>=tmp->startAddr ||
+ prev->endAddr>tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev=tmp;
+ tmp=tmp->next;
+ }
+ prev=0;
+ tmp = fxMesa->tmFree[1];
while (tmp) {
- fprintf(stderr, "TMU %d Sanity %d %d-%d\n", tmu, i,
- tmp->startAddr, tmp->endAddr);
- i++;
if (!tmp->startAddr && !tmp->endAddr) {
fprintf(stderr, "Textures fubar\n");
fubar();
fubar();
}
if (prev && (prev->startAddr>=tmp->startAddr ||
- prev->endAddr>=tmp->startAddr)) {
+ prev->endAddr>tmp->startAddr)) {
fprintf(stderr, "Sorting fubar\n");
fubar();
}
start=FX_grTexMinAddress(tmu);
end=FX_grTexMaxAddress(tmu);
- fxMesa->texStart[tmu]=start;
if(fxMesa->verbose) {
fprintf(stderr,"%s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1");
fprintf(stderr," Lower texture memory address (%u)\n",(unsigned int)start);
fprintf(stderr," Higher texture memory address (%u)\n",(unsigned int)end);
- fprintf(stderr," Splitting Texture memory in 2Mb blocks:\n");
+ fprintf(stderr," Splitting Texture memory in 2b blocks:\n");
}
fxMesa->freeTexMem[tmu]=end-start;
}
fxTMDeleteRangeNode(fxMesa, tmp);
}
+ fxMesa->freeTexMem[tmu]-=size;
return result;
}
prev=tmp;
return -1;
}
fxTMMoveOutTM(fxMesa, obj);
+ texSwaps++;
}
}
static void fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange *range)
{
- MemRange *tmp, *prev, *next;
+ MemRange *tmp, *prev;
if (range->startAddr==range->endAddr) {
fxTMDeleteRangeNode(fxMesa, range);
return;
}
+ fxMesa->freeTexMem[tmu]+=range->endAddr-range->startAddr;
prev=0;
tmp=fxMesa->tmFree[tmu];
while (tmp) {
info=fxTMGetTexInfo(tmp);
if (info && info->isInTM &&
- (info->whichTMU==tmu || info->whichTMU==FX_TMU_BOTH ||
- info->whichTMU==FX_TMU_SPLIT)) {
+ ((info->whichTMU==tmu) || (info->whichTMU==FX_TMU_BOTH) ||
+ (info->whichTMU==FX_TMU_SPLIT))) {
lasttime=info->lastTimeUsed;
if (lasttime>bindnumber)
exit(-1);
}
- if (ti->isInTM) return;
+ if (ti->isInTM) {
+ if (ti->whichTMU==where) return;
+ if (where==FX_TMU_SPLIT || ti->whichTMU==FX_TMU_SPLIT)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj);
+ else {
+ if (ti->whichTMU==FX_TMU_BOTH) return;
+ where=FX_TMU_BOTH;
+ }
+ }
if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) {
fprintf(stderr,"fxmesa: downloading %x (%d) in texture memory in %d\n",(GLuint)tObj,tObj->Name,where);
GR_MIPMAPLEVELMASK_BOTH,
ti->mipmapLevel[l].data);
break;
- case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
+ case FX_TMU_SPLIT:
texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_ODD,
&(ti->info));
ti->tm[FX_TMU0]=fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
ti->mipmapLevel[l].data);
}
break;
+ case FX_TMU_BOTH:
+ texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[FX_TMU0]=fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
+ fxMesa->stats.memTexUpload+=texmemsize;
+
+ texmemsize=(int)FX_grTexTextureMemRequired_NoLock(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[FX_TMU1]=fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
+ fxMesa->stats.memTexUpload+=texmemsize;
+
+ for (i=FX_largeLodValue(ti->info),l=ti->minLevel;
+ i<=FX_smallLodValue(ti->info);
+ i++,l++) {
+ FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ ti->mipmapLevel[l].data);
+
+ FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ ti->mipmapLevel[l].data);
+ }
+ break;
default:
fprintf(stderr,"fx Driver: internal error in fxTMMoveInTM() -> wrong tmu (%d)\n",where);
fxCloseHardware();
fxTexGetInfo(ti->mipmapLevel[0].width,ti->mipmapLevel[0].height,
&lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+#ifdef FX_GLIDE3
+ lodlevel-=level;
+#else
+ lodlevel+=level;
+#endif
switch(tmu) {
case FX_TMU0:
case FX_TMU1:
FX_grTexDownloadMipMapLevel(tmu,
ti->tm[tmu]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
+ FX_valueToLod(FX_lodToValue(lodlevel)),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_BOTH,
ti->mipmapLevel[level].data);
break;
- case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
+ case FX_TMU_SPLIT:
FX_grTexDownloadMipMapLevel(GR_TMU0,
ti->tm[GR_TMU0]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
+ FX_valueToLod(FX_lodToValue(lodlevel)),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
FX_grTexDownloadMipMapLevel(GR_TMU1,
ti->tm[GR_TMU1]->startAddr,
- FX_valueToLod(FX_lodToValue(lodlevel)+level),
+ FX_valueToLod(FX_lodToValue(lodlevel)),
FX_largeLodLog2(ti->info),
FX_aspectRatioLog2(ti->info),
ti->info.format,
GR_MIPMAPLEVELMASK_EVEN,
ti->mipmapLevel[level].data);
break;
+ case FX_TMU_BOTH:
+ FX_grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ ti->mipmapLevel[level].data);
+
+ FX_grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ ti->mipmapLevel[level].data);
+ break;
+
default:
fprintf(stderr,"fx Driver: internal error in fxTMReloadMipMapLevel() -> wrong tmu (%d)\n",tmu);
fxCloseHardware();
data,
yoffset,yoffset+height-1);
break;
- case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
+ case FX_TMU_SPLIT:
FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
ti->tm[FX_TMU0]->startAddr,
FX_valueToLod(FX_lodToValue(lodlevel)+level),
data,
yoffset,yoffset+height-1);
break;
+ case FX_TMU_BOTH:
+ FX_grTexDownloadMipMapLevelPartial(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)+level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ data,
+ yoffset,yoffset+height-1);
+
+ FX_grTexDownloadMipMapLevelPartial(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)+level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ data,
+ yoffset,yoffset+height-1);
+ break;
default:
fprintf(stderr,"fx Driver: internal error in fxTMReloadSubMipMapLevel() -> wrong tmu (%d)\n",tmu);
fxCloseHardware();
fxTMRemoveRange(fxMesa, (int)ti->whichTMU, ti->tm[ti->whichTMU]);
break;
case FX_TMU_SPLIT:
+ case FX_TMU_BOTH:
fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
break;
}
switch (ti->whichTMU) {
case FX_TMU0:
+ case FX_TMU1:
fxTMDeleteRangeNode(fxMesa, ti->tm[ti->whichTMU]);
break;
case FX_TMU_SPLIT:
void fxTMInit(fxMesaContext fxMesa)
{
+ fxMesa->texBindNumber=0;
+ fxMesa->tmPool=0;
+
fxTMUInit(fxMesa,FX_TMU0);
if(fxMesa->haveTwoTMUs)
fxTMUInit(fxMesa,FX_TMU1);
-
- fxMesa->texBindNumber=0;
}
void fxTMClose(fxMesaContext fxMesa)
}
}
-void fxTMRestore_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
-{
- tfxTexInfo *ti=fxTMGetTexInfo(tObj);
- int i,l, where;
-
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxRestore(%d)\n",tObj->Name);
- }
-
- if (!ti->validated) {
- fprintf(stderr,"fxDriver: internal error in fxRestore -> not validated\n");
- fxCloseHardware();
- exit(-1);
- }
-
- where=ti->whichTMU;
- if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_TEXTURE)) {
- fprintf(stderr,"fxmesa: reloading %x (%d) in texture memory in %d\n",
- (GLuint)tObj, tObj->Name, where);
- }
-
- switch(where) {
- case FX_TMU0:
- case FX_TMU1:
- for (i=FX_largeLodValue_NoLock(ti->info), l=ti->minLevel;
- i<=FX_smallLodValue_NoLock(ti->info);
- i++,l++)
- if (ti->mipmapLevel[l].data)
- FX_grTexDownloadMipMapLevel_NoLock(where,
- ti->tm[where]->startAddr,
- FX_valueToLod(i),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- ti->mipmapLevel[l].data);
- break;
- case FX_TMU_SPLIT: /* TO DO: alternate even/odd TMU0/TMU1 */
- for (i=FX_largeLodValue_NoLock(ti->info),l=ti->minLevel;
- i<=FX_smallLodValue_NoLock(ti->info);
- i++,l++) {
- if (ti->mipmapLevel[l].data)
- FX_grTexDownloadMipMapLevel_NoLock(GR_TMU0,
- ti->tm[FX_TMU0]->startAddr,
- FX_valueToLod(i),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_ODD,
- ti->mipmapLevel[l].data);
- if (ti->mipmapLevel[l].data)
- FX_grTexDownloadMipMapLevel_NoLock(GR_TMU1,
- ti->tm[FX_TMU1]->startAddr,
- FX_valueToLod(i),
- FX_largeLodLog2(ti->info),
- FX_aspectRatioLog2(ti->info),
- ti->info.format,
- GR_MIPMAPLEVELMASK_EVEN,
- ti->mipmapLevel[l].data);
- }
- break;
- default:
- fprintf(stderr,"fxDriver: internal error in fxRestore -> bad tmu (%d)\n",
- where);
- fxCloseHardware();
- exit(-1);
- }
-}
-
void
-fxTMRestoreTextures(fxMesaContext ctx) {
+fxTMRestoreTextures_NoLock(fxMesaContext ctx) {
tfxTexInfo *ti;
struct gl_texture_object *tObj;
- int i;
+ int i, where;
tObj=ctx->glCtx->Shared->TexObjectList;
while (tObj) {
for (i=0; i<MAX_TEXTURE_UNITS; i++)
if (ctx->glCtx->Texture.Unit[i].Current==tObj) {
/* Force the texture onto the board, as it could be in use */
- fxTMRestore_NoLock(ctx, tObj);
+ where=ti->whichTMU;
+ ti->whichTMU=FX_TMU_NONE;
+ fxTMMoveInTM_NoLock(ctx, tObj, where);
break;
}
if (i==MAX_TEXTURE_UNITS) /* Mark the texture as off the board */
- fxTMMoveOutTM(ctx, tObj);
+ fxTMMoveOutTM_NoLock(ctx, tObj);
}
tObj=tObj->Next;
}