From 4e088aebb7c7b2ce5604bb90086a7a59ee0fa630 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 4 Jan 2016 20:57:54 -0800 Subject: [PATCH] Discard blit buffer contents before blit. This way the GPU doesn't think it needs to load anything, it's all being overwritten. If we're only using part of the framebuffer, the other parts don't matter. --- GPU/GLES/Framebuffer.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 93da39c3ff..93e03802bd 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1274,18 +1274,16 @@ bool FramebufferManager::CreateDownloadTempBuffer(VirtualFramebuffer *nvfb) { } void FramebufferManager::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) { - if (gl_extensions.IsGLES) { - if (nvfb->fbo) { - fbo_bind_as_render_target(nvfb->fbo); - } + _assert_msg_(G3D, nvfb->fbo, "Expecting a valid nvfb in UpdateDownloadTempBuffer"); - // Some tiled mobile GPUs benefit IMMENSELY from clearing an FBO before rendering - // to it. This broke stuff before, so now it only clears on the first use of an - // FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs - // performance-crushing framebuffer reloads from RAM, but we'll have to live with that. - if (nvfb->last_frame_render != gpuStats.numFlips) { - ClearBuffer(); - } + // Discard the previous contents of this buffer where possible. + if (gl_extensions.GLES3 && glInvalidateFramebuffer != nullptr) { + fbo_bind_as_render_target(nvfb->fbo); + GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_STENCIL_ATTACHMENT, GL_DEPTH_ATTACHMENT }; + glInvalidateFramebuffer(GL_FRAMEBUFFER, 3, attachments); + } else if (gl_extensions.IsGLES) { + fbo_bind_as_render_target(nvfb->fbo); + ClearBuffer(); } }