From b963c67339b33224b888d58e7665a9410efb0105 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Tue, 23 Dec 2014 19:24:29 +0100 Subject: [PATCH] SharedState: Don't reallocate global tex on every bind --- src/sharedstate.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index 9e77f25..ff0989b 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -88,6 +88,7 @@ struct SharedStatePrivate TEX::ID globalTex; int globalTexW, globalTexH; + bool globalTexDirty; TEXFBO gpTexFBO; @@ -144,6 +145,7 @@ struct SharedStatePrivate TEX::setRepeat(false); TEX::setSmooth(false); TEX::allocEmpty(globalTexW, globalTexH); + globalTexDirty = false; TEXFBO::init(gpTexFBO); /* Reuse starting values */ @@ -251,16 +253,27 @@ GlobalIBO &SharedState::globalIBO() void SharedState::bindTex() { TEX::bind(p->globalTex); - TEX::allocEmpty(p->globalTexW, p->globalTexH); + + if (p->globalTexDirty) + { + TEX::allocEmpty(p->globalTexW, p->globalTexH); + p->globalTexDirty = false; + } } void SharedState::ensureTexSize(int minW, int minH, Vec2i ¤tSizeOut) { if (minW > p->globalTexW) + { + p->globalTexDirty = true; p->globalTexW = findNextPow2(minW); + } if (minH > p->globalTexH) + { + p->globalTexDirty = true; p->globalTexH = findNextPow2(minH); + } currentSizeOut = Vec2i(p->globalTexW, p->globalTexH); }