Avoid polluting glstate in GetTempFBO().

Since we do this "late", we might overwrite important settings, such as
stencil, color masks, etc.

This affects both depal and fbo shader blending.

Didn't do it for all ClearBuffer()s, since I'm worried some might be
intentionally resetting state.
This commit is contained in:
Unknown W. Brackets committed 2015-11-03 22:37:19 -08:00
1 parent 7af7b2bc6d
commit 5ff3e6a5e7
5 files changed
+47 -17

No files matched your search

+22 -7
View File
@@ -86,12 +86,20 @@ static const char color_vs[] =
void ConvertFromRGBA8888(u8 *dst, const u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format);
void FramebufferManager::ClearBuffer() {
glstate.scissorTest.disable();
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glstate.stencilFunc.set(GL_ALWAYS, 0, 0);
glstate.stencilMask.set(0xFF);
void FramebufferManager::ClearBuffer(bool keepState) {
if (keepState) {
glstate.scissorTest.force(false);
glstate.depthWrite.force(GL_TRUE);
glstate.colorMask.force(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glstate.stencilFunc.force(GL_ALWAYS, 0, 0);
glstate.stencilMask.force(0xFF);
} else {
glstate.scissorTest.disable();
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glstate.stencilFunc.set(GL_ALWAYS, 0, 0);
glstate.stencilMask.set(0xFF);
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearStencil(0);
#ifdef USING_GLES2
@@ -100,6 +108,13 @@ void FramebufferManager::ClearBuffer() {
glClearDepth(0.0);
#endif
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
if (keepState) {
glstate.scissorTest.restore();
glstate.depthWrite.restore();
glstate.colorMask.restore();
glstate.stencilFunc.restore();
glstate.stencilMask.restore();
}
}
void FramebufferManager::ClearDepthBuffer() {
@@ -859,7 +874,7 @@ FBO *FramebufferManager::GetTempFBO(u16 w, u16 h, FBOColorDepth depth) {
if (!fbo)
return fbo;
fbo_bind_as_render_target(fbo);
ClearBuffer();
ClearBuffer(true);
const TempFBO info = {fbo, gpuStats.numFlips};
tempFBOs_[key] = info;
return fbo;