Allow Downsizing Textures
For some reason, this leads to a huge performance benefit on mobile devices, especially when using MegaSurface
This commit is contained in:
parent
eaf4bd5e66
commit
35c19792f8
|
@ -263,16 +263,13 @@ void SharedState::bindTex()
|
|||
|
||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
||||
{
|
||||
if (minW > p->globalTexW)
|
||||
{
|
||||
p->globalTexDirty = true;
|
||||
p->globalTexW = findNextPow2(minW);
|
||||
}
|
||||
minW = findNextPow2(minW); minH = findNextPow2(minH);
|
||||
|
||||
if (minH > p->globalTexH)
|
||||
if (minW != p->globalTexW || minH != p->globalTexH)
|
||||
{
|
||||
p->globalTexW = minW;
|
||||
p->globalTexH = minH;
|
||||
p->globalTexDirty = true;
|
||||
p->globalTexH = findNextPow2(minH);
|
||||
}
|
||||
|
||||
currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
|
||||
|
@ -280,22 +277,12 @@ void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
|||
|
||||
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
|
||||
{
|
||||
bool needResize = false;
|
||||
minW = findNextPow2(minW); minH = findNextPow2(minH);
|
||||
|
||||
if (minW > p->gpTexFBO.width)
|
||||
{
|
||||
p->gpTexFBO.width = findNextPow2(minW);
|
||||
needResize = true;
|
||||
}
|
||||
|
||||
if (minH > p->gpTexFBO.height)
|
||||
{
|
||||
p->gpTexFBO.height = findNextPow2(minH);
|
||||
needResize = true;
|
||||
}
|
||||
|
||||
if (needResize)
|
||||
if (minW != p->gpTexFBO.width || minH != p->gpTexFBO.height)
|
||||
{
|
||||
p->gpTexFBO.width = minW;
|
||||
p->gpTexFBO.height = minH;
|
||||
TEX::bind(p->gpTexFBO.tex);
|
||||
TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
|
||||
}
|
||||
|
|
|
@ -388,30 +388,17 @@ struct WindowPrivate
|
|||
|
||||
void ensureBaseTexReady()
|
||||
{
|
||||
/* Make sure texture is big enough */
|
||||
int newW = baseTex.width;
|
||||
int newH = baseTex.height;
|
||||
bool resizeNeeded = false;
|
||||
/* Make sure texture is properly sized */
|
||||
int newW = findNextPow2(size.x);
|
||||
int newH = findNextPow2(size.y);
|
||||
|
||||
if (size.x > baseTex.width)
|
||||
if (newW != baseTex.width || newH != baseTex.height)
|
||||
{
|
||||
newW = findNextPow2(size.x);
|
||||
resizeNeeded = true;
|
||||
}
|
||||
if (size.y > baseTex.height)
|
||||
{
|
||||
newH = findNextPow2(size.y);
|
||||
resizeNeeded = true;
|
||||
}
|
||||
|
||||
if (!resizeNeeded)
|
||||
return;
|
||||
|
||||
shState->texPool().release(baseTex);
|
||||
baseTex = shState->texPool().request(newW, newH);
|
||||
|
||||
baseTexDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void redrawBaseTex()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue