remove three methods related to do texture scaling and ensure power of 2 textures on the CPU side. This methods where actually never called. Also remove members related to this methods

This commit is contained in:
Dorian Fevrier 2014-12-23 02:08:59 -05:00
parent e6066f07c0
commit 5665013d58
8 changed files with 5 additions and 243 deletions

View file

@ -104,7 +104,6 @@ void ConvertRGBA16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
// N64 32 bit textures are in R8G8B8A8 format. On little endian processors,
@ -186,7 +185,6 @@ void ConvertRGBA32(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
// E.g. Dear Mario text
@ -290,7 +288,6 @@ void ConvertIA4(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -361,7 +358,6 @@ void ConvertIA8(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -429,7 +425,6 @@ void ConvertIA16(CTexture *pTexture, const TxtrInfo &tinfo)
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -545,7 +540,6 @@ void ConvertI4(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
// Used by MarioKart
@ -607,7 +601,6 @@ void ConvertI8(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -744,7 +737,6 @@ void ConvertCI4_RGBA16(CTexture *pTexture, const TxtrInfo &tinfo)
}
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
// Used by Starfox intro
@ -851,7 +843,6 @@ void ConvertCI4_IA16(CTexture *pTexture, const TxtrInfo &tinfo)
}
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -925,7 +916,6 @@ void ConvertCI8_RGBA16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -999,7 +989,6 @@ void ConvertCI8_IA16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
void ConvertYUV(CTexture *pTexture, const TxtrInfo &tinfo)
@ -1103,7 +1092,6 @@ void ConvertYUV(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
uint32 ConvertYUV16ToR8G8B8(int Y, int U, int V)
@ -1254,7 +1242,6 @@ void Convert4b(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
void Convert8b(CTexture *pTexture, const TxtrInfo &tinfo)
@ -1355,7 +1342,6 @@ void Convert8b(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -1425,6 +1411,5 @@ void Convert16b(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}

View file

@ -128,7 +128,6 @@ void ConvertRGBA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
void ConvertRGBA32_16(CTexture *pTexture, const TxtrInfo &tinfo)
@ -223,7 +222,6 @@ void ConvertRGBA32_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -307,7 +305,6 @@ void ConvertIA4_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
// E.g Mario's head textures
@ -366,7 +363,6 @@ void ConvertIA8_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -402,7 +398,6 @@ void ConvertIA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -484,7 +479,6 @@ void ConvertI4_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
// Used by MarioKart
@ -546,7 +540,6 @@ void ConvertI8_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -618,7 +611,6 @@ void ConvertCI4_RGBA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
//*****************************************************************************
@ -714,7 +706,6 @@ void ConvertCI4_IA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -772,7 +763,6 @@ void ConvertCI8_RGBA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -830,7 +820,6 @@ void ConvertCI8_IA16_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -939,7 +928,6 @@ void ConvertYUV_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
uint16 ConvertYUV16ToR4G4B4(int Y, int U, int V)
@ -1053,7 +1041,6 @@ void Convert4b_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
void Convert8b_16(CTexture *pTexture, const TxtrInfo &tinfo)
@ -1141,7 +1128,6 @@ void Convert8b_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}
@ -1208,6 +1194,5 @@ void Convert16b_16(CTexture *pTexture, const TxtrInfo &tinfo)
}
pTexture->EndUpdate(&dInfo);
pTexture->SetOthersVariables();
}

View file

@ -396,7 +396,6 @@ void DumpCachedTexture(uint32 index)
DebuggerAppendMsg("Display cached texture #%d of %d\n", index, gTextureManager.GetNumOfCachedTexture());
DebuggerAppendMsg("W:%d, H:%d, RealW:%d, RealH:%d, D3DW:%d, D3DH: %d", p->ti.WidthToCreate, p->ti.HeightToCreate,
p->ti.WidthToLoad, p->ti.HeightToLoad, p->pTexture->m_dwCreatedTextureWidth, p->pTexture->m_dwCreatedTextureHeight);
DebuggerAppendMsg("ScaledS:%s, ScaledT:%s", p->pTexture->m_bScaledS?"T":"F", p->pTexture->m_bScaledT?"T":"F");
}
else
{

View file

@ -97,15 +97,13 @@ bool COGLTexture::StartUpdate(DrawInfo *di)
{
if (m_pTexture == NULL)
return false;
di->dwHeight = (uint16)m_dwHeight;
di->dwWidth = (uint16)m_dwWidth;
di->dwCreatedHeight = m_dwCreatedTextureHeight;
di->dwCreatedWidth = m_dwCreatedTextureWidth;
di->lpSurface = m_pTexture;
di->lPitch = GetPixelSize()*m_dwCreatedTextureWidth;
return true;
}
@ -161,9 +159,3 @@ void COGLTexture::EndUpdate(DrawInfo *di)
glBindTexture(GL_TEXTURE_2D, 0);
}
// Keep in mind that the real texture is not scaled to fix the created opengl texture yet.
// when the image is need to be scaled, ScaleImageToSurface in CTexure will be called to
// scale the image automatically

View file

@ -32,10 +32,6 @@ CTexture::CTexture(uint32 dwWidth, uint32 dwHeight, TextureUsage usage) :
m_dwCreatedTextureHeight(dwHeight),
m_fXScale(1.0f),
m_fYScale(1.0f),
m_bScaledS(false),
m_bScaledT(false),
m_bClampedS(false),
m_bClampedT(false),
m_bIsEnhancedTexture(false),
m_Usage(usage),
m_pTexture(NULL),
@ -65,175 +61,6 @@ uint32 CTexture::GetPixelSize()
return 2;
}
// There are reasons to create this function. D3D and OGL will only create surface of width and height
// as 2's pow, for example, N64's 20x14 image, D3D and OGL will create a 32x16 surface.
// When we using such a surface as D3D texture, and the U and V address is for the D3D and OGL surface
// width and height. It is still OK if the U and V addr value is less than the real image within
// the D3D surface. But we will have problems if the U and V addr value is larger than it, or even
// large then 1.0.
// In such a case, we need to scale the image to the D3D surface dimension, to ease the U/V addr
// limition
void CTexture::ScaleImageToSurface(bool scaleS, bool scaleT)
{
uint8 g_ucTempBuffer[1024*1024*4];
if( scaleS==false && scaleT==false) return;
// If the image is not scaled, call this function to scale the real image to
// the D3D given dimension
uint32 width = scaleS ? m_dwWidth : m_dwCreatedTextureWidth;
uint32 height = scaleT ? m_dwHeight : m_dwCreatedTextureHeight;
uint32 xDst, yDst;
uint32 xSrc, ySrc;
DrawInfo di;
if (!StartUpdate(&di))
{
return;
}
int pixSize = GetPixelSize();
// Copy across from the temp buffer to the surface
switch (pixSize)
{
case 4:
{
memcpy((uint8*)g_ucTempBuffer, (uint8*)(di.lpSurface), m_dwHeight*m_dwCreatedTextureWidth*4);
uint32 * pDst;
uint32 * pSrc;
for (yDst = 0; yDst < m_dwCreatedTextureHeight; yDst++)
{
// ySrc ranges from 0..m_dwHeight
// I'd rather do this but sometimes very narrow (i.e. 1 pixel)
// surfaces are created which results in /0...
//ySrc = (yDst * (m_dwHeight-1)) / (d3dTextureHeight-1);
ySrc = (uint32)((yDst * height) / m_dwCreatedTextureHeight+0.49f);
pSrc = (uint32*)((uint8*)g_ucTempBuffer + (ySrc * m_dwCreatedTextureWidth * 4));
pDst = (uint32*)((uint8*)di.lpSurface + (yDst * di.lPitch));
for (xDst = 0; xDst < m_dwCreatedTextureWidth; xDst++)
{
xSrc = (uint32)((xDst * width) / m_dwCreatedTextureWidth+0.49f);
pDst[xDst] = pSrc[xSrc];
}
}
}
break;
case 2:
{
memcpy((uint8*)g_ucTempBuffer, (uint8*)(di.lpSurface), m_dwHeight*m_dwCreatedTextureWidth*2);
uint16 * pDst;
uint16 * pSrc;
for (yDst = 0; yDst < m_dwCreatedTextureHeight; yDst++)
{
// ySrc ranges from 0..m_dwHeight
ySrc = (yDst * height) / m_dwCreatedTextureHeight;
pSrc = (uint16*)((uint8*)g_ucTempBuffer + (ySrc * m_dwCreatedTextureWidth * 2));
pDst = (uint16*)((uint8*)di.lpSurface + (yDst * di.lPitch));
for (xDst = 0; xDst < m_dwCreatedTextureWidth; xDst++)
{
xSrc = (xDst * width) / m_dwCreatedTextureWidth;
pDst[xDst] = pSrc[xSrc];
}
}
}
break;
}
EndUpdate(&di);
if( scaleS ) m_bScaledS = true;
if( scaleT ) m_bScaledT = true;
}
void CTexture::ClampImageToSurfaceS()
{
if( !m_bClampedS && m_dwWidth < m_dwCreatedTextureWidth )
{
DrawInfo di;
if( StartUpdate(&di) )
{
if( m_dwTextureFmt == TEXTURE_FMT_A8R8G8B8 )
{
for( uint32 y = 0; y<m_dwHeight; y++ )
{
uint32* line = (uint32*)((uint8*)di.lpSurface+di.lPitch*y);
uint32 val = line[m_dwWidth-1];
for( uint32 x=m_dwWidth; x<m_dwCreatedTextureWidth; x++ )
{
line[x] = val;
}
}
}
else
{
for( uint32 y = 0; y<m_dwHeight; y++ )
{
uint16* line = (uint16*)((uint8*)di.lpSurface+di.lPitch*y);
uint16 val = line[m_dwWidth-1];
for( uint32 x=m_dwWidth; x<m_dwCreatedTextureWidth; x++ )
{
line[x] = val;
}
}
}
EndUpdate(&di);
}
}
m_bClampedS = true;
}
void CTexture::ClampImageToSurfaceT()
{
if( !m_bClampedT && m_dwHeight < m_dwCreatedTextureHeight )
{
DrawInfo di;
if( StartUpdate(&di) )
{
if( m_dwTextureFmt == TEXTURE_FMT_A8R8G8B8 )
{
uint32* linesrc = (uint32*)((uint8*)di.lpSurface+di.lPitch*(m_dwHeight-1));
for( uint32 y = m_dwHeight; y<m_dwCreatedTextureHeight; y++ )
{
uint32* linedst = (uint32*)((uint8*)di.lpSurface+di.lPitch*y);
for( uint32 x=0; x<m_dwCreatedTextureWidth; x++ )
{
linedst[x] = linesrc[x];
}
}
}
else
{
uint16* linesrc = (uint16*)((uint8*)di.lpSurface+di.lPitch*(m_dwHeight-1));
for( uint32 y = m_dwHeight; y<m_dwCreatedTextureHeight; y++ )
{
uint16* linedst = (uint16*)((uint8*)di.lpSurface+di.lPitch*y);
for( uint32 x=0; x<m_dwCreatedTextureWidth; x++ )
{
linedst[x] = linesrc[x];
}
}
}
EndUpdate(&di);
}
}
m_bClampedT = true;
}
void CTexture::RestoreAlphaChannel(void)
{
DrawInfo di;

View file

@ -64,29 +64,14 @@ public:
float m_fXScale; // = m_dwCorrectedWidth/m_dwWidth
float m_fYScale; // = m_dwCorrectedHeight/m_dwWidth
bool m_bScaledS;
bool m_bScaledT;
bool m_bClampedS;
bool m_bClampedT;
bool m_bIsEnhancedTexture;
TextureUsage m_Usage;
virtual void ScaleImageToSurface(bool scaleS=true, bool scaleT=true);
virtual void ClampImageToSurfaceS();
virtual void ClampImageToSurfaceT();
virtual LPRICETEXTURE GetTexture() { return m_pTexture; }
uint32 GetPixelSize();
TextureFmt GetSurfaceFormat(void); // Surface pixel format...
inline void SetOthersVariables(void)
{
m_bClampedS = m_bScaledS = (m_dwWidth == m_dwCreatedTextureWidth);
m_bClampedT = m_bScaledT = (m_dwHeight == m_dwCreatedTextureHeight);
}
// Provides access to "surface"
virtual bool StartUpdate(DrawInfo *di)=0;

View file

@ -780,7 +780,6 @@ void EnhanceTexture(TxtrCacheEntry *pEntry)
pSurfaceHandler->EndUpdate(&destInfo);
}
pSurfaceHandler->SetOthersVariables();
pSurfaceHandler->m_bIsEnhancedTexture = true;
}
@ -2103,7 +2102,6 @@ void LoadHiresTexture( TxtrCacheEntry &entry )
}
entry.pEnhancedTexture->EndUpdate(&info);
entry.pEnhancedTexture->SetOthersVariables();
entry.pEnhancedTexture->m_bIsEnhancedTexture = true;
entry.dwEnhancementFlag = TEXTURE_EXTERNAL;

