diff options
| author | Random06457 <28494085+Random06457@users.noreply.github.com> | 2023-11-19 22:26:37 +0100 |
|---|---|---|
| committer | Random06457 <28494085+Random06457@users.noreply.github.com> | 2023-11-19 22:26:37 +0100 |
| commit | 64271fe66fad26a97bd69417a68d7b7b80728dcc (patch) | |
| tree | d3a05833d7e0566f1f28f7cb717d202d085c0dca | |
| parent | ac78f25ca96c415e40279a8f15c98603a46c8ca8 (diff) | |
integrate GfxDebugger
| -rw-r--r-- | mm/2s2h/SohGui.cpp | 6 | ||||
| -rw-r--r-- | mm/2s2h/SohMenuBar.cpp | 11 | ||||
| -rw-r--r-- | mm/include/gfx.h | 19 | ||||
| -rw-r--r-- | mm/src/code/graph.c | 25 |
4 files changed, 44 insertions, 17 deletions
diff --git a/mm/2s2h/SohGui.cpp b/mm/2s2h/SohGui.cpp index 3f7b792f2..6771ff921 100644 --- a/mm/2s2h/SohGui.cpp +++ b/mm/2s2h/SohGui.cpp @@ -110,6 +110,7 @@ namespace SohGui { std::shared_ptr<LUS::GuiWindow> mConsoleWindow; std::shared_ptr<LUS::GuiWindow> mStatsWindow; std::shared_ptr<LUS::GuiWindow> mInputEditorWindow; + std::shared_ptr<LUS::GuiWindow> mGfxDebuggerWindow; //std::shared_ptr<AudioEditor> mAudioEditorWindow; //std::shared_ptr<GameControlEditor::GameControlEditorWindow> mGameControlEditorWindow; @@ -155,6 +156,11 @@ namespace SohGui { SPDLOG_ERROR("Could not find input editor window"); } + mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); + if (mGfxDebuggerWindow == nullptr) { + SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); + } + /* mAudioEditorWindow = std::make_shared<AudioEditor>("gAudioEditor.WindowOpen", "Audio Editor"); gui->AddGuiWindow(mAudioEditorWindow); diff --git a/mm/2s2h/SohMenuBar.cpp b/mm/2s2h/SohMenuBar.cpp index 1192cd2bf..cbc502839 100644 --- a/mm/2s2h/SohMenuBar.cpp +++ b/mm/2s2h/SohMenuBar.cpp @@ -446,6 +446,7 @@ void DrawSettingsMenu() { extern std::shared_ptr<LUS::GuiWindow> mStatsWindow; extern std::shared_ptr<LUS::GuiWindow> mConsoleWindow; +extern std::shared_ptr<LUS::GuiWindow> mGfxDebuggerWindow; // extern std::shared_ptr<SaveEditorWindow> mSaveEditorWindow; // extern std::shared_ptr<ColViewerWindow> mColViewerWindow; // extern std::shared_ptr<ActorViewerWindow> mActorViewerWindow; @@ -505,6 +506,16 @@ void DrawDeveloperToolsMenu() { "Enables the console window, allowing you to input commands, type help for some examples"); } UIWidgets::Spacer(0); + if (mGfxDebuggerWindow) { + if (ImGui::Button(GetWindowButtonText("Gfx Debugger", CVarGetInteger("gGfxDebuggerEnabled", 0)).c_str(), + ImVec2(-1.0f, 0.0f))) { + mGfxDebuggerWindow->ToggleVisibility(); + } + UIWidgets::Tooltip( + "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples"); + } + UIWidgets::Spacer(0); + // if (mSaveEditorWindow) { // if (ImGui::Button(GetWindowButtonText("Save Editor", CVarGetInteger("gSaveEditorEnabled", 0)).c_str(), // ImVec2(-1.0f, 0.0f))) { diff --git a/mm/include/gfx.h b/mm/include/gfx.h index 3bcfc7701..499679cbf 100644 --- a/mm/include/gfx.h +++ b/mm/include/gfx.h @@ -247,14 +247,19 @@ extern Gfx gEmptyDL[]; // __gfxCtx shouldn't be used directly. // Use the DISP macros defined above when writing to display buffers. -#define OPEN_DISPS(gfxCtx) \ - { \ - GraphicsContext* __gfxCtx = gfxCtx; \ - s32 __dispPad +#define OPEN_DISPS(gfxCtx) \ + { \ + GraphicsContext* __gfxCtx = gfxCtx; \ + gDPNoOpOpenDisp(gfxCtx->polyOpa.p++, __FILE__, __LINE__); \ + gDPNoOpOpenDisp(gfxCtx->polyXlu.p++, __FILE__, __LINE__); \ + gDPNoOpOpenDisp(gfxCtx->overlay.p++, __FILE__, __LINE__); -#define CLOSE_DISPS(gfxCtx) \ - (void)0; \ - } \ +#define CLOSE_DISPS(gfxCtx) \ + (void)0; \ + gDPNoOpCloseDisp(gfxCtx->polyOpa.p++, __FILE__, __LINE__); \ + gDPNoOpCloseDisp(gfxCtx->polyXlu.p++, __FILE__, __LINE__); \ + gDPNoOpCloseDisp(gfxCtx->overlay.p++, __FILE__, __LINE__); \ + } \ (void)0 #define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) diff --git a/mm/src/code/graph.c b/mm/src/code/graph.c index a4b73bf84..929c5de6c 100644 --- a/mm/src/code/graph.c +++ b/mm/src/code/graph.c @@ -251,6 +251,10 @@ void Graph_UpdateGame(GameState* gameState) { */ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { u32 problem; + if (GfxDebuggerIsDebugging()) { + Graph_ProcessGfxCommands(&gGfxMasterDL->taskStart[0]); + return; + } gameState->unk_A3 = 0; Graph_SetNextGfxPool(gfxCtx); @@ -271,20 +275,18 @@ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { Gfx* gfx = gGfxMasterDL->taskStart; gSPSegment(gfx++, 0x0E, gGfxMasterDL->taskStart); - __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[3] - (uintptr_t)&D_0E000000) + 1); - __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[0] - (uintptr_t)&D_0E000000) + 1); - __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[1] - (uintptr_t)&D_0E000000) + 1); - __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[2] - (uintptr_t)&D_0E000000) + 1); - __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.debugDisp[0] - (uintptr_t)&D_0E000000) + 1); - gSPDisplayList(gfx++, gfxCtx->work.start); + // __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[3] - (uintptr_t)&D_0E000000) + 1); + // __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[0] - (uintptr_t)&D_0E000000) + 1); + // __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[1] - (uintptr_t)&D_0E000000) + 1); + // __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.disps[2] - (uintptr_t)&D_0E000000) + 1); + // __gSPDisplayList(gfx++, 0x0E000000 + ((uintptr_t)&D_0E000000.debugDisp[0] - (uintptr_t)&D_0E000000) + 1); + // gSPDisplayList(gfx++, gfxCtx->work.start); gSPDisplayList(gfx++, gGfxPools[gfxCtx->gfxPoolIdx % 2].workBuffer); gSPDisplayList(gfx++, gGfxPools[gfxCtx->gfxPoolIdx % 2].polyOpaBuffer); gSPDisplayList(gfx++, gGfxPools[gfxCtx->gfxPoolIdx % 2].polyXluBuffer); gSPDisplayList(gfx++, gGfxPools[gfxCtx->gfxPoolIdx % 2].overlayBuffer); - - // BENTODO: CRASH! - // gSPDisplayList(gfx++, gGfxPools[gfxCtx->gfxPoolIdx % 2].debugBuffer); + gSPDisplayList(gfx++, gGfxPools[gfxCtx->gfxPoolIdx % 2].debugBuffer); gDPPipeSync(gfx++); gDPFullSync(gfx++); @@ -325,6 +327,9 @@ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) { gfxCtx->gfxPoolIdx++; gfxCtx->framebufferIndex++; + if (GfxDebuggerIsDebuggingRequested()) { + GfxDebuggerDebugDisplayList(&gGfxMasterDL->taskStart[0]); + } Graph_ProcessGfxCommands(&gGfxMasterDL->taskStart[0]); } @@ -419,4 +424,4 @@ void RunFrame() { void Graph_ThreadEntry(void* arg0) { Graph_ProcessFrame(RunFrame); -}
\ No newline at end of file +} |
