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_;