From 3d31b4ac4ca7f2f58dbbc1de745b9018f4e5599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 2 Oct 2024 00:58:50 +0200 Subject: [PATCH] Fix possible framebuffer binding bug in EmuScreen --- GPU/Common/PresentationCommon.h | 1 + GPU/Common/ReplacedTexture.cpp | 7 +++++++ UI/EmuScreen.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/GPU/Common/PresentationCommon.h b/GPU/Common/PresentationCommon.h index 7e4877f11d..2da590dfc5 100644 --- a/GPU/Common/PresentationCommon.h +++ b/GPU/Common/PresentationCommon.h @@ -106,6 +106,7 @@ public: } void NotifyPresent() { // Something else did the present, skipping PresentationCommon. + // If you haven't called BindFramebufferAsRenderTarget, you must not set this. presentedThisFrame_ = true; } diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index fb01001474..f785c6105a 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -199,6 +199,8 @@ inline uint32_t RoundUpTo4(uint32_t value) { } void ReplacedTexture::Prepare(VFSBackend *vfs) { + _assert_(vfs != nullptr); + this->vfs_ = vfs; std::unique_lock lock(lock_); @@ -295,6 +297,11 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference data_.resize(mipLevel + 1); } + if (!vfs_) { + ERROR_LOG(Log::G3D, "Unexpected null vfs_ pointer in LoadLevelData"); + return LoadLevelResult::LOAD_ERROR; + } + ReplacedTextureLevel level; size_t fileSize; VFSOpenFile *openFile = vfs_->OpenFileForRead(fileRef, &fileSize); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 361c026dde..cafc6b7293 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1464,8 +1464,8 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { if (!framebufferBound && PSP_IsInited()) { // draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_Stepping"); gpu->CopyDisplayToOutput(true); + framebufferBound = true; } - framebufferBound = true; } break; }