From 09fae37520e1410466a5df80158483265d00552f Mon Sep 17 00:00:00 2001 From: koolsmoky <> Date: Sat, 29 Sep 2007 14:19:23 +0000 Subject: [PATCH] fixed problem with performance trilinear and lodbias sign --- glide3x/h5/glide3/src/gtex.c | 110 ++++++++++++++++------------------- 1 file changed, 51 insertions(+), 59 deletions(-) diff --git a/glide3x/h5/glide3/src/gtex.c b/glide3x/h5/glide3/src/gtex.c index 5594813..1d00583 100644 --- a/glide3x/h5/glide3/src/gtex.c +++ b/glide3x/h5/glide3/src/gtex.c @@ -2458,7 +2458,7 @@ GR_ENTRY(grTexLodBiasValue, void, else if(lodBias < -0x20) lodBias = -0x20; /* Mask it back off. */ lodBias &= 0x3f; - tLod |= lodBias << SST_LODBIAS_SHIFT; + tLod |= (lodBias << SST_LODBIAS_SHIFT); gc->state.tmuShadow[tmu].tLOD = tLod; @@ -2541,7 +2541,14 @@ GR_ENTRY(grTexMipMapMode, void, tLod &= ~(SST_LODMIN | SST_LODMAX | SST_LOD_ODD); texMode &= ~(SST_TLODDITHER | SST_TRILINEAR); gc->state.per_tmu[tmu].texSubLodDither = FXFALSE; - + + /* Force LOD dithering if the user asked for it. + * + * NB: There is a performance hit for this, but it does + * look better. + */ + texMode |= _GlideRoot.environment.texLodDither; + /*-------------------------------------------------------------- Encode Mipmap Mode Bits --------------------------------------------------------------*/ @@ -2583,13 +2590,6 @@ GR_ENTRY(grTexMipMapMode, void, } gc->state.per_tmu[tmu].mmMode = mmMode; - /* Force LOD dithering if the user asked for it. - * - * NB: There is a performance hit for this, but it does - * look better. - */ - texMode |= _GlideRoot.environment.texLodDither; - /*-------------------------------------------------------------- Fix trilinear and evenOdd bits - @@ -3786,12 +3786,22 @@ _g3LodXlat(const GrLOD_t someLOD, const FxBool tBig) void g3LodBiasPerChip(GrChipID_t tmu, FxU32 tLod) { #define FN_NAME "g3LodBiasPerChip" - FxU32 newtLod ; - FxI32 oldLodBias, newLodBias; - unsigned int i; - unsigned int idx, iTexLodDither; + GR_BEGIN_NOFIFOCHECK("g3LodBiasPerChip", 88); - static FxI32 chipLodBias[2][2][4] = + if( /*(_GlideRoot.environment.texSubLodDither != 1) ||*//* we won't get here if 0 */ + /*((gc->sliCount == gc->chipCount) && (gc->grSamplesPerChip == 1)) ||*//* check done in grTexMipMapMode */ + /*(gc->windowed) ||*/ + (gc->state.per_tmu[tmu].evenOdd != 3) || + (gc->state.tmuShadow[tmu].textureMode & SST_TRILINEAR) ) + goto FORGET_IT; + + { + unsigned int i; + FxU32 newtLod; + FxI32 newLodBias; + /* sign extend it. do not remove the FxI32 cast. */ + const FxI32 oldLodBias = ((((FxI32)tLod & SST_LODBIAS) << (32-6-SST_LODBIAS_SHIFT)) >> (32-6-SST_LODBIAS_SHIFT)); + const unsigned int idx = ((gc->chipCount - gc->sliCount) > 2); /* 4.2 format for tLod register * 1chip x2fsaa - no sli, 2 samples per chip * 2chip x2fsaa - no sli, 1 sample per chip @@ -3803,64 +3813,46 @@ void g3LodBiasPerChip(GrChipID_t tmu, FxU32 tLod) * 4chip x8fsaa - no sli, 2 samples per chip * 0.00, 0.25, 0.50, 0.75 - 4 chip * {0x00, 0x01, 0x02, 0x03} - * if mipmap dithering is enabled - * we will use different tLod registers. */ - { + static const FxI32 chipLodBias[2][4] = { {0x00<chipCount; i++) { - {-0x01<sliCount == gc->chipCount) && (gc->grSamplesPerChip == 1)) ||*//* check done in grTexMipMapMode */ - /*(gc->windowed) ||*/ - (gc->state.per_tmu[tmu].evenOdd != 3) || - (gc->state.tmuShadow[tmu].textureMode & SST_TRILINEAR) ) - return; + if (newLodBias > (0x1f<> (32-6-SST_LODBIAS_SHIFT)); + newtLod = (tLod | (newLodBias & SST_LODBIAS)); - /* unmask lodbias */ - tLod &= ~(SST_LODBIAS); - - idx = ((gc->chipCount - gc->sliCount) > 2); - iTexLodDither = (_GlideRoot.environment.texLodDither == 1); - - for (i = 0; i < gc->chipCount; i++) - { - /* don't need to modify lodbias if 0 */ - if(chipLodBias[iTexLodDither][idx][i] != 0) { - newLodBias = oldLodBias + chipLodBias[iTexLodDither][idx][i]; - - if(newLodBias > (0x1f<chipmask ); + /* Restore chip mask */ + _grChipMask( gc->chipmask ); + } + +FORGET_IT: GR_END(); #undef FN_NAME }