Use POT texture when resizing, when NOTP is not supported

This commit is contained in:
Jupeyy 2020-09-14 22:11:39 +02:00
parent 3eea399d37
commit 8b29240491

View file

@ -473,7 +473,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Update(const CCommandBuffer::
int ResizedW = (int)(Width * ResizeW);
int ResizedH = (int)(Height * ResizeH);
void *pTmpData = Resize(Width, Height, ResizedW, ResizedH, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
void *pTmpData = Resize(Width, Height, ResizedW, ResizedH, pCommand->m_Format, static_cast<const unsigned char *>(pTexData));
free(pTexData);
pTexData = pTmpData;
@ -484,6 +484,8 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Update(const CCommandBuffer::
if(m_aTextures[pCommand->m_Slot].m_RescaleCount > 0)
{
int OldWidth = Width;
int OldHeight = Height;
for(int i = 0; i < m_aTextures[pCommand->m_Slot].m_RescaleCount; ++i)
{
Width >>= 1;
@ -493,7 +495,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Update(const CCommandBuffer::
Y /= 2;
}
void *pTmpData = Resize(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
void *pTmpData = Resize(OldWidth, OldHeight, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pTexData));
free(pTexData);
pTexData = pTmpData;
}
@ -563,7 +565,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
int PowerOfTwoHeight = HighestBit(Height);
if(Width != PowerOfTwoWidth || Height != PowerOfTwoHeight)
{
void *pTmpData = Resize(Width, Height, PowerOfTwoWidth, PowerOfTwoHeight, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
void *pTmpData = Resize(Width, Height, PowerOfTwoWidth, PowerOfTwoHeight, pCommand->m_Format, static_cast<const unsigned char *>(pTexData));
free(pTexData);
pTexData = pTmpData;
@ -578,6 +580,10 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
int RescaleCount = 0;
if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB || pCommand->m_Format == CCommandBuffer::TEXFORMAT_ALPHA)
{
int OldWidth = Width;
int OldHeight = Height;
bool NeedsResize = false;
if(Width > m_MaxTexSize || Height > m_MaxTexSize)
{
do
@ -586,18 +592,19 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
Height >>= 1;
++RescaleCount;
} while(Width > m_MaxTexSize || Height > m_MaxTexSize);
void *pTmpData = Resize(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
free(pTexData);
pTexData = pTmpData;
NeedsResize = true;
}
else if(pCommand->m_Format != CCommandBuffer::TEXFORMAT_ALPHA && (Width > 16 && Height > 16 && (pCommand->m_Flags&CCommandBuffer::TEXFLAG_QUALITY) == 0))
{
Width >>= 1;
Height >>= 1;
++RescaleCount;
NeedsResize = true;
}
void *pTmpData = Resize(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
if(NeedsResize)
{
void *pTmpData = Resize(OldWidth, OldHeight, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pTexData));
free(pTexData);
pTexData = pTmpData;
}