GE Debugger: Add option to auto flush.

This makes it easier to see what's happening in each draw.
This commit is contained in:
Unknown W. Brackets 2022-01-22 13:12:59 -08:00
parent b840eec290
commit eb95b99523
10 changed files with 52 additions and 1 deletions

View File

@ -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<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
return false;

View File

@ -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);
}

View File

@ -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();

View File

@ -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)

View File

@ -171,6 +171,7 @@ public:
// Note: Not virtual!
void Flush();
void DispatchFlush() override;
#ifdef USE_CRT_DBG
#undef new

View File

@ -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) {

View File

@ -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));
}

View File

@ -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;

View File

@ -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

View File

@ -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