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,39 +263,26 @@ void SharedState::bindTex()
|
||||||
|
|
||||||
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
||||||
{
|
{
|
||||||
if (minW > p->globalTexW)
|
minW = findNextPow2(minW); minH = findNextPow2(minH);
|
||||||
|
|
||||||
|
if (minW != p->globalTexW || minH != p->globalTexH)
|
||||||
{
|
{
|
||||||
|
p->globalTexW = minW;
|
||||||
|
p->globalTexH = minH;
|
||||||
p->globalTexDirty = true;
|
p->globalTexDirty = true;
|
||||||
p->globalTexW = findNextPow2(minW);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minH > p->globalTexH)
|
|
||||||
{
|
|
||||||
p->globalTexDirty = true;
|
|
||||||
p->globalTexH = findNextPow2(minH);
|
|
||||||
}
|
|
||||||
|
|
||||||
currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
|
currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
|
TEXFBO &SharedState::gpTexFBO(int minW, int minH)
|
||||||
{
|
{
|
||||||
bool needResize = false;
|
minW = findNextPow2(minW); minH = findNextPow2(minH);
|
||||||
|
|
||||||
if (minW > p->gpTexFBO.width)
|
if (minW != p->gpTexFBO.width || minH != p->gpTexFBO.height)
|
||||||
{
|
|
||||||
p->gpTexFBO.width = findNextPow2(minW);
|
|
||||||
needResize = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minH > p->gpTexFBO.height)
|
|
||||||
{
|
|
||||||
p->gpTexFBO.height = findNextPow2(minH);
|
|
||||||
needResize = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needResize)
|
|
||||||
{
|
{
|
||||||
|
p->gpTexFBO.width = minW;
|
||||||
|
p->gpTexFBO.height = minH;
|
||||||
TEX::bind(p->gpTexFBO.tex);
|
TEX::bind(p->gpTexFBO.tex);
|
||||||
TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
|
TEX::allocEmpty(p->gpTexFBO.width, p->gpTexFBO.height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,29 +388,16 @@ struct WindowPrivate
|
||||||
|
|
||||||
void ensureBaseTexReady()
|
void ensureBaseTexReady()
|
||||||
{
|
{
|
||||||
/* Make sure texture is big enough */
|
/* Make sure texture is properly sized */
|
||||||
int newW = baseTex.width;
|
int newW = findNextPow2(size.x);
|
||||||
int newH = baseTex.height;
|
int newH = findNextPow2(size.y);
|
||||||
bool resizeNeeded = false;
|
|
||||||
|
|
||||||
if (size.x > baseTex.width)
|
if (newW != baseTex.width || newH != baseTex.height)
|
||||||
{
|
{
|
||||||
newW = findNextPow2(size.x);
|
shState->texPool().release(baseTex);
|
||||||
resizeNeeded = true;
|
baseTex = shState->texPool().request(newW, newH);
|
||||||
|
baseTexDirty = 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()
|
void redrawBaseTex()
|
||||||
|
|
Loading…
Reference in New Issue