summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c')
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c423
1 files changed, 209 insertions, 214 deletions
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
index 5493eea8a..368f051a3 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
@@ -38,7 +38,6 @@
#include "tdfx_state.h"
#include "tdfx_tex.h"
#include "tdfx_texman.h"
-#include "tdfx_texstate.h"
/* =============================================================
@@ -1270,105 +1269,105 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
static void
setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
{
- struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
- tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
const GLcontext *ctx = fxMesa->glCtx;
+ tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ctx->Shared->DriverData;
+ tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
/* Make sure we're not loaded incorrectly */
- if (ti->isInTM && !shared->umaTexMemory) {
+ if (t->isInTM && !tss->umaTexMemory) {
/* if doing filtering between mipmap levels, alternate mipmap levels
* must be in alternate TMUs.
*/
- if (ti->LODblend) {
- if (ti->whichTMU != TDFX_TMU_SPLIT)
- tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
+ if (t->LODblend) {
+ if (t->whichTMU != TDFX_TMU_SPLIT)
+ tdfxTMMoveOutTMLocked(fxMesa, tObj);
}
else {
- if (ti->whichTMU == TDFX_TMU_SPLIT)
- tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
+ if (t->whichTMU == TDFX_TMU_SPLIT)
+ tdfxTMMoveOutTMLocked(fxMesa, tObj);
}
}
/* Make sure we're loaded correctly */
- if (!ti->isInTM) {
+ if (!t->isInTM) {
/* Have to download the texture */
- if (shared->umaTexMemory) {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
+ if (tss->umaTexMemory) {
+ tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU0);
}
else {
/* Voodoo3 (split texture memory) */
- if (ti->LODblend) {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU_SPLIT);
+ if (t->LODblend) {
+ tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU_SPLIT);
}
else {
#if 0
/* XXX putting textures into the second memory bank when the
* first bank is full is not working at this time.
*/
- if (fxMesa->haveTwoTMUs) {
- GLint memReq = FX_grTexTextureMemRequired_NoLock(
- GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
- if (shared->freeTexMem[TDFX_TMU0] > memReq) {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
+ if (fxMesa->numTMUs > 1) {
+ GLint memReq =
+ grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &t->info );
+ if (tss->freeTexMem[TDFX_TMU0] > memReq) {
+ tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU0);
}
else {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU1);
+ tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU1);
}
}
else
#endif
{
- tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
+ tdfxTMMoveInTMLocked( fxMesa, tObj, TDFX_TMU0 );
}
}
}
}
- if (ti->LODblend && ti->whichTMU == TDFX_TMU_SPLIT) {
+ if (t->LODblend && t->whichTMU == TDFX_TMU_SPLIT) {
/* mipmap levels split between texture banks */
GLint u;
- if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+ if (t->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(ti->palette);
+ fxMesa->TexPalette.Data = &(t->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
for (u = 0; u < 2; u++) {
- fxMesa->TexParams[u].sClamp = ti->sClamp;
- fxMesa->TexParams[u].tClamp = ti->tClamp;
- fxMesa->TexParams[u].minFilt = ti->minFilt;
- fxMesa->TexParams[u].magFilt = ti->magFilt;
- fxMesa->TexParams[u].mmMode = ti->mmMode;
- fxMesa->TexParams[u].LODblend = ti->LODblend;
+ fxMesa->TexParams[u].sClamp = t->sClamp;
+ fxMesa->TexParams[u].tClamp = t->tClamp;
+ fxMesa->TexParams[u].minFilt = t->minFilt;
+ fxMesa->TexParams[u].magFilt = t->magFilt;
+ fxMesa->TexParams[u].mmMode = t->mmMode;
+ fxMesa->TexParams[u].LODblend = t->LODblend;
fxMesa->TexParams[u].LodBias = ctx->Texture.Unit[u].LodBias;
}
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
- fxMesa->TexSource[0].StartAddress = ti->tm[TDFX_TMU0]->startAddr;
+ fxMesa->TexSource[0].StartAddress = t->range[TDFX_TMU0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD;
- fxMesa->TexSource[0].Info = &(ti->info);
- fxMesa->TexSource[1].StartAddress = ti->tm[TDFX_TMU1]->startAddr;
+ fxMesa->TexSource[0].Info = &(t->info);
+ fxMesa->TexSource[1].StartAddress = t->range[TDFX_TMU1]->startAddr;
fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
- fxMesa->TexSource[1].Info = &(ti->info);
+ fxMesa->TexSource[1].Info = &(t->info);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
}
else {
FxU32 tmu;
- if (ti->whichTMU == TDFX_TMU_BOTH)
+ if (t->whichTMU == TDFX_TMU_BOTH)
tmu = TDFX_TMU0;
else
- tmu = ti->whichTMU;
+ tmu = t->whichTMU;
- if (shared->umaTexMemory) {
- assert(ti->whichTMU == TDFX_TMU0);
+ if (tss->umaTexMemory) {
+ assert(t->whichTMU == TDFX_TMU0);
assert(tmu == TDFX_TMU0);
}
- if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+ if (t->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(ti->palette);
+ fxMesa->TexPalette.Data = &(t->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
@@ -1377,18 +1376,18 @@ setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
* texture memory, so perhaps it's not a good idea.
*/
- if (fxMesa->TexParams[tmu].sClamp != ti->sClamp ||
- fxMesa->TexParams[tmu].tClamp != ti->tClamp ||
- fxMesa->TexParams[tmu].minFilt != ti->minFilt ||
- fxMesa->TexParams[tmu].magFilt != ti->magFilt ||
- fxMesa->TexParams[tmu].mmMode != ti->mmMode ||
+ if (fxMesa->TexParams[tmu].sClamp != t->sClamp ||
+ fxMesa->TexParams[tmu].tClamp != t->tClamp ||
+ fxMesa->TexParams[tmu].minFilt != t->minFilt ||
+ fxMesa->TexParams[tmu].magFilt != t->magFilt ||
+ fxMesa->TexParams[tmu].mmMode != t->mmMode ||
fxMesa->TexParams[tmu].LODblend != FXFALSE ||
fxMesa->TexParams[tmu].LodBias != ctx->Texture.Unit[tmu].LodBias) {
- fxMesa->TexParams[tmu].sClamp = ti->sClamp;
- fxMesa->TexParams[tmu].tClamp = ti->tClamp;
- fxMesa->TexParams[tmu].minFilt = ti->minFilt;
- fxMesa->TexParams[tmu].magFilt = ti->magFilt;
- fxMesa->TexParams[tmu].mmMode = ti->mmMode;
+ fxMesa->TexParams[tmu].sClamp = t->sClamp;
+ fxMesa->TexParams[tmu].tClamp = t->tClamp;
+ fxMesa->TexParams[tmu].minFilt = t->minFilt;
+ fxMesa->TexParams[tmu].magFilt = t->magFilt;
+ fxMesa->TexParams[tmu].mmMode = t->mmMode;
fxMesa->TexParams[tmu].LODblend = FXFALSE;
fxMesa->TexParams[tmu].LodBias = ctx->Texture.Unit[tmu].LodBias;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
@@ -1397,16 +1396,16 @@ setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
/* Glide texture source info */
fxMesa->TexSource[0].Info = NULL;
fxMesa->TexSource[1].Info = NULL;
- if (ti->tm[tmu]) {
- fxMesa->TexSource[tmu].StartAddress = ti->tm[tmu]->startAddr;
+ if (t->range[tmu]) {
+ fxMesa->TexSource[tmu].StartAddress = t->range[tmu]->startAddr;
fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu].Info = &(ti->info);
+ fxMesa->TexSource[tmu].Info = &(t->info);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
}
}
- fxMesa->sScale0 = ti->sScale;
- fxMesa->tScale0 = ti->tScale;
+ fxMesa->sScale0 = t->sScale;
+ fxMesa->tScale0 = t->tScale;
}
static void
@@ -1420,12 +1419,12 @@ selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
- if (fxMesa->haveTwoTMUs) {
- const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
- const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ if ( fxMesa->numTMUs > 1 ) {
+ const struct gl_shared_state *ss = fxMesa->glCtx->Shared;
+ const tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
int tmu;
- if (shared->umaTexMemory)
+ if (tss->umaTexMemory)
tmu = GR_TMU0;
else
tmu = GR_TMU1;
@@ -1447,7 +1446,7 @@ selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE;
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
- if (fxMesa->haveTwoTMUs) {
+ if ( fxMesa->numTMUs > 1 ) {
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
@@ -1511,7 +1510,7 @@ static void print_state(tdfxContextPtr fxMesa)
static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxTexInfo *ti;
+ tdfxTexObjPtr t;
struct gl_texture_object *tObj;
int tmu;
GLenum envMode, baseFormat;
@@ -1530,17 +1529,17 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
setupSingleTMU(fxMesa, tObj);
- ti = TDFX_TEXTURE_DATA(tObj);
- if (ti->whichTMU == TDFX_TMU_BOTH)
+ t = TDFX_TEXTURE_DATA(tObj);
+ if (t->whichTMU == TDFX_TMU_BOTH)
tmu = TDFX_TMU0;
else
- tmu = ti->whichTMU;
+ tmu = t->whichTMU;
if (fxMesa->tmuSrc != tmu) {
- selectSingleTMUSrc(fxMesa, tmu, ti->LODblend);
+ selectSingleTMUSrc(fxMesa, tmu, t->LODblend);
}
- if (ti->reloadImages)
+ if (t->reloadImages)
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES;
/* Some texture environments not supported */
@@ -1627,35 +1626,35 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
#define T0_IN_TMU1 0x10
#define T1_IN_TMU1 0x20
- const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
- const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ const struct gl_shared_state *ss = fxMesa->glCtx->Shared;
+ const tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
const GLcontext *ctx = fxMesa->glCtx;
- tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
- tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
+ tdfxTexObjPtr t0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexObjPtr t1 = TDFX_TEXTURE_DATA(tObj1);
GLuint tstate = 0;
int tmu0 = 0, tmu1 = 1;
- if (shared->umaTexMemory) {
- if (!ti0->isInTM) {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
- assert(ti0->isInTM);
+ if (tss->umaTexMemory) {
+ if (!t0->isInTM) {
+ tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU0);
+ assert(t0->isInTM);
}
- if (!ti1->isInTM) {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0);
- assert(ti1->isInTM);
+ if (!t1->isInTM) {
+ tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU0);
+ assert(t1->isInTM);
}
}
else {
/* We shouldn't need to do this. There is something wrong with
multitexturing when the TMUs are swapped. So, we're forcing
them to always be loaded correctly. !!! */
- if (ti0->whichTMU == TDFX_TMU1)
- tdfxTMMoveOutTM_NoLock(fxMesa, tObj0);
- if (ti1->whichTMU == TDFX_TMU0)
- tdfxTMMoveOutTM_NoLock(fxMesa, tObj1);
+ if (t0->whichTMU == TDFX_TMU1)
+ tdfxTMMoveOutTMLocked(fxMesa, tObj0);
+ if (t1->whichTMU == TDFX_TMU0)
+ tdfxTMMoveOutTMLocked(fxMesa, tObj1);
- if (ti0->isInTM) {
- switch (ti0->whichTMU) {
+ if (t0->isInTM) {
+ switch (t0->whichTMU) {
case TDFX_TMU0:
tstate |= T0_IN_TMU0;
break;
@@ -1673,8 +1672,8 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
else
tstate |= T0_NOT_IN_TMU;
- if (ti1->isInTM) {
- switch (ti1->whichTMU) {
+ if (t1->isInTM) {
+ switch (t1->whichTMU) {
case TDFX_TMU0:
tstate |= T1_IN_TMU0;
break;
@@ -1697,7 +1696,7 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) ||
((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) {
if (tObj0 == tObj1) {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU_BOTH);
+ tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU_BOTH);
}
else {
/* Find the minimal way to correct the situation */
@@ -1705,10 +1704,10 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/* We have one in the standard order, setup the other */
if (tstate & T0_IN_TMU0) {
/* T0 is in TMU0, put T1 in TMU1 */
- tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1);
+ tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU1);
}
else {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
+ tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU0);
}
/* tmu0 and tmu1 are setup */
}
@@ -1716,36 +1715,36 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/* we have one in the reverse order, setup the other */
if (tstate & T1_IN_TMU0) {
/* T1 is in TMU0, put T0 in TMU1 */
- tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU1);
+ tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU1);
}
else {
- tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0);
+ tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU0);
}
tmu0 = 1;
tmu1 = 0;
}
else { /* Nothing is loaded */
- tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
- tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1);
+ tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU0);
+ tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU1);
/* tmu0 and tmu1 are setup */
}
}
}
}
- ti0->lastTimeUsed = fxMesa->texBindNumber;
- ti1->lastTimeUsed = fxMesa->texBindNumber;
+ t0->lastTimeUsed = fxMesa->texBindNumber;
+ t1->lastTimeUsed = fxMesa->texBindNumber;
if (!ctx->Texture.SharedPalette) {
- if (ti0->info.format == GR_TEXFMT_P_8) {
+ if (t0->info.format == GR_TEXFMT_P_8) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(ti0->palette);
+ fxMesa->TexPalette.Data = &(t0->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
- else if (ti1->info.format == GR_TEXFMT_P_8) {
+ else if (t1->info.format == GR_TEXFMT_P_8) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(ti1->palette);
+ fxMesa->TexPalette.Data = &(t1->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
else {
@@ -1756,25 +1755,25 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/*
* Setup Unit 0
*/
- assert(ti0->isInTM);
- assert(ti0->tm[tmu0]);
- fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr;
+ assert(t0->isInTM);
+ assert(t0->range[tmu0]);
+ fxMesa->TexSource[tmu0].StartAddress = t0->range[tmu0]->startAddr;
fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu0].Info = &(ti0->info);
+ fxMesa->TexSource[tmu0].Info = &(t0->info);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
- if (fxMesa->TexParams[tmu0].sClamp != ti0->sClamp ||
- fxMesa->TexParams[tmu0].tClamp != ti0->tClamp ||
- fxMesa->TexParams[tmu0].minFilt != ti0->minFilt ||
- fxMesa->TexParams[tmu0].magFilt != ti0->magFilt ||
- fxMesa->TexParams[tmu0].mmMode != ti0->mmMode ||
+ if (fxMesa->TexParams[tmu0].sClamp != t0->sClamp ||
+ fxMesa->TexParams[tmu0].tClamp != t0->tClamp ||
+ fxMesa->TexParams[tmu0].minFilt != t0->minFilt ||
+ fxMesa->TexParams[tmu0].magFilt != t0->magFilt ||
+ fxMesa->TexParams[tmu0].mmMode != t0->mmMode ||
fxMesa->TexParams[tmu0].LODblend != FXFALSE ||
fxMesa->TexParams[tmu0].LodBias != ctx->Texture.Unit[tmu0].LodBias) {
- fxMesa->TexParams[tmu0].sClamp = ti0->sClamp;
- fxMesa->TexParams[tmu0].tClamp = ti0->tClamp;
- fxMesa->TexParams[tmu0].minFilt = ti0->minFilt;
- fxMesa->TexParams[tmu0].magFilt = ti0->magFilt;
- fxMesa->TexParams[tmu0].mmMode = ti0->mmMode;
+ fxMesa->TexParams[tmu0].sClamp = t0->sClamp;
+ fxMesa->TexParams[tmu0].tClamp = t0->tClamp;
+ fxMesa->TexParams[tmu0].minFilt = t0->minFilt;
+ fxMesa->TexParams[tmu0].magFilt = t0->magFilt;
+ fxMesa->TexParams[tmu0].mmMode = t0->mmMode;
fxMesa->TexParams[tmu0].LODblend = FXFALSE;
fxMesa->TexParams[tmu0].LodBias = ctx->Texture.Unit[tmu0].LodBias;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
@@ -1783,42 +1782,42 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/*
* Setup Unit 1
*/
- if (shared->umaTexMemory) {
- ASSERT(ti1->isInTM);
- ASSERT(ti1->tm[0]);
- fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr;
+ if (tss->umaTexMemory) {
+ ASSERT(t1->isInTM);
+ ASSERT(t1->range[0]);
+ fxMesa->TexSource[tmu1].StartAddress = t1->range[0]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ fxMesa->TexSource[tmu1].Info = &(t1->info);
}
else {
- ASSERT(ti1->isInTM);
- ASSERT(ti1->tm[tmu1]);
- fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr;
+ ASSERT(t1->isInTM);
+ ASSERT(t1->range[tmu1]);
+ fxMesa->TexSource[tmu1].StartAddress = t1->range[tmu1]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ fxMesa->TexSource[tmu1].Info = &(t1->info);
}
- if (fxMesa->TexParams[tmu1].sClamp != ti1->sClamp ||
- fxMesa->TexParams[tmu1].tClamp != ti1->tClamp ||
- fxMesa->TexParams[tmu1].minFilt != ti1->minFilt ||
- fxMesa->TexParams[tmu1].magFilt != ti1->magFilt ||
- fxMesa->TexParams[tmu1].mmMode != ti1->mmMode ||
+ if (fxMesa->TexParams[tmu1].sClamp != t1->sClamp ||
+ fxMesa->TexParams[tmu1].tClamp != t1->tClamp ||
+ fxMesa->TexParams[tmu1].minFilt != t1->minFilt ||
+ fxMesa->TexParams[tmu1].magFilt != t1->magFilt ||
+ fxMesa->TexParams[tmu1].mmMode != t1->mmMode ||
fxMesa->TexParams[tmu1].LODblend != FXFALSE ||
fxMesa->TexParams[tmu1].LodBias != ctx->Texture.Unit[tmu1].LodBias) {
- fxMesa->TexParams[tmu1].sClamp = ti1->sClamp;
- fxMesa->TexParams[tmu1].tClamp = ti1->tClamp;
- fxMesa->TexParams[tmu1].minFilt = ti1->minFilt;
- fxMesa->TexParams[tmu1].magFilt = ti1->magFilt;
- fxMesa->TexParams[tmu1].mmMode = ti1->mmMode;
+ fxMesa->TexParams[tmu1].sClamp = t1->sClamp;
+ fxMesa->TexParams[tmu1].tClamp = t1->tClamp;
+ fxMesa->TexParams[tmu1].minFilt = t1->minFilt;
+ fxMesa->TexParams[tmu1].magFilt = t1->magFilt;
+ fxMesa->TexParams[tmu1].mmMode = t1->mmMode;
fxMesa->TexParams[tmu1].LODblend = FXFALSE;
fxMesa->TexParams[tmu1].LodBias = ctx->Texture.Unit[tmu1].LodBias;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
}
- fxMesa->sScale0 = ti0->sScale;
- fxMesa->tScale0 = ti0->tScale;
- fxMesa->sScale1 = ti1->sScale;
- fxMesa->tScale1 = ti1->tScale;
+ fxMesa->sScale0 = t0->sScale;
+ fxMesa->tScale0 = t0->tScale;
+ fxMesa->sScale1 = t1->sScale;
+ fxMesa->tScale1 = t1->tScale;
#undef T0_NOT_IN_TMU
#undef T1_NOT_IN_TMU
@@ -1833,8 +1832,8 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].CurrentD[2];
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].CurrentD[2];
- tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
- tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
+ tdfxTexObjPtr t0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexObjPtr t1 = TDFX_TEXTURE_DATA(tObj1);
struct gl_texture_image *baseImage0 = tObj0->Image[tObj0->BaseLevel];
struct gl_texture_image *baseImage1 = tObj1->Image[tObj1->BaseLevel];
const GLenum envMode0 = ctx->Texture.Unit[0].EnvMode;
@@ -1847,7 +1846,7 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
setupDoubleTMU(fxMesa, tObj0, tObj1);
- if (ti0->reloadImages || ti1->reloadImages)
+ if (t0->reloadImages || t1->reloadImages)
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES;
fxMesa->tmuSrc = TDFX_TMU_BOTH;
@@ -1893,7 +1892,7 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
}
else {
int unit0, unit1;
- if ((ti0->whichTMU == TDFX_TMU1) || (ti1->whichTMU == TDFX_TMU0))
+ if ((t0->whichTMU == TDFX_TMU1) || (t1->whichTMU == TDFX_TMU0))
unit0 = 1;
else
unit0 = 0;
@@ -1924,34 +1923,34 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
}
-void
-tdfxUpdateTextureState( GLcontext *ctx )
+void tdfxUpdateTextureState( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- GLuint tex2Denabled = ctx->Texture.ReallyEnabled;
+ GLuint enabled = ctx->Texture.ReallyEnabled;
- if (!fxMesa->haveTwoTMUs)
- tex2Denabled &= TEXTURE0_2D;
+ if ( fxMesa->numTMUs == 1 )
+ enabled &= TEXTURE0_2D;
- switch (tex2Denabled) {
+ switch ( enabled ) {
case TEXTURE0_2D:
LOCK_HARDWARE( fxMesa ); /* XXX remove locking eventually */
- setupTextureSingleTMU(ctx, 0);
+ setupTextureSingleTMU( ctx, 0 );
UNLOCK_HARDWARE( fxMesa );
break;
case TEXTURE1_2D:
LOCK_HARDWARE( fxMesa );
- setupTextureSingleTMU(ctx, 1);
+ setupTextureSingleTMU( ctx, 1 );
UNLOCK_HARDWARE( fxMesa );
break;
- case (TEXTURE0_2D | TEXTURE1_2D):
+ case TEXTURE0_2D | TEXTURE1_2D:
LOCK_HARDWARE( fxMesa );
- setupTextureDoubleTMU(ctx);
+ setupTextureDoubleTMU( ctx );
UNLOCK_HARDWARE( fxMesa );
break;
+
default:
- /* disable hardware texturing */
- if (TDFX_IS_NAPALM(fxMesa)) {
+ /* Disable hardware texturing */
+ if ( TDFX_IS_NAPALM( fxMesa ) ) {
fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB;
fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X;
fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO;
@@ -1972,9 +1971,8 @@ tdfxUpdateTextureState( GLcontext *ctx )
fxMesa->AlphaCombineExt.InvertD = FXFALSE;
fxMesa->AlphaCombineExt.Shift = 0;
fxMesa->AlphaCombineExt.Invert = FXFALSE;
- }
- else {
- /* Voodoo 3*/
+ } else {
+ /* Voodoo 3 */
fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE;
fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED;
@@ -1997,106 +1995,103 @@ tdfxUpdateTextureState( GLcontext *ctx )
}
-
-/*
- * This is a special case of texture state update.
+/* This is a special case of texture state update.
* It's used when we've simply bound a new texture to a texture
* unit and the new texture has the exact same attributes as the
* previously bound texture.
* This is very common in Quake3.
*/
-void
-tdfxUpdateTextureBinding( GLcontext *ctx )
+void tdfxUpdateTextureBinding( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const struct gl_shared_state *ss = fxMesa->glCtx->Shared;
+ const tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].CurrentD[2];
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].CurrentD[2];
- tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
- tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
-
- const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
- const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxTexObjPtr t0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexObjPtr t1 = TDFX_TEXTURE_DATA(tObj1);
- if (ti0) {
- fxMesa->sScale0 = ti0->sScale;
- fxMesa->tScale0 = ti0->tScale;
- if (ti0->info.format == GR_TEXFMT_P_8) {
+ if ( t0 ) {
+ fxMesa->sScale0 = t0->sScale;
+ fxMesa->tScale0 = t0->tScale;
+ if ( t0->info.format == GR_TEXFMT_P_8 ) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(ti0->palette);
+ fxMesa->TexPalette.Data = &t0->palette;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
- }
- else if (ti1 && ti1->info.format == GR_TEXFMT_P_8) {
+ } else if ( t1 && t1->info.format == GR_TEXFMT_P_8 ) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(ti1->palette);
+ fxMesa->TexPalette.Data = &t1->palette;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
}
- if (ti1) {
- fxMesa->sScale1 = ti1->sScale;
- fxMesa->tScale1 = ti1->tScale;
+ if ( t1 ) {
+ fxMesa->sScale1 = t1->sScale;
+ fxMesa->tScale1 = t1->tScale;
}
- if (ctx->Texture.ReallyEnabled == TEXTURE0_2D) {
- if (shared->umaTexMemory) {
- fxMesa->TexSource[0].StartAddress = ti0->tm[0]->startAddr;
+ switch ( ctx->Texture.ReallyEnabled ) {
+ case TEXTURE0_2D:
+ if ( tss->umaTexMemory ) {
+ fxMesa->TexSource[0].StartAddress = t0->range[0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[0].Info = &(ti0->info);
- }
- else {
- if (ti0->LODblend && ti0->whichTMU == TDFX_TMU_SPLIT) {
- fxMesa->TexSource[0].StartAddress = ti0->tm[TDFX_TMU0]->startAddr;
+ fxMesa->TexSource[0].Info = &(t0->info);
+ } else {
+ if ( t0->LODblend && t0->whichTMU == TDFX_TMU_SPLIT ) {
+ fxMesa->TexSource[0].StartAddress = t0->range[TDFX_TMU0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD;
- fxMesa->TexSource[0].Info = &(ti0->info);
- fxMesa->TexSource[1].StartAddress = ti0->tm[TDFX_TMU1]->startAddr;
+ fxMesa->TexSource[0].Info = &t0->info;
+ fxMesa->TexSource[1].StartAddress = t0->range[TDFX_TMU1]->startAddr;
fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
- fxMesa->TexSource[1].Info = &(ti0->info);
- }
- else {
- FxU32 tmu;
- if (ti0->whichTMU == TDFX_TMU_BOTH)
- tmu = TDFX_TMU0;
- else
- tmu = ti0->whichTMU;
+ fxMesa->TexSource[1].Info = &t0->info;
+ } else {
+ FxU32 unit;
+ if ( t0->whichTMU == TDFX_TMU_BOTH ) {
+ unit = TDFX_TMU0;
+ } else {
+ unit = t0->whichTMU;
+ }
fxMesa->TexSource[0].Info = NULL;
fxMesa->TexSource[1].Info = NULL;
- if (ti0->tm[tmu]) {
- fxMesa->TexSource[tmu].StartAddress = ti0->tm[tmu]->startAddr;
- fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu].Info = &(ti0->info);
+ if ( t0->range[unit] ) {
+ fxMesa->TexSource[unit].StartAddress = t0->range[unit]->startAddr;
+ fxMesa->TexSource[unit].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[unit].Info = &t0->info;
}
}
}
- }
- else if (ctx->Texture.ReallyEnabled == TEXTURE1_2D) {
- if (shared->umaTexMemory) {
- fxMesa->TexSource[0].StartAddress = ti1->tm[0]->startAddr;
+ break;
+
+ case TEXTURE1_2D:
+ if ( tss->umaTexMemory ) {
+ fxMesa->TexSource[0].StartAddress = t1->range[0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[0].Info = &(ti1->info);
+ fxMesa->TexSource[0].Info = &t1->info;
}
- }
- else if (ctx->Texture.ReallyEnabled == (TEXTURE0_2D | TEXTURE1_2D)) {
- if (shared->umaTexMemory) {
+ break;
+
+ case TEXTURE0_2D | TEXTURE1_2D:
+ if ( tss->umaTexMemory ) {
const FxU32 tmu0 = 0, tmu1 = 1;
- fxMesa->TexSource[tmu0].StartAddress = ti0->tm[0]->startAddr;
+ fxMesa->TexSource[tmu0].StartAddress = t0->range[0]->startAddr;
fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu0].Info = &(ti0->info);
+ fxMesa->TexSource[tmu0].Info = &t0->info;
- fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr;
+ fxMesa->TexSource[tmu1].StartAddress = t1->range[0]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ fxMesa->TexSource[tmu1].Info = &t1->info;
}
else {
const FxU32 tmu0 = 0, tmu1 = 1;
- fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr;
+ fxMesa->TexSource[tmu0].StartAddress = t0->range[tmu0]->startAddr;
fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu0].Info = &(ti0->info);
+ fxMesa->TexSource[tmu0].Info = &t0->info;
- fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr;
+ fxMesa->TexSource[tmu1].StartAddress = t1->range[tmu1]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ fxMesa->TexSource[tmu1].Info = &t1->info;
}
+ break;
}
-
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
}