From 53ebba4a3eabbc95ae20c2cb8a5ed7c9e7a6e6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 29 May 2024 14:47:50 +0200 Subject: [PATCH] Vulkan: Fix bug when stepping / pausing-on-lost-focus --- UI/EmuScreen.cpp | 14 ++++++++------ UI/GameSettingsScreen.cpp | 3 +++ Windows/MainWindow.cpp | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index a06b1c60ef..6ccacf6b8f 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1348,7 +1348,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { // We only bind it in FramebufferManager::CopyDisplayToOutput (unless non-buffered)... // We do, however, start the frame in other ways. - if ((skipBufferEffects && !g_Config.bSoftwareRendering) || Core_IsStepping()) { + if (skipBufferEffects && !g_Config.bSoftwareRendering) { // We need to clear here already so that drawing during the frame is done on a clean slate. if (Core_IsStepping() && gpuStats.numFlips != 0) { draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::KEEP, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_BackBuffer"); @@ -1450,13 +1450,11 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { } else { // If we're stepping, it's convenient not to clear the screen entirely, so we copy display to output. // This won't work in non-buffered, but that's fine. - draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_Stepping"); - framebufferBound = true; - // Just to make sure. - if (PSP_IsInited()) { - _dbg_assert_(gpu); + if (!framebufferBound && PSP_IsInited()) { + // draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_Stepping"); gpu->CopyDisplayToOutput(true); } + framebufferBound = true; } break; } @@ -1468,6 +1466,10 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { break; } + if (framebufferBound && gpu) { + gpu->PresentedThisFrame(); + } + PSP_EndHostFrame(); // This place rougly matches how libretro handles it (after retro_frame). diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3b118093d6..b672af8e2b 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1224,7 +1224,10 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) { systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")))->SetEnabled(!PSP_IsInited()); systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, sy->T("VersionCheck", "Check for new versions of PPSSPP"))); systemSettings->Add(new CheckBox(&g_Config.bScreenshotsAsPNG, sy->T("Screenshots as PNG"))); + // TODO: Make this setting available on Mac too. +#if PPSSPP_PLATFORM(WINDOWS) systemSettings->Add(new CheckBox(&g_Config.bPauseOnLostFocus, sy->T("Pause when not focused"))); +#endif systemSettings->Add(new ItemHeader(sy->T("Cheats", "Cheats"))); CheckBox *enableCheats = systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, sy->T("Enable Cheats"))); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 67601d69ee..0a1016e0ae 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -844,7 +844,7 @@ namespace MainWindow g_activeWindow = WINDOW_OTHER; } if (!noFocusPause && g_Config.bPauseOnLostFocus && GetUIState() == UISTATE_INGAME) { - if (pause != Core_IsStepping()) { // != is xor for bools + if (pause != Core_IsStepping()) { if (disasmWindow) SendMessage(disasmWindow->GetDlgHandle(), WM_COMMAND, IDC_STOPGO, 0); else