diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index adf158f01f..5ec2774bff 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -213,9 +213,6 @@ public: virtual void ResetListStall(int listID, u32 stall) = 0; virtual void ResetListState(int listID, DisplayListState state) = 0; - GPUDebugOp DisassembleOp(u32 pc) { - return DisassembleOp(pc, Memory::Read_U32(pc)); - } virtual GPUDebugOp DisassembleOp(u32 pc, u32 op) = 0; virtual std::vector DisassembleOpRange(u32 startpc, u32 endpc) = 0; @@ -245,10 +242,10 @@ public: virtual const std::list &GetDisplayListQueue() = 0; virtual const DisplayList &GetDisplayList(int index) = 0; - virtual int PrimsThisFrame() = 0; - virtual int PrimsLastFrame() = 0; + virtual int PrimsThisFrame() const = 0; + virtual int PrimsLastFrame() const = 0; - virtual void ClearBreakNext() = 0 ; + virtual void ClearBreakNext() = 0; virtual void SetBreakNext(GPUDebug::BreakNext next) = 0 ; virtual void SetBreakCount(int c, bool relative = false) = 0 ; virtual GPUDebug::BreakNext GetBreakNext() = 0 ; diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index 0860c1a292..0ec2072d99 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -45,10 +45,6 @@ static bool isStepping; // Number of times we've entered stepping, to detect a resume asynchronously. static int stepCounter = 0; -// Debug stats. -static double g_timeSteppingStarted; -static double g_timeSpentStepping; - static std::mutex pauseLock; static PauseAction pauseAction = PAUSE_CONTINUE; static std::mutex actionLock; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 1ecd09757b..4db72805b3 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -620,7 +620,12 @@ void GPUCommon::PSPFrame() { } else if (dumpThisFrame_) { dumpThisFrame_ = false; } - NotifyBeginFrame(); + + if (breakNext == GPUDebug::BreakNext::VSYNC) { + // Just start stepping as soon as we can once the vblank finishes. + breakNext = GPUDebug::BreakNext::OP; + } + recorder_.NotifyBeginFrame(); } // Returns false on breakpoint. @@ -2019,20 +2024,28 @@ GPUDebug::BreakNext GPUCommon::GetBreakNext() { void GPUCommon::SetBreakNext(GPUDebug::BreakNext next) { breakNext = next; breakAtCount = -1; - if (next == GPUDebug::BreakNext::TEX) { + switch (next) { + case GPUDebug::BreakNext::TEX: breakpoints_.AddTextureChangeTempBreakpoint(); - } else if (next == GPUDebug::BreakNext::PRIM || next == GPUDebug::BreakNext::COUNT) { + break; + case GPUDebug::BreakNext::PRIM: + case GPUDebug::BreakNext::COUNT: breakpoints_.AddCmdBreakpoint(GE_CMD_PRIM, true); breakpoints_.AddCmdBreakpoint(GE_CMD_BEZIER, true); breakpoints_.AddCmdBreakpoint(GE_CMD_SPLINE, true); breakpoints_.AddCmdBreakpoint(GE_CMD_VAP, true); - } else if (next == GPUDebug::BreakNext::CURVE) { + break; + case GPUDebug::BreakNext::CURVE: breakpoints_.AddCmdBreakpoint(GE_CMD_BEZIER, true); breakpoints_.AddCmdBreakpoint(GE_CMD_SPLINE, true); - } else if (next == GPUDebug::BreakNext::DRAW) { + break; + case GPUDebug::BreakNext::DRAW: // This is now handled by switching to BreakNext::PRIM when we encounter a flush. // This will take us to the following actual draw. primAfterDraw_ = true; + break; + default: + break; } if (GPUStepping::IsStepping()) { @@ -2093,12 +2106,13 @@ GPUDebug::NotifyResult GPUCommon::NotifyCommand(u32 pc, GPUBreakpoints *breakpoi if (isBreakpoint) { breakpoints->ClearTempBreakpoints(); - if (coreState == CORE_POWERDOWN || !gpuDebug) { + if (coreState == CORE_POWERDOWN) { breakNext = BreakNext::NONE; return process ? NotifyResult::Execute : NotifyResult::Skip; } - auto info = gpuDebug->DisassembleOp(pc); + u32 op = Memory::Read_U32(pc); + auto info = DisassembleOp(pc, op); NOTICE_LOG(Log::GeDebugger, "Waiting at %08x, %s", pc, info.desc.c_str()); g_skipPcOnce = pc; @@ -2131,23 +2145,6 @@ void GPUCommon::NotifyDisplay(u32 framebuf, u32 stride, int format) { recorder_.NotifyDisplay(framebuf, stride, format); } -void GPUCommon::NotifyBeginFrame() { - using namespace GPUDebug; - if (breakNext == BreakNext::VSYNC) { - // Just start stepping as soon as we can once the vblank finishes. - breakNext = BreakNext::OP; - } - recorder_.NotifyBeginFrame(); -} - -int GPUCommon::PrimsThisFrame() { - return primsThisFrame; -} - -int GPUCommon::PrimsLastFrame() { - return primsLastFrame; -} - bool GPUCommon::SetRestrictPrims(std::string_view rule) { if (rule.empty() || rule == "*") { restrictPrimRanges.clear(); diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index bbac458561..ddaf64c406 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -392,15 +392,18 @@ public: bool SetRestrictPrims(std::string_view rule) override; const char *GetRestrictPrims() override; - int PrimsThisFrame() override; - int PrimsLastFrame() override; + int PrimsThisFrame() const override { + return primsThisFrame; + } + int PrimsLastFrame() const override { + return primsLastFrame; + } void NotifyFlush(); protected: // While debugging is active, these may block. void NotifyDisplay(u32 framebuf, u32 stride, int format); - void NotifyBeginFrame(); bool NeedsSlowInterpreter() const; GPUDebug::NotifyResult NotifyCommand(u32 pc, GPUBreakpoints *breakpoints); diff --git a/UI/ImDebugger/ImGe.cpp b/UI/ImDebugger/ImGe.cpp index bd3bca15f5..ae8193a727 100644 --- a/UI/ImDebugger/ImGe.cpp +++ b/UI/ImDebugger/ImGe.cpp @@ -150,7 +150,8 @@ void ImGeDisasmView::Draw(GPUDebugInterface *gpuDebug) { if (Memory::IsValid4AlignedAddress(addr)) { draw_list->AddText(lineStart, 0xFFC0C0C0, addrBuffer); - GPUDebugOp op = gpuDebug->DisassembleOp(addr); + u32 opcode = Memory::Read_U32(addr); + GPUDebugOp op = gpuDebug->DisassembleOp(addr, opcode); u32 color = 0xFFFFFFFF; char temp[16]; snprintf(temp, sizeof(temp), "%08x", op.op); @@ -212,7 +213,8 @@ void ImGeDisasmView::Draw(GPUDebugInterface *gpuDebug) { } } else if (Memory::IsValid4AlignedAddress(dragAddr_)) { char buffer[64]; - GPUDebugOp op = gpuDebug->DisassembleOp(pc); + u32 opcode = Memory::Read_U32(dragAddr_); + GPUDebugOp op = gpuDebug->DisassembleOp(dragAddr_, opcode); // affect dragAddr_? if (ImGui::MenuItem("Copy Address", NULL, false)) { snprintf(buffer, sizeof(buffer), "%08x", dragAddr_); diff --git a/Windows/GEDebugger/CtrlDisplayListView.cpp b/Windows/GEDebugger/CtrlDisplayListView.cpp index 3c7e7c4129..6c0f41961f 100644 --- a/Windows/GEDebugger/CtrlDisplayListView.cpp +++ b/Windows/GEDebugger/CtrlDisplayListView.cpp @@ -341,7 +341,8 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) char *p = temp, *end = temp + space; for (u32 pos = selectRangeStart; pos < selectRangeEnd && p < end; pos += instructionSize) { - GPUDebugOp op = gpuDebug->DisassembleOp(pos); + u32 opcode = Memory::Read_U32(pos); + GPUDebugOp op = gpuDebug->DisassembleOp(pos, opcode); p += snprintf(p, end - p, "%s\r\n", op.desc.c_str()); }