From d3b265a3e49ba674af55c2c372da65c61b7b83fa Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 27 Sep 2015 19:59:47 +0200 Subject: [PATCH] Fix render resolution race condition. Should help #8002 --- GPU/Common/FramebufferCommon.cpp | 17 ++++++++--------- GPU/Common/FramebufferCommon.h | 2 ++ GPU/Directx9/FramebufferDX9.cpp | 3 ++- GPU/GLES/Framebuffer.cpp | 6 +++++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 3eaa795cf9b7..60704f07ace5 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -90,17 +90,13 @@ FramebufferManagerCommon::FramebufferManagerCommon() : currentRenderVfb_(0), framebufRangeEnd_(0), hackForce04154000Download_(false) { - renderWidth_ = (float)PSP_CoreParameter().renderWidth; - renderHeight_ = (float)PSP_CoreParameter().renderHeight; - pixelWidth_ = PSP_CoreParameter().pixelWidth; - pixelHeight_ = PSP_CoreParameter().pixelHeight; + UpdateSize(); } FramebufferManagerCommon::~FramebufferManagerCommon() { } void FramebufferManagerCommon::Init() { - const std::string gameId = g_paramSFO.GetValueString("DISC_ID"); // This applies a hack to Dangan Ronpa, its demo, and its sequel. // The game draws solid colors to a small framebuffer, and then reads this directly in VRAM. @@ -114,15 +110,18 @@ void FramebufferManagerCommon::Init() { BeginFrame(); } +void FramebufferManagerCommon::UpdateSize() { + renderWidth_ = (float)PSP_CoreParameter().renderWidth; + renderHeight_ = (float)PSP_CoreParameter().renderHeight; + pixelWidth_ = PSP_CoreParameter().pixelWidth; + pixelHeight_ = PSP_CoreParameter().pixelHeight; +} + void FramebufferManagerCommon::BeginFrame() { DecimateFBOs(); currentRenderVfb_ = 0; useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; updateVRAM_ = !(g_Config.iRenderingMode == FB_NON_BUFFERED_MODE || g_Config.iRenderingMode == FB_BUFFERED_MODE); - renderWidth_ = (float)PSP_CoreParameter().renderWidth; - renderHeight_ = (float)PSP_CoreParameter().renderHeight; - pixelWidth_ = PSP_CoreParameter().pixelWidth; - pixelHeight_ = PSP_CoreParameter().pixelHeight; } void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) { diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 3602df828577..51f386f29281 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -211,6 +211,8 @@ class FramebufferManagerCommon { void SetRenderSize(VirtualFramebuffer *vfb); protected: + void UpdateSize(); + virtual void DisableState() = 0; virtual void ClearBuffer() = 0; virtual void ClearDepthBuffer() = 0; diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index 0c1797870a50..cc5ac2b558ed 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -1109,7 +1109,7 @@ namespace DX9 { void FramebufferManagerDX9::EndFrame() { if (resized_) { DestroyAllFBOs(); - dxstate.viewport.set(0, 0, pixelWidth_, pixelHeight_); + dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); // Actually, auto mode should be more granular... // Round up to a zoom factor for the render size. int zoom = g_Config.iInternalResolution; @@ -1132,6 +1132,7 @@ namespace DX9 { PSP_CoreParameter().renderHeight = 272 * zoom; } + UpdateSize(); ShowScreenResolution(); resized_ = false; } diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index f60ef5674524..d29a59542be0 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1659,8 +1659,10 @@ void ShowScreenResolution(); void FramebufferManager::EndFrame() { if (resized_) { + // TODO: Only do this if the new size actually changed the renderwidth/height. DestroyAllFBOs(); - glstate.viewport.set(0, 0, pixelWidth_, pixelHeight_); + // Probably not necessary + glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); // Actually, auto mode should be more granular... // Round up to a zoom factor for the render size. @@ -1684,6 +1686,8 @@ void FramebufferManager::EndFrame() { PSP_CoreParameter().renderHeight = 272 * zoom; } + UpdateSize(); + resized_ = false; #ifdef _WIN32 ShowScreenResolution();