From ed7de3ea76c4d4276ed1502da63403228cef1f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 9 Oct 2026 16:22:05 +0200 Subject: [PATCH] Readback: Only scale a framebuffer down when it's rendered above maxScaleFactor ReadFramebufferForDebug scaled the buffer down, cropped to its drawn size, whenever the render width was more than the drawn width times maxScaleFactor. At 1x that's any buffer wider than what has been drawn in it, though nothing needs scaling. Headless compares at maxScaleFactor 1, so this cut off most of the screen in Gangs of London, which draws a 256 px wide region: its dumps went from 78 to 62,017 pixels differing from the PSP. Now it only scales down when the render scale is above maxScaleFactor, and then scales the whole buffer, since a display at an offset can sit past the drawn width. Co-Authored-By: Claude Opus 5.5 --- GPU/Common/FramebufferManagerCommon.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 9342f8f81c..d24dc00018 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -3169,20 +3169,19 @@ bool FramebufferManagerCommon::ReadFramebufferForDebug(VirtualFramebuffer *vfb, Draw::Framebuffer *bound = nullptr; if (vfb->fbo) { - if (maxScaleFactor > 0 && vfb->renderWidth > vfb->width * maxScaleFactor) { - w = vfb->width * maxScaleFactor; - h = vfb->height * maxScaleFactor; + // Scale down the whole buffer: the crop below may be anywhere in it, past the drawn width (a display at an offset). + if (maxScaleFactor > 0 && vfb->renderScaleFactor > maxScaleFactor) { + w = vfb->bufferWidth * maxScaleFactor; + h = vfb->bufferHeight * maxScaleFactor; scale = maxScaleFactor; Draw::Framebuffer *tempFBO = GetTempFBO(TempFBO::COPY, w, h); VirtualFramebuffer tempVfb = *vfb; tempVfb.fbo = tempFBO; - tempVfb.bufferWidth = vfb->width; - tempVfb.bufferHeight = vfb->height; tempVfb.renderWidth = w; tempVfb.renderHeight = h; tempVfb.renderScaleFactor = maxScaleFactor; - BlitFramebuffer(&tempVfb, 0, 0, vfb, 0, 0, vfb->width, vfb->height, 0, RASTER_COLOR, "Blit_GetFramebuffer"); + BlitFramebuffer(&tempVfb, 0, 0, vfb, 0, 0, vfb->bufferWidth, vfb->bufferHeight, 0, RASTER_COLOR, "Blit_GetFramebuffer"); bound = tempFBO; } else {