From 102d62deabeca80b62f6411be6972e4d4dc91215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 2 Dec 2024 09:57:46 +0100 Subject: [PATCH] More GE debugging prep --- Core/System.cpp | 2 +- GPU/GPUCommon.cpp | 26 ++++++++++++++++---------- GPU/GPUCommon.h | 3 +-- GPU/GPUInterface.h | 23 ++++++++++++++++++++++- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Core/System.cpp b/Core/System.cpp index 3e0a0dba40..de8930e41f 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -642,7 +642,7 @@ void PSP_RunLoopUntil(u64 globalticks) { _dbg_assert_(false); break; case CORE_RUNNING_GE: - gpu->ProcessDLQueue(); + gpu->ProcessDLQueue(DLRunType::Run, DLStepType::None); coreState = CORE_RUNNING_CPU; break; } diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 3bc7a42c4d..d3e2703279 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -551,9 +551,10 @@ u32 GPUCommon::Continue() { void GPUCommon::SwitchToGe() { // Old method, although may make sense for performance if the ImDebugger isn't active. #if 1 - ProcessDLQueue(); + // Call ProcessDLQueue directly. + ProcessDLQueue(DLRunType::Run, DLStepType::None); #else - // New method, will allow ImDebugger to step the GPU + // New method, will allow ImDebugger to step the GPU. Core_SwitchToGe(); #endif } @@ -841,7 +842,10 @@ int GPUCommon::GetNextListIndex() { // This is now called when coreState == CORE_RUNNING_GE. // TODO: It should return the next action.. (break into debugger or continue running) -void GPUCommon::ProcessDLQueue() { +DLResult GPUCommon::ProcessDLQueue(DLRunType run, DLStepType step) { + _dbg_assert_(run == DLRunType::Run); + _dbg_assert_(step == DLStepType::None); + startingTicks = CoreTiming::GetTicks(); cyclesExecuted = 0; @@ -855,13 +859,14 @@ void GPUCommon::ProcessDLQueue() { DisplayList &l = dls[listIndex]; DEBUG_LOG(Log::G3D, "Starting DL execution at %08x - stall = %08x", l.pc, l.stall); if (!InterpretList(l)) { - return; - } else { - // Some other list could've taken the spot while we dilly-dallied around. - if (l.state != PSP_GE_DL_STATE_QUEUED) { - // At the end, we can remove it from the queue and continue. - dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end()); - } + return DLResult::Error; + } + + // Some other list could've taken the spot while we dilly-dallied around. + // LATER: Hm, really? Not unless we start time-slicing... + if (l.state != PSP_GE_DL_STATE_QUEUED) { + // At the end, we can remove it from the queue and continue. + dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end()); } } @@ -876,6 +881,7 @@ void GPUCommon::ProcessDLQueue() { __GeTriggerSync(GPU_SYNC_DRAW, 1, drawCompleteTicks); // Since the event is in CoreTiming, we're in sync. Just set 0 now. + return DLResult::Done; } void GPUCommon::Execute_OffsetAddr(u32 op, u32 diff) { diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 62354af6fb..b5abf0028c 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -78,7 +78,6 @@ inline bool IsTrianglePrim(GEPrimitiveType prim) { return prim > GE_PRIM_LINE_STRIP && prim != GE_PRIM_RECTANGLES; } - class GPUCommon : public GPUInterface, public GPUDebugInterface { public: GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw); @@ -114,7 +113,7 @@ public: virtual void PreExecuteOp(u32 op, u32 diff) {} bool InterpretList(DisplayList &list); - void ProcessDLQueue() override; + DLResult ProcessDLQueue(DLRunType run, DLStepType step) override; u32 UpdateStall(int listid, u32 newstall) override; u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer args, bool head) override; u32 DequeueList(int listid) override; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index beab46ab6c..7daccb1f78 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -172,6 +172,27 @@ namespace Draw { class DrawContext; } +enum class DLRunType { + Run, + RunDebug, + Step, +}; + +enum class DLStepType { + None, + Single, + Prim, + Draw, + Texture, + Rendertarget, +}; + +enum class DLResult { + Done, + Error, + Pause, // used for stepping, breakpoints +}; + class GPUInterface { public: virtual ~GPUInterface() {} @@ -197,7 +218,7 @@ public: virtual u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer args, bool head) = 0; virtual u32 DequeueList(int listid) = 0; virtual u32 UpdateStall(int listid, u32 newstall) = 0; - virtual void ProcessDLQueue() = 0; + virtual DLResult ProcessDLQueue(DLRunType run, DLStepType step) = 0; virtual u32 DrawSync(int mode) = 0; virtual int ListSync(int listid, int mode) = 0;