From c842e3f137f0fe5df6c97f838ed9d30a48502277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 9 Dec 2024 12:00:15 +0100 Subject: [PATCH] Fix discrepancy between stepping and running across frame endings. Add some more menu options in the ImDebugger --- Core/Config.h | 4 +++- Core/Core.cpp | 7 +++++-- GPU/GPUCommon.cpp | 22 +++++++++++----------- GPU/GPUCommon.h | 4 ++-- UI/ImDebugger/ImDebugger.cpp | 5 +++++ 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Core/Config.h b/Core/Config.h index 8eff66237e..bf8f5b8634 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -70,11 +70,13 @@ public: bool bFirstRun; bool bGameSpecific = false; bool bUpdatedInstanceCounter = false; + bool bBrowse; // show a file browser on startup. TODO: Does anyone use this? int iRunCount; // To be used to for example check for updates every 10 runs and things like that. + // Debugger bool bAutoRun; // start immediately - bool bBrowse; // when opening the emulator, immediately show a file browser + bool bBreakOnFrameTimeout; // not saved // General bool bScreenshotsAsPNG; diff --git a/Core/Core.cpp b/Core/Core.cpp index cb6d9ca1e0..b92f94e3ce 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -430,12 +430,15 @@ void Core_Resume() { // Should be called from the EmuThread. bool Core_NextFrame() { + CoreState coreState = ::coreState; + _dbg_assert_(coreState != CORE_STEPPING_GE && coreState != CORE_RUNNING_GE); - if (coreState == CORE_RUNNING_CPU) { - coreState = CORE_NEXTFRAME; + if (coreState == CORE_RUNNING_CPU || coreState == CORE_STEPPING_CPU) { + ::coreState = CORE_NEXTFRAME; return true; } else { + ERROR_LOG(Log::System, "Core_NextFrame called with core state %s", CoreStateToString(coreState)); return false; } } diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index fa9a91f564..95c1c76830 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -97,7 +97,7 @@ void GPUCommon::Reinitialize() { memset(dls, 0, sizeof(dls)); for (int i = 0; i < DisplayListMaxCount; ++i) { dls[i].state = PSP_GE_DL_STATE_NONE; - dls[i].waitTicks = 0; + dls[i].waitUntilTicks = 0; } nextListID = 0; @@ -273,7 +273,7 @@ int GPUCommon::ListSync(int listid, int mode) { return SCE_KERNEL_ERROR_ILLEGAL_CONTEXT; } - if (dl.waitTicks > CoreTiming::GetTicks()) { + if (dl.waitUntilTicks > CoreTiming::GetTicks()) { __GeWaitCurrentThread(GPU_SYNC_LIST, listid, "GeListSync"); } return PSP_GE_LIST_COMPLETED; @@ -409,7 +409,7 @@ u32 GPUCommon::EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointerpendingInterrupt = true; } else { currentList->state = PSP_GE_DL_STATE_COMPLETED; - currentList->waitTicks = startingTicks + cyclesExecuted; - busyTicks = std::max(busyTicks, currentList->waitTicks); - __GeTriggerSync(GPU_SYNC_LIST, currentList->id, currentList->waitTicks); + currentList->waitUntilTicks = startingTicks + cyclesExecuted; + busyTicks = std::max(busyTicks, currentList->waitUntilTicks); + __GeTriggerSync(GPU_SYNC_LIST, currentList->id, currentList->waitUntilTicks); } break; } @@ -1419,7 +1419,7 @@ struct DisplayList_v1 { DisplayListStackEntry stack[32]; int stackptr; bool interrupted; - u64 waitTicks; + u64 waitUntilTicks; bool interruptsEnabled; bool pendingInterrupt; bool started; @@ -1440,7 +1440,7 @@ struct DisplayList_v2 { DisplayListStackEntry stack[32]; int stackptr; bool interrupted; - u64 waitTicks; + u64 waitUntilTicks; bool interruptsEnabled; bool pendingInterrupt; bool started; @@ -1547,7 +1547,7 @@ void GPUCommon::InterruptEnd(int listid) { gstate.Restore(dl.context); ReapplyGfxState(); } - dl.waitTicks = 0; + dl.waitUntilTicks = 0; __GeTriggerWait(GPU_SYNC_LIST, listid); // Make sure the list isn't still queued since it's now completed. diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index b14742bb0c..305a04d7da 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -125,7 +125,7 @@ struct DisplayList { DisplayListStackEntry stack[32]; int stackptr; bool interrupted; - u64 waitTicks; + u64 waitUntilTicks; bool interruptsEnabled; bool pendingInterrupt; bool started; @@ -371,7 +371,7 @@ public: s64 GetListTicks(int listid) const { if (listid >= 0 && listid < DisplayListMaxCount) { - return dls[listid].waitTicks; + return dls[listid].waitUntilTicks; } return -1; } diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index b81e45c00b..e115c6643e 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -860,7 +860,11 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu } ImGui::Separator(); ImGui::MenuItem("Ignore bad memory accesses", nullptr, &g_Config.bIgnoreBadMemAccess); + ImGui::MenuItem("Break on frame timeout", nullptr, &g_Config.bBreakOnFrameTimeout); + ImGui::MenuItem("Don't break on start", nullptr, &g_Config.bAutoRun); // should really invert this bool! + ImGui::MenuItem("Fast memory", nullptr, &g_Config.bFastMemory); ImGui::Separator(); + /* // Symbol stuff. Move to separate menu? // Doesn't quite seem to work yet. @@ -891,6 +895,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu if (ImGui::MenuItem("Take screenshot")) { g_TakeScreenshot = true; } + ImGui::MenuItem("Save screenshot as .png", nullptr, &g_Config.bScreenshotsAsPNG); if (ImGui::MenuItem("Restart graphics")) { System_PostUIMessage(UIMessage::RESTART_GRAPHICS); }