Permalink
Browse files

Merge pull request #11616 from unknownbrackets/debugger

GE Debugger: Allow jumping to a specific prim
  • Loading branch information...
hrydgard committed Dec 2, 2018
2 parents d9cfa3a + f88dc9e commit 95ffa15a842730e8ddc467d28d50d7995e258c13
Showing with 90 additions and 12 deletions.
  1. +45 −2 GPU/Debugger/Debugger.cpp
  2. +5 −0 GPU/Debugger/Debugger.h
  3. +1 −0 GPU/Debugger/Stepping.cpp
  4. +25 −0 Windows/GEDebugger/GEDebugger.cpp
  5. +10 −8 Windows/ppsspp.rc
  6. +4 −2 Windows/resource.h
@@ -25,6 +25,11 @@ 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;
static int thisFlipNum = 0;
static void Init() {
if (!inited) {
@@ -40,6 +45,7 @@ void SetActive(bool flag) {
active = flag;
if (!active) {
breakNext = BreakNext::NONE;
breakAtCount = -1;
GPUStepping::ResumeFromStepping();
}
}
@@ -51,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);
@@ -64,11 +71,39 @@ void SetBreakNext(BreakNext next) {
GPUStepping::ResumeFromStepping();
}
void SetBreakCount(int c, bool relative) {
if (relative) {
breakAtCount = primsThisFrame + c;
} else {
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;
u32 op = Memory::ReadUnchecked_U32(pc);
if (breakNext == BreakNext::OP || GPUBreakpoints::IsBreakpoint(pc, op)) {
u32 cmd = op >> 24;
if (thisFlipNum != gpuStats.numFlips) {
primsLastFrame = primsThisFrame;
primsThisFrame = 0;
thisFlipNum = gpuStats.numFlips;
}
if (cmd == GE_CMD_PRIM || cmd == GE_CMD_BEZIER || cmd == GE_CMD_SPLINE) {
primsThisFrame++;
}
if (IsBreakpoint(pc, op)) {
GPUBreakpoints::ClearTempBreakpoints();
auto info = gpuDebug->DissassembleOp(pc);
@@ -100,4 +135,12 @@ void NotifyTextureAttachment(u32 texaddr) {
return;
}
int PrimsThisFrame() {
return primsThisFrame;
}
int PrimsLastFrame() {
return primsLastFrame;
}
}
@@ -30,17 +30,22 @@ enum class BreakNext {
FRAME,
PRIM,
CURVE,
COUNT,
};
void SetActive(bool flag);
bool IsActive();
void SetBreakNext(BreakNext next);
void SetBreakCount(int c, bool relative = false);
// While debugging is active, these may block.
void NotifyCommand(u32 pc);
void NotifyDraw();
void NotifyDisplay(u32 framebuf, u32 stride, int format);
void NotifyTextureAttachment(u32 texaddr);
int PrimsThisFrame();
int PrimsLastFrame();
}
@@ -38,6 +38,7 @@ enum PauseAction {
};
static bool isStepping;
// Number of times we've entered stepping, to detect a resume asynchronously.
static int stepCounter = 0;
static std::mutex pauseLock;
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
#include "base/stringutil.h"
#include "Common/ColorConv.h"
#include "Core/Config.h"
#include "Core/Screenshot.h"
@@ -291,6 +292,10 @@ void CGEDebugger::UpdatePreviews() {
displayList->setDisplayList(list);
}
wchar_t primCounter[1024]{};
swprintf(primCounter, ARRAY_SIZE(primCounter), L"%d/%d", PrimsThisFrame(), PrimsLastFrame());
SetDlgItemText(m_hDlg, IDC_GEDBG_PRIMCOUNTER, primCounter);
flags->Update();
lighting->Update();
textureState->Update();
@@ -720,6 +725,25 @@ 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 (value.length() > 1 && value[0] == '+' && TryParse(value.substr(1), &count)) {
SetBreakNext(BreakNext::COUNT);
SetBreakCount(count, true);
} else if (value.length() > 1 && value[0] == '-' && TryParse(value.substr(1), &count)) {
SetBreakNext(BreakNext::COUNT);
SetBreakCount(-count, true);
} else if (TryParse(value, &count)) {
SetBreakNext(BreakNext::COUNT);
SetBreakCount(count);
}
}
}
break;
case IDC_GEDBG_BREAKTEX:
{
GPUDebug::SetActive(true);
@@ -778,6 +802,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
secondWindow->Clear();
SetDlgItemText(m_hDlg, IDC_GEDBG_FRAMEBUFADDR, L"");
SetDlgItemText(m_hDlg, IDC_GEDBG_TEXADDR, L"");
SetDlgItemText(m_hDlg, IDC_GEDBG_PRIMCOUNTER, L"");
SetBreakNext(BreakNext::NONE);
break;
@@ -210,14 +210,16 @@ EXSTYLE WS_EX_ACCEPTFILES | WS_EX_TOOLWINDOW
CAPTION "GE"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
PUSHBUTTON "Step &Frame",IDC_GEDBG_STEPFRAME,10,2,48,14
PUSHBUTTON "Step &Tex",IDC_GEDBG_STEPTEX,62,2,48,14
PUSHBUTTON "Step &Draw",IDC_GEDBG_STEPDRAW,114,2,48,14
PUSHBUTTON "Step &Prim",IDC_GEDBG_STEPPRIM,166,2,48,14
PUSHBUTTON "Step &Curve",IDC_GEDBG_STEPCURVE,218,2,48,14
PUSHBUTTON "Step &Into",IDC_GEDBG_STEP,270,2,48,14
PUSHBUTTON "&Resume",IDC_GEDBG_RESUME,322,2,48,14
PUSHBUTTON "Rec&ord",IDC_GEDBG_RECORD,440,2,48,14
PUSHBUTTON "Step &Frame",IDC_GEDBG_STEPFRAME,10,2,44,14
PUSHBUTTON "Step &Tex",IDC_GEDBG_STEPTEX,55,2,44,14
PUSHBUTTON "Step &Draw",IDC_GEDBG_STEPDRAW,100,2,44,14
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
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
CONTROL "",IDC_GEDBG_FRAME,"SimpleGLWindow",WS_CHILD | WS_VISIBLE,148,20,256,136
CONTROL "",IDC_GEDBG_MAINTAB,"SysTabControl32",TCS_TABS | TCS_FOCUSNEVER,10,216,480,180
@@ -165,6 +165,7 @@
#define IDC_GEDBG_SHOWCLUT 1198
#define IDC_BREAKPOINT_LOG_FORMAT 1199
#define IDC_SHOWOFFSETS 1200
#define IDC_GEDBG_PRIMCOUNTER 1201
#define ID_SHADERS_BASE 5000
@@ -362,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
@@ -374,8 +376,8 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 256
#define _APS_NEXT_COMMAND_VALUE 40199
#define _APS_NEXT_CONTROL_VALUE 1200
#define _APS_NEXT_COMMAND_VALUE 40200
#define _APS_NEXT_CONTROL_VALUE 1202
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

0 comments on commit 95ffa15

Please sign in to comment.