From 357a90db714b32ab1de4e6ff69c30a482670fbd3 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Wed, 13 Sep 2023 13:48:19 +0100 Subject: [PATCH] GS/PCRTC: Avoid trying to lookup bad framebuffers --- pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 3 +++ pcsx2/GS/Renderers/SW/GSRendererSW.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 0db1cc0d9d..0194ed4ae0 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -162,6 +162,9 @@ GSTexture* GSRendererHW::GetOutput(int i, float& scale, int& y_offset) GSPCRTCRegs::PCRTCDisplay& curFramebuffer = PCRTCDisplays.PCRTCDisplays[index]; const GSVector2i framebufferSize(PCRTCDisplays.GetFramebufferSize(i)); + if (curFramebuffer.framebufferRect.rempty() || curFramebuffer.FBW == 0) + return nullptr; + PCRTCDisplays.RemoveFramebufferOffset(i); // TRACE(_T("[%d] GetOutput %d %05x (%d)\n"), (int)m_perfmon.GetFrame(), i, (int)TEX0.TBP0, (int)TEX0.PSM); diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index 3c4e1579ce..104e84dbae 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -115,8 +115,13 @@ GSTexture* GSRendererSW::GetOutput(int i, float& scale, int& y_offset) GSPCRTCRegs::PCRTCDisplay& curFramebuffer = PCRTCDisplays.PCRTCDisplays[index]; GSVector2i framebufferSize = PCRTCDisplays.GetFramebufferSize(i); GSVector4i framebufferRect = PCRTCDisplays.GetFramebufferRect(i); - int w = curFramebuffer.FBW * 64; - int h = framebufferSize.y; + + // Try to avoid broken/incomplete setups which are probably ingnored on console, but can cause us problems. + if (framebufferRect.rempty() || curFramebuffer.FBW == 0) + return nullptr; + + const int w = curFramebuffer.FBW * 64; + const int h = framebufferSize.y; if (g_gs_device->ResizeRenderTarget(&m_texture[index], w, h, false, false)) {