From adda49d05d1091decb8832259f0ca4e9e085f143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 15 Feb 2023 15:28:33 +0100 Subject: [PATCH] Add a heuristic avoiding joining framebuffers horizontally ...when texturing from the other one. Greatly improves GPU performance in Rainbow Six: Vegas. Fixes #9324. --- GPU/Common/FramebufferManagerCommon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 31981d722f..a126bb7fb2 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -426,6 +426,14 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(Framebuffer u32 v_fb_end_ptr = v->fb_address + v->fb_stride * v->height * bpp; if (params.fb_address > v->fb_address && params.fb_address < v_fb_first_line_end_ptr) { + // If the framebuffer we can join to is currently bound as a texture, we likely have + // a situation like in #9324 and don't want to do this. + u32 curTextureAddress = gstate.getTextureAddress(0); + if (v->fb_address == curTextureAddress) { + // Don't try these joining shenanigans. + continue; + } + const int x_offset = (params.fb_address - v->fb_address) / bpp; if (x_offset < params.fb_stride && v->height >= drawing_height) { // Pretty certainly a pure render-to-X-offset.