From e029168be2fc0a92975f99a8e6381446e11adebc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Dec 2018 06:40:27 -0800 Subject: [PATCH] GE Debugger: Allow jumping to a specific prim. This will make the most sense when frames are relatively stable, and works great for GE dumps. --- GPU/Debugger/Debugger.cpp | 21 +++++++++++++++++++-- GPU/Debugger/Debugger.h | 2 ++ Windows/GEDebugger/GEDebugger.cpp | 14 ++++++++++++++ Windows/ppsspp.rc | 3 ++- Windows/resource.h | 3 ++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/GPU/Debugger/Debugger.cpp b/GPU/Debugger/Debugger.cpp index 27083674b0..9591cec8c1 100644 --- a/GPU/Debugger/Debugger.cpp +++ b/GPU/Debugger/Debugger.cpp @@ -25,6 +25,7 @@ namespace GPUDebug { static bool active = false; static bool inited = false; static BreakNext breakNext = BreakNext::NONE; +static int breakAtCount = -1; static int primsLastFrame = 0; static int primsThisFrame = 0; @@ -44,6 +45,7 @@ void SetActive(bool flag) { active = flag; if (!active) { breakNext = BreakNext::NONE; + breakAtCount = -1; GPUStepping::ResumeFromStepping(); } } @@ -55,9 +57,10 @@ bool IsActive() { void SetBreakNext(BreakNext next) { SetActive(true); breakNext = next; + breakAtCount = -1; if (next == BreakNext::TEX) { GPUBreakpoints::AddTextureChangeTempBreakpoint(); - } else if (next == BreakNext::PRIM) { + } else if (next == BreakNext::PRIM || next == BreakNext::COUNT) { GPUBreakpoints::AddCmdBreakpoint(GE_CMD_PRIM, true); GPUBreakpoints::AddCmdBreakpoint(GE_CMD_BEZIER, true); GPUBreakpoints::AddCmdBreakpoint(GE_CMD_SPLINE, true); @@ -68,6 +71,20 @@ void SetBreakNext(BreakNext next) { GPUStepping::ResumeFromStepping(); } +void SetBreakCount(int c) { + breakAtCount = c; +} + +static bool IsBreakpoint(u32 pc, u32 op) { + if (breakNext == BreakNext::OP) { + return true; + } else if (breakNext == BreakNext::COUNT) { + return primsThisFrame == breakAtCount; + } else { + return GPUBreakpoints::IsBreakpoint(pc, op); + } +} + void NotifyCommand(u32 pc) { if (!active) return; @@ -82,7 +99,7 @@ void NotifyCommand(u32 pc) { primsThisFrame++; } - if (breakNext == BreakNext::OP || GPUBreakpoints::IsBreakpoint(pc, op)) { + if (IsBreakpoint(pc, op)) { GPUBreakpoints::ClearTempBreakpoints(); auto info = gpuDebug->DissassembleOp(pc); diff --git a/GPU/Debugger/Debugger.h b/GPU/Debugger/Debugger.h index 193b4630ec..b459f5a859 100644 --- a/GPU/Debugger/Debugger.h +++ b/GPU/Debugger/Debugger.h @@ -30,12 +30,14 @@ enum class BreakNext { FRAME, PRIM, CURVE, + COUNT, }; void SetActive(bool flag); bool IsActive(); void SetBreakNext(BreakNext next); +void SetBreakCount(int c); // While debugging is active, these may block. void NotifyCommand(u32 pc); diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 5d4f978357..8ff0223ecd 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -20,6 +20,7 @@ #include #include +#include "base/stringutil.h" #include "Common/ColorConv.h" #include "Core/Config.h" #include "Core/Screenshot.h" @@ -724,6 +725,19 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { SetBreakNext(BreakNext::CURVE); break; + case IDC_GEDBG_STEPCOUNT: + { + std::string value; + int count; + if (InputBox_GetString(GetModuleHandle(NULL), m_hDlg, L"Prim count", "", value)) { + if (TryParse(value, &count)) { + SetBreakNext(BreakNext::COUNT); + SetBreakCount(count); + } + } + } + break; + case IDC_GEDBG_BREAKTEX: { GPUDebug::SetActive(true); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 3aa2993ec6..195f92eb05 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -216,7 +216,8 @@ BEGIN PUSHBUTTON "Step &Prim",IDC_GEDBG_STEPPRIM,145,2,44,14 PUSHBUTTON "Step &Curve",IDC_GEDBG_STEPCURVE,190,2,44,14 PUSHBUTTON "Step &Into",IDC_GEDBG_STEP,235,2,44,14 - EDITTEXT IDC_GEDBG_PRIMCOUNTER,340,4,44,12,ES_READONLY | NOT WS_BORDER + PUSHBUTTON "Step Cou&nt",IDC_GEDBG_STEPCOUNT,280,2,44,14 + EDITTEXT IDC_GEDBG_PRIMCOUNTER,325,4,50,12,ES_READONLY | NOT WS_BORDER PUSHBUTTON "&Resume",IDC_GEDBG_RESUME,396,2,44,14 PUSHBUTTON "Rec&ord",IDC_GEDBG_RECORD,444,2,44,14 CONTROL "",IDC_GEDBG_TEX,"SimpleGLWindow",WS_CHILD | WS_VISIBLE,10,20,128,128 diff --git a/Windows/resource.h b/Windows/resource.h index 1d56567dcd..ee64c5759f 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -363,6 +363,7 @@ #define ID_OPTIONS_TEXTUREFILTERING_MENU 40196 #define ID_OPTIONS_SCREENFILTER_MENU 40197 #define ID_OPTIONS_TEXTURESCALING_MENU 40198 +#define IDC_GEDBG_STEPCOUNT 40199 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 @@ -375,7 +376,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 256 -#define _APS_NEXT_COMMAND_VALUE 40199 +#define _APS_NEXT_COMMAND_VALUE 40200 #define _APS_NEXT_CONTROL_VALUE 1202 #define _APS_NEXT_SYMED_VALUE 101 #endif