From 7ca20f8a429620de507114a147b119703a657f3d Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Thu, 18 Dec 2014 20:14:27 +0600 Subject: [PATCH] Update CachedTexture::shiftScaleS and CachedTexture::shiftScaleT before call to TextureCache::activateTexture() since these parameters can change between frames. Fixed "Ground incorrect at some place durin mario golf intro #78" --- Textures.cpp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/Textures.cpp b/Textures.cpp index 6592f0e8..2403ba08 100644 --- a/Textures.cpp +++ b/Textures.cpp @@ -1101,7 +1101,7 @@ u32 _calculateCRC(u32 t, const TextureParams & _params) void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture) { - glActiveTexture( GL_TEXTURE0 + _t ); + glActiveTexture(GL_TEXTURE0 + _t); // Bind the cached texture glBindTexture( GL_TEXTURE_2D, _pTexture->glName ); @@ -1220,6 +1220,23 @@ void TextureCache::_updateBackground() current[0] = pCurrent; } +static +void _updateShiftScale(u32 _t, CachedTexture *_pTexture) +{ + _pTexture->shiftScaleS = 1.0f; + _pTexture->shiftScaleT = 1.0f; + + if (gSP.textureTile[_t]->shifts > 10) + _pTexture->shiftScaleS = (f32)(1 << (16 - gSP.textureTile[_t]->shifts)); + else if (gSP.textureTile[_t]->shifts > 0) + _pTexture->shiftScaleS /= (f32)(1 << gSP.textureTile[_t]->shifts); + + if (gSP.textureTile[_t]->shiftt > 10) + _pTexture->shiftScaleT = (f32)(1 << (16 - gSP.textureTile[_t]->shiftt)); + else if (gSP.textureTile[_t]->shiftt > 0) + _pTexture->shiftScaleT /= (f32)(1 << gSP.textureTile[_t]->shiftt); +} + void TextureCache::update(u32 _t) { if (m_bitDepth != config.texture.textureBitDepth) @@ -1266,6 +1283,7 @@ void TextureCache::update(u32 _t) } if (current[_t] != NULL && current[_t]->crc == crc) { + _updateShiftScale(_t, current[_t]); activateTexture(_t, current[_t]); return; } @@ -1287,6 +1305,7 @@ void TextureCache::update(u32 _t) (current.size == gSP.textureTile[_t]->size) ); + _updateShiftScale(_t, ¤t); activateTexture(_t, ¤t); m_hits++; return; @@ -1335,23 +1354,12 @@ void TextureCache::update(u32 _t) pCurrent->scaleS = 1.0f / (f32)(pCurrent->realWidth); pCurrent->scaleT = 1.0f / (f32)(pCurrent->realHeight); - pCurrent->shiftScaleS = 1.0f; - pCurrent->shiftScaleT = 1.0f; - pCurrent->offsetS = 0.5f; pCurrent->offsetT = 0.5f; - if (gSP.textureTile[_t]->shifts > 10) - pCurrent->shiftScaleS = (f32)(1 << (16 - gSP.textureTile[_t]->shifts)); - else if (gSP.textureTile[_t]->shifts > 0) - pCurrent->shiftScaleS /= (f32)(1 << gSP.textureTile[_t]->shifts); + _updateShiftScale(_t, pCurrent); - if (gSP.textureTile[_t]->shiftt > 10) - pCurrent->shiftScaleT = (f32)(1 << (16 - gSP.textureTile[_t]->shiftt)); - else if (gSP.textureTile[_t]->shiftt > 0) - pCurrent->shiftScaleT /= (f32)(1 << gSP.textureTile[_t]->shiftt); - - _load( _t, pCurrent ); + _load(_t, pCurrent); activateTexture( _t, pCurrent ); m_cachedBytes += pCurrent->textureBytes;