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)
|
void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut)
|
||||||
{
|
{
|
||||||
if (minW > p->globalTexW)
|
minW = findNextPow2(minW); minH = findNextPow2(minH);
|
||||||
{
|
|
||||||
p->globalTexDirty = true;
|
|
||||||
p->globalTexW = findNextPow2(minW);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minH > p->globalTexH)
|
if (minW != p->globalTexW || minH != p->globalTexH)
|
||||||
{
|
{
|
||||||
|
p->globalTexW = minW;
|
||||||
|
p->globalTexH = minH;
|
||||||
p->globalTexDirty = true;
|
p->globalTexDirty = true;
|
||||||
p->globalTexH = findNextPow2(minH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSizeOut = Vec2i(p->globalTexW, p->globalTexH);
|
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)
|
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,30 +388,17 @@ 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);
|
|
||||||
resizeNeeded = true;
|
|
||||||
}
|
|
||||||
if (size.y > baseTex.height)
|
|
||||||
{
|
|
||||||
newH = findNextPow2(size.y);
|
|
||||||
resizeNeeded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!resizeNeeded)
|
|
||||||
return;
|
|
||||||
|
|
||||||
shState->texPool().release(baseTex);
|
shState->texPool().release(baseTex);
|
||||||
baseTex = shState->texPool().request(newW, newH);
|
baseTex = shState->texPool().request(newW, newH);
|
||||||
|
|
||||||
baseTexDirty = true;
|
baseTexDirty = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void redrawBaseTex()
|
void redrawBaseTex()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue