From 437b6f3f0e485e94046ff1348cfd4f8c8cdc17a4 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 16 May 2022 22:43:01 +1000 Subject: [PATCH] Host: Reset imgui state when there's no frame to present Prevents things getting into a messed up state internally where several frames are buffered. --- pcsx2-qt/EmuThread.cpp | 10 +++++++++- pcsx2/gui/AppHost.cpp | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pcsx2-qt/EmuThread.cpp b/pcsx2-qt/EmuThread.cpp index 66513f4f2d..34c9623f05 100644 --- a/pcsx2-qt/EmuThread.cpp +++ b/pcsx2-qt/EmuThread.cpp @@ -716,7 +716,15 @@ void Host::ReleaseHostDisplay() bool Host::BeginPresentFrame(bool frame_skip) { - return s_host_display->BeginPresent(frame_skip); + if (!s_host_display->BeginPresent(frame_skip)) + { + // if we're skipping a frame, we need to reset imgui's state, since + // we won't be calling EndPresentFrame(). + ImGuiManager::NewFrame(); + return false; + } + + return true; } void Host::EndPresentFrame() diff --git a/pcsx2/gui/AppHost.cpp b/pcsx2/gui/AppHost.cpp index 003bbdebd5..2628ea626a 100644 --- a/pcsx2/gui/AppHost.cpp +++ b/pcsx2/gui/AppHost.cpp @@ -153,7 +153,16 @@ HostDisplay* Host::GetHostDisplay() bool Host::BeginPresentFrame(bool frame_skip) { CheckForGSWindowResize(); - return s_host_display->BeginPresent(frame_skip); + + if (!s_host_display->BeginPresent(frame_skip)) + { + // if we're skipping a frame, we need to reset imgui's state, since + // we won't be calling EndPresentFrame(). + ImGuiManager::NewFrame(); + return false; + } + + return true; } void Host::EndPresentFrame()