Graphics: Remove superfluous TEXFBOs while reusing existing ones

While the PingPong buffers were always texture-backed, currentScene
and transBuffer used to be backed by renderbuffers, which might have
been more optimized as render targets on older hardware; but since
all buffers in Graphics got switched to being texture backed to allow
blitting via rendering (when hardware blitting isn't available or broken,
eg. on mobile platforms), their reason to exist vanished.

For transBuffer, we can reuse the backbuffer of the PingPong structure,
while currentScene might have been useless from the start.
This commit is contained in:
Jonas Kulla 2017-05-11 12:37:15 +02:00
parent cab453ac3a
commit bd694f9f99
1 changed files with 12 additions and 21 deletions

View File

@ -474,9 +474,7 @@ struct GraphicsPrivate
bool frozen; bool frozen;
TEXFBO frozenScene; TEXFBO frozenScene;
TEXFBO currentScene;
Quad screenQuad; Quad screenQuad;
TEXFBO transBuffer;
/* Global list of all live Disposables /* Global list of all live Disposables
* (disposed on reset) */ * (disposed on reset) */
@ -502,26 +500,15 @@ struct GraphicsPrivate
TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y); TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y);
TEXFBO::linkFBO(frozenScene); TEXFBO::linkFBO(frozenScene);
TEXFBO::init(currentScene);
TEXFBO::allocEmpty(currentScene, scRes.x, scRes.y);
TEXFBO::linkFBO(currentScene);
FloatRect screenRect(0, 0, scRes.x, scRes.y); FloatRect screenRect(0, 0, scRes.x, scRes.y);
screenQuad.setTexPosRect(screenRect, screenRect); screenQuad.setTexPosRect(screenRect, screenRect);
TEXFBO::init(transBuffer);
TEXFBO::allocEmpty(transBuffer, scRes.x, scRes.y);
TEXFBO::linkFBO(transBuffer);
fpsLimiter.resetFrameAdjust(); fpsLimiter.resetFrameAdjust();
} }
~GraphicsPrivate() ~GraphicsPrivate()
{ {
TEXFBO::fini(frozenScene); TEXFBO::fini(frozenScene);
TEXFBO::fini(currentScene);
TEXFBO::fini(transBuffer);
} }
void updateScreenResoRatio(RGSSThreadData *rtData) void updateScreenResoRatio(RGSSThreadData *rtData)
@ -721,8 +708,15 @@ void Graphics::transition(int duration,
setBrightness(255); setBrightness(255);
/* The PP frontbuffer will hold the current scene after the
* composition step. Since the backbuffer is unused during
* the transition, we can reuse it as the target buffer for
* the final rendered image. */
TEXFBO &currentScene = p->screen.getPP().frontBuffer();
TEXFBO &transBuffer = p->screen.getPP().backBuffer();
/* Capture new scene */ /* Capture new scene */
p->compositeToBuffer(p->currentScene); p->screen.composite();
/* If no transition bitmap is provided, /* If no transition bitmap is provided,
* we can use a simplified shader */ * we can use a simplified shader */
@ -735,7 +729,7 @@ void Graphics::transition(int duration,
shader.bind(); shader.bind();
shader.applyViewportProj(); shader.applyViewportProj();
shader.setFrozenScene(p->frozenScene.tex); shader.setFrozenScene(p->frozenScene.tex);
shader.setCurrentScene(p->currentScene.tex); shader.setCurrentScene(currentScene.tex);
shader.setTransMap(transMap->getGLTypes().tex); shader.setTransMap(transMap->getGLTypes().tex);
shader.setVague(vague / 256.0f); shader.setVague(vague / 256.0f);
shader.setTexSize(p->scRes); shader.setTexSize(p->scRes);
@ -746,7 +740,7 @@ void Graphics::transition(int duration,
shader.bind(); shader.bind();
shader.applyViewportProj(); shader.applyViewportProj();
shader.setFrozenScene(p->frozenScene.tex); shader.setFrozenScene(p->frozenScene.tex);
shader.setCurrentScene(p->currentScene.tex); shader.setCurrentScene(currentScene.tex);
shader.setTexSize(p->scRes); shader.setTexSize(p->scRes);
} }
@ -790,7 +784,7 @@ void Graphics::transition(int duration,
/* Draw the composed frame to a buffer first /* Draw the composed frame to a buffer first
* (we need this because we're skipping PingPong) */ * (we need this because we're skipping PingPong) */
FBO::bind(p->transBuffer.fbo); FBO::bind(transBuffer.fbo);
FBO::clear(); FBO::clear();
p->screenQuad.draw(); p->screenQuad.draw();
@ -801,7 +795,7 @@ void Graphics::transition(int duration,
FBO::clear(); FBO::clear();
GLMeta::blitBeginScreen(Vec2i(p->winSize)); GLMeta::blitBeginScreen(Vec2i(p->winSize));
GLMeta::blitSource(p->transBuffer); GLMeta::blitSource(transBuffer);
p->metaBlitBufferFlippedScaled(); p->metaBlitBufferFlippedScaled();
GLMeta::blitEnd(); GLMeta::blitEnd();
@ -945,13 +939,10 @@ void Graphics::resizeScreen(int width, int height)
p->screen.setResolution(width, height); p->screen.setResolution(width, height);
TEXFBO::allocEmpty(p->frozenScene, width, height); TEXFBO::allocEmpty(p->frozenScene, width, height);
TEXFBO::allocEmpty(p->currentScene, width, height);
FloatRect screenRect(0, 0, width, height); FloatRect screenRect(0, 0, width, height);
p->screenQuad.setTexPosRect(screenRect, screenRect); p->screenQuad.setTexPosRect(screenRect, screenRect);
TEXFBO::allocEmpty(p->transBuffer, width, height);
shState->eThread().requestWindowResize(width, height); shState->eThread().requestWindowResize(width, height);
} }