View file

@ -505,11 +505,6 @@ TxtrCacheEntry * CTextureManager::CreateNewCacheEntry(uint32 dwAddr, uint32 dwWi
_VIDEO_DisplayTemporaryMessage("Error to create an texture");
TRACE2("Warning, unable to create %d x %d texture!", dwWidth, dwHeight);
}
else
{
pEntry->pTexture->m_bScaledS = false;
pEntry->pTexture->m_bScaledT = false;
}
}
// Initialize
@ -708,14 +703,10 @@ TxtrCacheEntry * CTextureManager::GetTexture(TxtrInfo * pgti, bool fromTMEM, boo
if( pEntry->pTexture->m_dwCreatedTextureWidth < pgti->WidthToCreate )
{
pEntry->ti.WidthToLoad = pEntry->pTexture->m_dwCreatedTextureWidth;
pEntry->pTexture->m_bScaledS = false;
pEntry->pTexture->m_bScaledT = false;
}
if( pEntry->pTexture->m_dwCreatedTextureHeight < pgti->HeightToCreate )
{
pEntry->ti.HeightToLoad = pEntry->pTexture->m_dwCreatedTextureHeight;
pEntry->pTexture->m_bScaledT = false;
pEntry->pTexture->m_bScaledS = false;
}
TextureFmt dwType = pEntry->pTexture->GetSurfaceFormat();
@ -747,9 +738,7 @@ TxtrCacheEntry * CTextureManager::GetTexture(TxtrInfo * pgti, bool fromTMEM, boo
{
LOG_TEXTURE(TRACE0(" Load new texture from RDRAM:\n"));
if (dwType == TEXTURE_FMT_A8R8G8B8)
{
ConvertTexture(pEntry, fromTMEM);
}
else
ConvertTexture_16(pEntry, fromTMEM);
SAFE_DELETE(pEntry->pEnhancedTexture);
@ -784,7 +773,6 @@ TxtrCacheEntry * CTextureManager::GetTexture(TxtrInfo * pgti, bool fromTMEM, boo
}
DebuggerAppendMsg("W:%d, H:%d, RealW:%d, RealH:%d, D3DW:%d, D3DH: %d", pEntry->ti.WidthToCreate, pEntry->ti.HeightToCreate,
pEntry->ti.WidthToLoad, pEntry->ti.HeightToLoad, pEntry->pTexture->m_dwCreatedTextureWidth, pEntry->pTexture->m_dwCreatedTextureHeight);
DebuggerAppendMsg("ScaledS:%s, ScaledT:%s, CRC=%08X", pEntry->pTexture->m_bScaledS?"T":"F", pEntry->pTexture->m_bScaledT?"T":"F", pEntry->dwCRC);
DebuggerPause();
CRender::g_pRender->SetCurrentTexture( 0, NULL, 64, 64, NULL);
}
@ -821,7 +809,9 @@ extern ConvertFunction gConvertTlutFunctions_16[ 8 ][ 4 ];
void CTextureManager::ConvertTexture(TxtrCacheEntry * pEntry, bool fromTMEM)
{
static uint32 dwCount = 0;
// We first figure out which convert function to use in the various
// function pointer arrays.
ConvertFunction pF;
if( options.bUseFullTMEM && fromTMEM && status.bAllowLoadFromTMEM )
{
@ -845,6 +835,7 @@ void CTextureManager::ConvertTexture(TxtrCacheEntry * pEntry, bool fromTMEM)
}
}
// Once we found it we simply execute it on the texture.
if( pF )
{
pF( pEntry->pTexture, pEntry->ti );