From a4a72ed7c19d4f1e9fd9258ec0c8ba7acc3f8a2f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Jan 2022 11:46:49 -0800 Subject: [PATCH 1/3] GE Debugger: Add a menu to the GE debugger window. This will allow adding more features without making the UI a mess. --- Windows/GEDebugger/GEDebugger.cpp | 13 +++++++------ Windows/ppsspp.rc | 27 +++++++++++++++++++++++++++ Windows/resource.h | 6 +++++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index f0d881fec9..ef19a9dbae 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -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); @@ -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); @@ -704,11 +706,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; diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 6e2f2d4657..1239a147c3 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -662,6 +662,33 @@ BEGIN END END +IDR_GEDBG_MENU MENUEX +BEGIN + POPUP "&Actions", ID_GEDBG_ACTIONS_MENU + BEGIN + MENUITEM "Rec&ord Next Frame", IDC_GEDBG_RECORD + 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 + 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 Target Pointer...", IDC_GEDBG_BREAKTARGET + END +END + IDR_POPUPMENUS MENU BEGIN POPUP "memview" diff --git a/Windows/resource.h b/Windows/resource.h index ce21b3a85a..bb9fd35226 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -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 @@ -318,6 +319,9 @@ #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 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 @@ -330,7 +334,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 40212 #define _APS_NEXT_CONTROL_VALUE 1202 #define _APS_NEXT_SYMED_VALUE 101 #endif From b840eec29062053a492de936310b67afc6b35400 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Jan 2022 11:59:49 -0800 Subject: [PATCH 2/3] GE Debugger: Cut down on primary buttons. Most of these are not commonly used, and it makes the interface feel a bit cluttered. --- Windows/ppsspp.rc | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 1239a147c3..84d9aa28cc 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -203,15 +203,13 @@ 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 @@ -219,11 +217,9 @@ BEGIN 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 @@ -685,7 +681,7 @@ BEGIN MENUITEM "&Resume", IDC_GEDBG_RESUME MENUITEM "", 0, MFT_SEPARATOR MENUITEM "Te&xture Pointer...", IDC_GEDBG_BREAKTEX - MENUITEM "Render Target Pointer...", IDC_GEDBG_BREAKTARGET + MENUITEM "Render Tar&get Pointer...", IDC_GEDBG_BREAKTARGET END END From eb95b995239e9aadec0f359b0dcf6e675c90dd5a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Jan 2022 13:12:59 -0800 Subject: [PATCH 3/3] GE Debugger: Add option to auto flush. This makes it easier to see what's happening in each draw. --- GPU/Common/GPUDebugInterface.h | 1 + GPU/Debugger/Stepping.cpp | 14 ++++++++++++++ GPU/Debugger/Stepping.h | 1 + GPU/GPUCommon.cpp | 4 ++++ GPU/GPUCommon.h | 1 + GPU/Software/TransformUnit.cpp | 1 + Windows/GEDebugger/GEDebugger.cpp | 22 ++++++++++++++++++++++ Windows/GEDebugger/GEDebugger.h | 2 ++ Windows/ppsspp.rc | 3 +++ Windows/resource.h | 4 +++- 10 files changed, 52 insertions(+), 1 deletion(-) diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index f72d57939d..97e97c9ea3 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -210,6 +210,7 @@ public: // 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 &vertices, std::vector &indices) { return false; diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index 2cc06f52fe..99267b38f5 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -36,6 +36,7 @@ enum PauseAction { PAUSE_GETTEX, PAUSE_GETCLUT, PAUSE_SETCMDVALUE, + PAUSE_FLUSHDRAW, }; static bool isStepping; @@ -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."); } @@ -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); } diff --git a/GPU/Debugger/Stepping.h b/GPU/Debugger/Stepping.h index 85b8a1082e..af93743eb3 100644 --- a/GPU/Debugger/Stepping.h +++ b/GPU/Debugger/Stepping.h @@ -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(); diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index e434470bc2..c7ff6f4521 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -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) diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 5eaf3ec145..361779821c 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -171,6 +171,7 @@ public: // Note: Not virtual! void Flush(); + void DispatchFlush() override; #ifdef USE_CRT_DBG #undef new diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 6b3ae38ff7..9313f06eb2 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -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) { diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index ef19a9dbae..31b8195bee 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -342,6 +342,8 @@ void CGEDebugger::UpdatePreviews() { } updating_ = true; + if (autoFlush_) + GPU_FlushDrawing(); UpdateTextureLevel(textureLevel_); UpdatePrimaryPreview(state); UpdateSecondPreview(state); @@ -784,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: @@ -881,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; @@ -937,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)); +} diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index 9202c85fad..ebf9a2c0d7 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -83,6 +83,7 @@ private: 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); @@ -102,6 +103,7 @@ private: 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; diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 84d9aa28cc..05d72954fc 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -663,6 +663,7 @@ 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 @@ -674,6 +675,8 @@ BEGIN 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 diff --git a/Windows/resource.h b/Windows/resource.h index bb9fd35226..0f02787f64 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -322,6 +322,8 @@ #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 @@ -334,7 +336,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 256 -#define _APS_NEXT_COMMAND_VALUE 40212 +#define _APS_NEXT_COMMAND_VALUE 40214 #define _APS_NEXT_CONTROL_VALUE 1202 #define _APS_NEXT_SYMED_VALUE 101 #endif