From c42d04829faaaf7f4320a2784b8b85c8fc896341 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 25 May 2014 18:18:26 -0700 Subject: [PATCH] Detect if the game uses block transfer slivers. In that case, it's better to read it once, than multiple times. Improves performance and graphics in Grand Knights History. --- GPU/GLES/Framebuffer.cpp | 25 ++++++++++++++++++++++++- GPU/GLES/Framebuffer.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index a9f898ddab..502cf3c03f 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -328,6 +328,7 @@ FramebufferManager::FramebufferManager() : usePostShader_(false), postShaderAtOutputResolution_(false), resized_(false), + gameUsesSequentialCopies_(false), framebufRangeEnd_(0) #ifndef USING_GLES2 , @@ -1240,7 +1241,29 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool s #endif } - vfb->memoryUpdated = true; + if (gameUsesSequentialCopies_) { + // Ignore the x/y/etc., read the entire thing. + x = 0; + y = 0; + w = vfb->width; + h = vfb->height; + } + if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) { + vfb->memoryUpdated = true; + } else { + const static int FREQUENT_SEQUENTIAL_COPIES = 3; + static int frameLastCopy = 0; + static u32 bufferLastCopy = 0; + static int copiesThisFrame = 0; + if (frameLastCopy != gpuStats.numFlips || bufferLastCopy != vfb->fb_address) { + frameLastCopy = gpuStats.numFlips; + bufferLastCopy = vfb->fb_address; + copiesThisFrame = 0; + } + if (++copiesThisFrame > FREQUENT_SEQUENTIAL_COPIES) { + gameUsesSequentialCopies_ = true; + } + } BlitFramebuffer_(nvfb, x, y, vfb, x, y, w, h, 0, true); // PackFramebufferSync_() - Synchronous pixel data transfer using glReadPixels diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index fc9ff3a2ab..b457d18b9d 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -272,6 +272,7 @@ private: bool resized_; bool useBufferedRendering_; bool updateVRAM_; + bool gameUsesSequentialCopies_; // The range of PSP memory that may contain FBOs. So we can skip iterating. u32 framebufRangeEnd_;