Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alow flushing at will via the GE debugger #15338

Merged
merged 3 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GPU/Common/GPUDebugInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class GPUDebugInterface {
// Needs to be called from the GPU thread.
// Calling from a separate thread (e.g. UI) may fail.
virtual void SetCmdValue(u32 op) = 0;
virtual void DispatchFlush() = 0;

virtual bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
return false;
Expand Down
14 changes: 14 additions & 0 deletions GPU/Debugger/Stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum PauseAction {
PAUSE_GETTEX,
PAUSE_GETCLUT,
PAUSE_SETCMDVALUE,
PAUSE_FLUSHDRAW,
};

static bool isStepping;
Expand Down Expand Up @@ -119,6 +120,10 @@ static void RunPauseAction() {
gpuDebug->SetCmdValue(pauseSetCmdValue);
break;

case PAUSE_FLUSHDRAW:
gpuDebug->DispatchFlush();
break;

default:
ERROR_LOG(G3D, "Unsupported pause action, forgot to add it to the switch.");
}
Expand Down Expand Up @@ -239,6 +244,15 @@ bool GPU_SetCmdValue(u32 op) {
return true;
}

bool GPU_FlushDrawing() {
if (!isStepping && coreState != CORE_STEPPING) {
return false;
}

SetPauseAction(PAUSE_FLUSHDRAW);
return true;
}

void ResumeFromStepping() {
SetPauseAction(PAUSE_CONTINUE, false);
}
Expand Down
1 change: 1 addition & 0 deletions GPU/Debugger/Stepping.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace GPUStepping {
bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level);
bool GPU_GetCurrentClut(const GPUDebugBuffer *&buffer);
bool GPU_SetCmdValue(u32 op);
bool GPU_FlushDrawing();

void ResumeFromStepping();
void ForceUnpause();
Expand Down
4 changes: 4 additions & 0 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ void GPUCommon::Flush() {
drawEngineCommon_->DispatchFlush();
}

void GPUCommon::DispatchFlush() {
drawEngineCommon_->DispatchFlush();
}

GPUCommon::GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw) :
gfxCtx_(gfxCtx),
draw_(draw)
Expand Down
1 change: 1 addition & 0 deletions GPU/GPUCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class GPUCommon : public GPUInterface, public GPUDebugInterface {

// Note: Not virtual!
void Flush();
void DispatchFlush() override;

#ifdef USE_CRT_DBG
#undef new
Expand Down
1 change: 1 addition & 0 deletions GPU/Software/TransformUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ SoftwareDrawEngine::~SoftwareDrawEngine() {
}

void SoftwareDrawEngine::DispatchFlush() {
transformUnit.Flush("debug");
}

void SoftwareDrawEngine::DispatchSubmitPrim(void *verts, void *inds, GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead) {
Expand Down
35 changes: 29 additions & 6 deletions Windows/GEDebugger/GEDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ void CGEDebugger::Init() {
CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent)
: Dialog((LPCSTR)IDD_GEDEBUGGER, _hInstance, _hParent)
, stepCountDlg(_hInstance, m_hDlg) {
SetMenu(m_hDlg, LoadMenu(_hInstance, MAKEINTRESOURCE(IDR_GEDBG_MENU)));

// minimum size = a little more than the default
RECT windowRect;
GetWindowRect(m_hDlg, &windowRect);
Expand Down Expand Up @@ -185,8 +187,8 @@ CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent)
// set window position
int x = g_Config.iGEWindowX == -1 ? windowRect.left : g_Config.iGEWindowX;
int y = g_Config.iGEWindowY == -1 ? windowRect.top : g_Config.iGEWindowY;
int w = g_Config.iGEWindowW == -1 ? minWidth_ : g_Config.iGEWindowW;
int h = g_Config.iGEWindowH == -1 ? minHeight_ : g_Config.iGEWindowH;
int w = g_Config.iGEWindowW == -1 ? minWidth_ : std::max(minWidth_, g_Config.iGEWindowW);
int h = g_Config.iGEWindowH == -1 ? minHeight_ : std::max(minHeight_, g_Config.iGEWindowH);
MoveWindow(m_hDlg,x,y,w,h,FALSE);

SetTimer(m_hDlg, 1, USER_TIMER_MINIMUM, nullptr);
Expand Down Expand Up @@ -340,6 +342,8 @@ void CGEDebugger::UpdatePreviews() {
}

updating_ = true;
if (autoFlush_)
GPU_FlushDrawing();
UpdateTextureLevel(textureLevel_);
UpdatePrimaryPreview(state);
UpdateSecondPreview(state);
Expand Down Expand Up @@ -704,11 +708,10 @@ void CGEDebugger::UpdateSize(WORD width, WORD height) {
MoveWindow(tabControl,tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,TRUE);
}

void CGEDebugger::SavePosition()
{
void CGEDebugger::SavePosition() {
RECT rc;
if (GetWindowRect(m_hDlg, &rc))
{
// Don't save while we're still loading.
if (tabs && GetWindowRect(m_hDlg, &rc)) {
g_Config.iGEWindowX = rc.left;
g_Config.iGEWindowY = rc.top;
g_Config.iGEWindowW = rc.right - rc.left;
Expand Down Expand Up @@ -783,6 +786,10 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
}
break;

case WM_MENUSELECT:
UpdateMenus();
break;

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_GEDBG_STEPDRAW:
Expand Down Expand Up @@ -880,6 +887,18 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
GPURecord::Activate();
break;

case IDC_GEDBG_FLUSH:
if (GPUDebug::IsActive() && gpuDebug != nullptr) {
if (!autoFlush_)
GPU_FlushDrawing();
UpdatePreviews();
}
break;

case IDC_GEDBG_FLUSHAUTO:
autoFlush_ = !autoFlush_;
break;

case IDC_GEDBG_FORCEOPAQUE:
if (GPUDebug::IsActive() && gpuDebug != nullptr) {
forceOpaque_ = SendMessage(GetDlgItem(m_hDlg, IDC_GEDBG_FORCEOPAQUE), BM_GETCHECK, 0, 0) != 0;
Expand Down Expand Up @@ -936,3 +955,7 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {

return FALSE;
}

void CGEDebugger::UpdateMenus() {
CheckMenuItem(GetMenu(m_hDlg), IDC_GEDBG_FLUSHAUTO, MF_BYCOMMAND | (autoFlush_ ? MF_CHECKED : MF_UNCHECKED));
}
2 changes: 2 additions & 0 deletions Windows/GEDebugger/GEDebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class CGEDebugger : public Dialog {
void PreviewExport(const GPUDebugBuffer *buffer);
void DescribePixel(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
void DescribePixelRGBA(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
void UpdateMenus();

u32 TexturePreviewFlags(const GPUgstate &state);

Expand All @@ -102,6 +103,7 @@ class CGEDebugger : public Dialog {
int textureLevel_ = 0;
bool showClut_ = false;
bool forceOpaque_ = false;
bool autoFlush_ = false;
// The most recent primary/framebuffer and texture buffers.
const GPUDebugBuffer *primaryBuffer_ = nullptr;
const GPUDebugBuffer *secondBuffer_ = nullptr;
Expand Down
52 changes: 39 additions & 13 deletions Windows/ppsspp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,23 @@ CAPTION "GE"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
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
PUSHBUTTON "Step &Tex",IDC_GEDBG_STEPTEX,60,2,44,14
PUSHBUTTON "Step &Draw",IDC_GEDBG_STEPDRAW,105,2,44,14
PUSHBUTTON "Step &Prim",IDC_GEDBG_STEPPRIM,150,2,44,14
PUSHBUTTON "Step &Into",IDC_GEDBG_STEP,200,2,44,14
PUSHBUTTON "Step Cou&nt",IDC_GEDBG_STEPCOUNT,245,2,44,14
EDITTEXT IDC_GEDBG_PRIMCOUNTER,290,4,50,12,ES_READONLY | NOT WS_BORDER
PUSHBUTTON "&Resume",IDC_GEDBG_RESUME,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
EDITTEXT IDC_GEDBG_FRAMEBUFADDR,148,192,200,12,ES_READONLY | NOT WS_BORDER
EDITTEXT IDC_GEDBG_TEXADDR,10,152,128,12,ES_READONLY | NOT WS_BORDER
CONTROL "Force opaque",IDC_GEDBG_FORCEOPAQUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,164,60,12
CONTROL "Show CLUT",IDC_GEDBG_SHOWCLUT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,90,164,50,12
PUSHBUTTON "Break on Te&xture...",IDC_GEDBG_BREAKTEX,24,176,100,14
PUSHBUTTON "Level -",IDC_GEDBG_TEXLEVELDOWN,24,192,40,14
PUSHBUTTON "Level +",IDC_GEDBG_TEXLEVELUP,84,192,40,14
PUSHBUTTON "Level -",IDC_GEDBG_TEXLEVELDOWN,24,184,40,14
PUSHBUTTON "Level +",IDC_GEDBG_TEXLEVELUP,84,184,40,14
CONTROL "",IDC_GEDBG_FBTABS,"SysTabControl32",TCS_BUTTONS | TCS_FOCUSNEVER,384,192,110,12
PUSHBUTTON "Break on Target...",IDC_GEDBG_BREAKTARGET,394,211,100,14
END

IDD_GEDBG_STEPCOUNT DIALOGEX 0, 0, 124, 18
Expand Down Expand Up @@ -662,6 +658,36 @@ BEGIN
END
END

IDR_GEDBG_MENU MENUEX
BEGIN
POPUP "&Actions", ID_GEDBG_ACTIONS_MENU
BEGIN
MENUITEM "Rec&ord Next Frame", IDC_GEDBG_RECORD
MENUITEM "F&lush Pending Draws", IDC_GEDBG_FLUSH
END

POPUP "&Step", ID_GEDBG_STEP_MENU
BEGIN
MENUITEM "Next &Instruction", IDC_GEDBG_STEP
MENUITEM "To Cou&nter...", IDC_GEDBG_STEPCOUNT
MENUITEM "Next &Primitive", IDC_GEDBG_STEPPRIM
MENUITEM "Next &Curve", IDC_GEDBG_STEPCURVE
MENUITEM "Next &Texture", IDC_GEDBG_STEPTEX
MENUITEM "Next &Draw Flush", IDC_GEDBG_STEPDRAW
MENUITEM "Next &Frame", IDC_GEDBG_STEPFRAME
MENUITEM "", 0, MFT_SEPARATOR
MENUITEM "&Auto Flush Pending", IDC_GEDBG_FLUSHAUTO
END

POPUP "&Breakpoints", ID_GEDBG_BREAK_MENU
BEGIN
MENUITEM "&Resume", IDC_GEDBG_RESUME
MENUITEM "", 0, MFT_SEPARATOR
MENUITEM "Te&xture Pointer...", IDC_GEDBG_BREAKTEX
MENUITEM "Render Tar&get Pointer...", IDC_GEDBG_BREAKTARGET
END
END

IDR_POPUPMENUS MENU
BEGIN
POPUP "memview"
Expand Down
8 changes: 7 additions & 1 deletion Windows/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define IDC_RAM 107
#define IDC_STEPOVER 108
#define IDC_TABDATATYPE 109
#define IDR_GEDBG_MENU 110
#define ID_MEMVIEW_GOTOINDISASM 112
#define IDI_PPSSPP 115
#define IDI_STOPDISABLE 118
Expand Down Expand Up @@ -318,6 +319,11 @@
#define IDC_MEMVIEW_STATUS 40206
#define ID_MEMVIEW_EXTENTBEGIN 40207
#define ID_MEMVIEW_EXTENTEND 40208
#define ID_GEDBG_ACTIONS_MENU 40209
#define ID_GEDBG_STEP_MENU 40210
#define ID_GEDBG_BREAK_MENU 40211
#define IDC_GEDBG_FLUSH 40212
#define IDC_GEDBG_FLUSHAUTO 40213

// Dummy option to let the buffered rendering hotkey cycle through all the options.
#define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500
Expand All @@ -330,7 +336,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 256
#define _APS_NEXT_COMMAND_VALUE 40209
#define _APS_NEXT_COMMAND_VALUE 40214
#define _APS_NEXT_CONTROL_VALUE 1202
#define _APS_NEXT_SYMED_VALUE 101
#endif
Expand Down