fixed problem with performance trilinear and lodbias sign
This commit is contained in:
@@ -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<<SST_LODBIAS_SHIFT, 0x02<<SST_LODBIAS_SHIFT, 0x00<<SST_LODBIAS_SHIFT, 0x02<<SST_LODBIAS_SHIFT},
|
||||
{0x00<<SST_LODBIAS_SHIFT, 0x01<<SST_LODBIAS_SHIFT, 0x02<<SST_LODBIAS_SHIFT, 0x03<<SST_LODBIAS_SHIFT}
|
||||
},
|
||||
};
|
||||
|
||||
/* unmask lodbias */
|
||||
tLod &= ~(SST_LODBIAS);
|
||||
|
||||
for (i = 0; i < gc->chipCount; i++)
|
||||
{
|
||||
{-0x01<<SST_LODBIAS_SHIFT, 0x02<<SST_LODBIAS_SHIFT, -0x01<<SST_LODBIAS_SHIFT, 0x02<<SST_LODBIAS_SHIFT},
|
||||
{-0x01<<SST_LODBIAS_SHIFT, 0x00<<SST_LODBIAS_SHIFT, 0x01<<SST_LODBIAS_SHIFT, 0x02<<SST_LODBIAS_SHIFT}
|
||||
}
|
||||
};
|
||||
|
||||
GR_BEGIN_NOFIFOCHECK("g3LodBiasPerChip", 88);
|
||||
/* don't need to modify lodbias if 0 */
|
||||
if(chipLodBias[idx][i] != 0) {
|
||||
newLodBias = oldLodBias + chipLodBias[idx][i];
|
||||
|
||||
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) )
|
||||
return;
|
||||
if (newLodBias > (0x1f<<SST_LODBIAS_SHIFT))
|
||||
newLodBias = (0x1f<<SST_LODBIAS_SHIFT);
|
||||
/*else if (newLodBias < (-0x20<<SST_LODBIAS_SHIFT))
|
||||
newLodBias = (-0x20<<SST_LODBIAS_SHIFT);*/
|
||||
|
||||
/* sign extend it. */
|
||||
oldLodBias = (((tLod & SST_LODBIAS) << (32-6-SST_LODBIAS_SHIFT)) >> (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<<SST_LODBIAS_SHIFT)) newLodBias = (0x1f<<SST_LODBIAS_SHIFT);
|
||||
else if(newLodBias < (-0x20<<SST_LODBIAS_SHIFT)) newLodBias = (-0x20<<SST_LODBIAS_SHIFT);
|
||||
newLodBias &= SST_LODBIAS;
|
||||
newtLod = tLod | newLodBias;
|
||||
|
||||
{
|
||||
SstRegs* tmuHw = SST_TMU(hw, tmu);
|
||||
_grChipMask( 0x01 << i );
|
||||
REG_GROUP_BEGIN((0x02 << tmu), tLOD, 1, 0x1);
|
||||
{
|
||||
REG_GROUP_SET(tmuHw, tLOD, tLod);
|
||||
SstRegs* tmuHw = SST_TMU(hw, tmu);
|
||||
_grChipMask( 0x01 << i );
|
||||
REG_GROUP_BEGIN((0x02 << tmu), tLOD, 1, 0x1);
|
||||
{
|
||||
REG_GROUP_SET(tmuHw, tLOD, newtLod);
|
||||
}
|
||||
REG_GROUP_END();
|
||||
}
|
||||
REG_GROUP_END();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore chip mask */
|
||||
_grChipMask( gc->chipmask );
|
||||
|
||||
/* Restore chip mask */
|
||||
_grChipMask( gc->chipmask );
|
||||
}
|
||||
|
||||
FORGET_IT:
|
||||
GR_END();
|
||||
#undef FN_NAME
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user