From 4003ea9bab821911867c3b9bb0f0f53973de14a5 Mon Sep 17 00:00:00 2001 From: Archez Date: Tue, 3 Sep 2024 01:09:29 -0400 Subject: [PATCH 1/2] update gfx debugger for more otr commands and context menu --- src/graphic/Fast3D/gfx_pc.cpp | 15 ++ src/window/gui/GfxDebuggerWindow.cpp | 343 ++++++++++++++++++++++++--- src/window/gui/GfxDebuggerWindow.h | 2 +- 3 files changed, 324 insertions(+), 36 deletions(-) diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 43a8f68d0..d3741055c 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -4091,12 +4091,20 @@ void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacemen if (dbg->IsDebugging()) { g_exec_stack.gfx_path.push_back(cmd); if (dbg->HasBreakPoint(g_exec_stack.gfx_path)) { + // On a breakpoint with the active framebuffer still set, we need to reset back to prevent + // soft locking the renderer + if (fbActive) { + fbActive = 0; + gfx_rapi->start_draw_to_framebuffer(game_renders_to_framebuffer ? game_framebuffer : 0, 1); + } + break; } g_exec_stack.gfx_path.pop_back(); } gfx_step(); } + gfx_flush(); gfxFramebuffer = 0; currentDir = std::stack(); @@ -4118,7 +4126,14 @@ void gfx_run(Gfx* commands, const std::unordered_map& mtx_replacemen } else { gfxFramebuffer = (uintptr_t)gfx_rapi->get_framebuffer_texture_id(game_framebuffer); } + } else if (fbActive) { + // Failsafe reset to main framebuffer to prevent softlocking the renderer + fbActive = 0; + gfx_rapi->start_draw_to_framebuffer(0, 1); + + assert(0 && "active framebuffer was never reset back to original"); } + Ship::Context::GetInstance()->GetWindow()->GetGui()->StartFrame(); Ship::Context::GetInstance()->GetWindow()->GetGui()->RenderViewports(); gfx_rapi->end_frame(); diff --git a/src/window/gui/GfxDebuggerWindow.cpp b/src/window/gui/GfxDebuggerWindow.cpp index 05551378a..8cc8216c5 100644 --- a/src/window/gui/GfxDebuggerWindow.cpp +++ b/src/window/gui/GfxDebuggerWindow.cpp @@ -50,11 +50,13 @@ static inline void* seg_addr(uintptr_t w1) { #define C1(pos, width) ((cmd->words.w1 >> (pos)) & ((1U << width) - 1)) // static int s_dbgcnt = 0; -void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector& gfx_path) const { +void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector& gfx_path, + float parentPosY = 0) const { + const F3DGfx* dlStart = cmd; auto dbg = Ship::Context::GetInstance()->GetGfxDebugger(); - auto node_with_text = [dbg, this, &gfx_path](const F3DGfx* cmd, const std::string& text, - const F3DGfx* sub = nullptr) mutable { + auto node_with_text = [dbg, dlStart, parentPosY, this, &gfx_path](const F3DGfx* cmd, const std::string& text, + const F3DGfx* sub = nullptr) mutable { ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; gfx_path.push_back(cmd); @@ -63,13 +65,36 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorSetBreakPoint(gfx_path); } + + if (ImGui::BeginPopupContextItem(nullptr, ImGuiPopupFlags_MouseButtonRight)) { + if (ImGui::Selectable("Copy text")) { + SDL_SetClipboardText(text.c_str()); + } + if (ImGui::Selectable("Copy address")) { + std::string address = fmt::format("0x{:x}", (uintptr_t)cmd); + SDL_SetClipboardText(address.c_str()); + } + if (parentPosY > 0) { + scrollTo = ImGui::Selectable("Scroll to parent"); + } + ImGui::EndPopup(); + } + + if (scrollTo) { + ImGui::SetScrollY(parentPosY); + } + if (open) { if (sub) { - DrawDisasNode(sub, gfx_path); + DrawDisasNode(sub, gfx_path, curPosY); } ImGui::TreePop(); } @@ -78,11 +103,16 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector input; @@ -96,13 +126,22 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 >> 24); node_with_text(cmd, fmt::format("UNK: 0x{:X}", opcode)); @@ -114,6 +153,7 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; uint32_t p = C0(16, 8); @@ -122,14 +162,49 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1); + if (C0(16, 1) == 0) { + node_with_text(cmd0, fmt::format("G_DL: 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), subGFX); + cmd++; + } else { + node_with_text(cmd0, fmt::format("G_DL (branch): 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), + subGFX); + return; + } + break; + } + +#ifdef F3DEX_GBI_2 // Different opcodes, same behavior. Return out of subtree. + case F3DEX2_G_ENDDL: { +#else + case F3DEX_G_ENDDL: { +#endif + simple_node(cmd, opcode); + return; + } + + // Increment 3 times because texture rectangle uses RDPHALF + case RDP_G_TEXRECTFLIP: + case RDP_G_TEXRECT: { + simple_node(cmd, opcode); + cmd += 3; + break; + } case OTR_G_MARKER: { cmd++; @@ -144,7 +219,6 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 << 32) + cmd->words.w1; @@ -153,7 +227,6 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; + F3DGfx* subGfx = (F3DGfx*)ResourceGetDataByName((const char*)fileName); + + if (subGfx == nullptr) { + assert(0 && "in gfx_pc????"); + } + + if (C0(16, 1) == 0 && subGfx != nullptr) { + node_with_text(cmd0, fmt::format("G_DL_OTR_HASH: {}", fileName), subGfx); + cmd++; + break; + } else { + node_with_text(cmd0, fmt::format("G_DL_OTR_HASH (branch): {}", fileName), subGfx); + return; + } + + break; + } + + case OTR_G_DL_INDEX: { + uint8_t segNum = (uint8_t)(cmd->words.w1 >> 24); + uint32_t index = (uint32_t)(cmd->words.w1 & 0x00FFFFFF); + uintptr_t segAddr = (segNum << 24) | (index * sizeof(F3DGfx)) + 1; + F3DGfx* subGFX = (F3DGfx*)seg_addr(segAddr); + + if (C0(16, 1) == 0) { + node_with_text(cmd0, fmt::format("G_DL_INDEX: 0x{:x} -> {}", segAddr, (void*)subGFX), subGFX); + cmd++; + } else { + node_with_text(cmd0, fmt::format("G_DL_INDEX (branch): 0x{:x} -> {}", segAddr, (void*)subGFX), + subGFX); + return; + } + + break; + } + + case OTR_G_BRANCH_Z_OTR: { + uint8_t vbidx = (uint8_t)(cmd->words.w0 & 0x00000FFF); + uint32_t zval = (uint32_t)(cmd->words.w1); + + cmd++; + + uint64_t hash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; + F3DGfx* subGfx = (F3DGfx*)ResourceGetDataByCrc(hash); + const char* dlName = ResourceGetNameByCrc(hash); + + if (!dlName) { + dlName = "UNKNOWN"; + } + + // TODO: Figure out the vertex value at the time this command would have run, since debugger display is + // not in sync with renderer execution. + // if (subGfx && (g_rsp.loaded_vertices[vbidx].z <= zval || + // (g_rsp.extra_geometry_mode & G_EX_ALWAYS_EXECUTE_BRANCH) != 0)) { + if (subGfx) { + node_with_text(cmd0, fmt::format("G_BRANCH_Z_OTR: zval {}, vIdx {}, DL {}", zval, vbidx, dlName), + subGfx); + } else { + node_with_text(cmd0, fmt::format("G_BRANCH_Z_OTR: zval {}, vIdx {}, DL {}", zval, vbidx, dlName)); + } + + cmd++; + break; + } + case OTR_G_SETTIMG_OTR_HASH: { cmd++; uint64_t hash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; @@ -171,8 +311,14 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector texture = std::static_pointer_cast( - // Ship::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(ResourceGetNameByCrc(hash))); + cmd++; + break; + } + + case OTR_G_SETTIMG_OTR_FILEPATH: { + const char* fileName = (char*)cmd->words.w1; + node_with_text(cmd0, fmt::format("G_SETTIMG_OTR_FILEPATH: {}", fileName)); + cmd++; break; } @@ -186,32 +332,51 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1); - if (C0(16, 1) == 0) { - node_with_text(cmd0, fmt::format("G_DL: 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), subGFX); - cmd++; - } else { - node_with_text(cmd0, fmt::format("G_DL (branch): 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), - subGFX); - return; - } + case OTR_G_VTX_OTR_FILEPATH: { + const char* fileName = (char*)cmd->words.w1; + node_with_text(cmd0, fmt::format("G_VTX_OTR_FILEPATH: {}", fileName)); + + cmd += 2; break; } - case F3DEX2_G_ENDDL: { - simple_node(cmd, opcode); - return; + case OTR_G_MTX_OTR: { + cmd++; + uint64_t hash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; + const char* name = ResourceGetNameByCrc(hash); + if (!name) + name = "UNKNOWN"; + + node_with_text(cmd0, fmt::format("G_MTX_OTR: {}", name)); + + cmd++; + break; } - case RDP_G_TEXRECT: { - simple_node(cmd, opcode); - cmd += 3; + case OTR_G_MTX_OTR2: { + const char* fileName = (char*)cmd->words.w1; + node_with_text(cmd0, fmt::format("G_MTX_OTR2: {}", fileName)); + + cmd++; + break; + } + + case OTR_G_MOVEMEM_HASH: { + const uint8_t index = C1(24, 8); + const uint8_t offset = C1(16, 8); + cmd++; + uint64_t hash = ((uint64_t)cmd->words.w0 << 32) + cmd->words.w1; + const char* name = ResourceGetNameByCrc(hash); + if (!name) + name = "UNKNOWN"; + + node_with_text(cmd0, fmt::format("G_MOVEMEM_HASH: idx {}, offset {}, {}", index, offset, name)); + + cmd++; break; } @@ -221,15 +386,123 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1)); + cmd++; + break; + } + + case OTR_G_INVALTEXCACHE: { + const char* texAddr = (const char*)cmd->words.w1; + if (texAddr == 0) { + node_with_text(cmd0, fmt::format("G_INVALTEXCACHE: clear all entries")); + } else { + if (((uintptr_t)texAddr & 1) == 0 && + Ship::Context::GetInstance()->GetResourceManager()->OtrSignatureCheck(texAddr)) { + node_with_text(cmd0, fmt::format("G_INVALTEXCACHE: {}", texAddr)); + } else { + node_with_text(cmd0, fmt::format("G_INVALTEXCACHE: 0x{:x}", (uintptr_t)texAddr)); + } + } + + cmd++; + break; + } + case OTR_G_SETTIMG_FB: { - node_with_text(cmd0, fmt::format("G_SETTIMG_FB: src {}", cmd->words.w1)); + node_with_text(cmd0, fmt::format("G_SETTIMG_FB: src FB {}", (int32_t)cmd->words.w1)); cmd++; break; } case OTR_G_COPYFB: { - node_with_text(cmd0, fmt::format("G_COPYFB: src {}, dest {}, new frames only {}", C0(0, 11), C0(11, 11), - C0(22, 1))); + node_with_text(cmd0, fmt::format("G_COPYFB: src FB {}, dest FB {}, new frames only {}", C0(0, 11), + C0(11, 11), C0(22, 1))); + cmd++; + break; + } + + case OTR_G_SETFB: { + node_with_text(cmd0, fmt::format("G_SETFB: src FB {}", (int32_t)cmd->words.w1)); + cmd++; + break; + } + + case OTR_G_RESETFB: { + node_with_text(cmd0, fmt::format("G_RESETFB")); + cmd++; + break; + } + + case OTR_G_READFB: { + int fbId = C0(0, 8); + bool bswap = C0(8, 1); + cmd++; + node_with_text(cmd0, + fmt::format("G_READFB: src FB {}, byteswap {}, ulx {}, uly {}, width {}, height {}", + fbId, bswap, C0(0, 16), C0(16, 16), C1(0, 16), C1(16, 16))); + cmd++; + break; + } + + case OTR_G_TEXRECT_WIDE: { + int32_t lrx = static_cast((C0(0, 24) << 8)) >> 8; + int32_t lry = static_cast((C1(0, 24) << 8)) >> 8; + int32_t tile = C1(24, 3); + cmd++; + uint32_t ulx = static_cast((C0(0, 24) << 8)) >> 8; + uint32_t uly = static_cast((C1(0, 24) << 8)) >> 8; + cmd++; + uint32_t uls = C0(16, 16); + uint32_t ult = C0(0, 16); + uint32_t dsdx = C1(16, 16); + uint32_t dtdy = C1(0, 16); + + node_with_text( + cmd0, + fmt::format("G_TEXRECT_WIDE: ulx {}, uly {}, lrx {}, lry {}, tile {}, s {}, t {}, dsdx {}, dtdy {}", + ulx, uly, lrx, lry, uls, tile, ult, dsdx, dtdy)); + + cmd++; + break; + } + + case OTR_G_FILLWIDERECT: { + int32_t lrx = (int32_t)(C0(0, 24) << 8) >> 8; + int32_t lry = (int32_t)(C1(0, 24) << 8) >> 8; + cmd++; + int32_t ulx = (int32_t)(C0(0, 24) << 8) >> 8; + int32_t uly = (int32_t)(C1(0, 24) << 8) >> 8; + node_with_text(cmd0, fmt::format("G_FILLWIDERECT: ulx {}, uly {}, lrx {}, lry {}", ulx, uly, lrx, lry)); + + cmd++; + break; + } + + case OTR_G_SETGRAYSCALE: { + node_with_text(cmd0, fmt::format("G_SETGRAYSCALE: Enable {}", (uint32_t)cmd->words.w1)); + cmd++; + break; + } + + case OTR_G_SETINTENSITY: { + node_with_text(cmd0, fmt::format("G_SETINTENSITY: red {}, green {}, blue {}, alpha {}", C1(24, 8), + C1(16, 8), C1(8, 8), C1(0, 8))); + cmd++; + break; + } + + case OTR_G_EXTRAGEOMETRYMODE: { + uint32_t setBits = (uint32_t)cmd->words.w1; + uint32_t clearBits = ~C0(0, 24); + node_with_text(cmd0, fmt::format("G_EXTRAGEOMETRYMODE: Set {}, Clear {}", setBits, clearBits)); cmd++; break; } diff --git a/src/window/gui/GfxDebuggerWindow.h b/src/window/gui/GfxDebuggerWindow.h index e508c652d..fa9a2dddb 100644 --- a/src/window/gui/GfxDebuggerWindow.h +++ b/src/window/gui/GfxDebuggerWindow.h @@ -18,7 +18,7 @@ class GfxDebuggerWindow : public Ship::GuiWindow { void DrawElement() override; private: - void DrawDisasNode(const F3DGfx* cmd, std::vector& gfx_path) const; + void DrawDisasNode(const F3DGfx* cmd, std::vector& gfx_path, float parentPosY) const; void DrawDisas(); private: From 70cb6c0ef29dce19cc4704c8830217ba09cb452b Mon Sep 17 00:00:00 2001 From: Archez Date: Tue, 3 Sep 2024 11:25:09 -0400 Subject: [PATCH 2/2] clang tidy it --- src/window/gui/GfxDebuggerWindow.cpp | 141 ++++++++++++++------------- src/window/gui/GfxDebuggerWindow.h | 2 +- 2 files changed, 74 insertions(+), 69 deletions(-) diff --git a/src/window/gui/GfxDebuggerWindow.cpp b/src/window/gui/GfxDebuggerWindow.cpp index 8cc8216c5..7030cc596 100644 --- a/src/window/gui/GfxDebuggerWindow.cpp +++ b/src/window/gui/GfxDebuggerWindow.cpp @@ -50,20 +50,22 @@ static inline void* seg_addr(uintptr_t w1) { #define C1(pos, width) ((cmd->words.w1 >> (pos)) & ((1U << width) - 1)) // static int s_dbgcnt = 0; -void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector& gfx_path, +void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector& gfxPath, float parentPosY = 0) const { const F3DGfx* dlStart = cmd; auto dbg = Ship::Context::GetInstance()->GetGfxDebugger(); - auto node_with_text = [dbg, dlStart, parentPosY, this, &gfx_path](const F3DGfx* cmd, const std::string& text, - const F3DGfx* sub = nullptr) mutable { - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; + auto nodeWithText = [dbg, dlStart, parentPosY, this, &gfxPath](const F3DGfx* cmd, const std::string& text, + const F3DGfx* sub = nullptr) mutable { + gfxPath.push_back(cmd); - gfx_path.push_back(cmd); - if (dbg->HasBreakPoint(gfx_path)) + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow; + if (dbg->HasBreakPoint(gfxPath)) { flags |= ImGuiTreeNodeFlags_Selected; - if (sub == nullptr) + } + if (sub == nullptr) { flags |= ImGuiTreeNodeFlags_Leaf; + } bool scrollTo = false; float curPosY = ImGui::GetCursorPosY(); @@ -71,7 +73,7 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorSetBreakPoint(gfx_path); + dbg->SetBreakPoint(gfxPath); } if (ImGui::BeginPopupContextItem(nullptr, ImGuiPopupFlags_MouseButtonRight)) { @@ -94,14 +96,14 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 >> 24); - node_with_text(cmd, fmt::format("UNK: 0x{:X}", opcode)); + nodeWithText(cmd, fmt::format("UNK: 0x{:X}", opcode)); } }; @@ -160,11 +162,11 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1); if (C0(16, 1) == 0) { - node_with_text(cmd0, fmt::format("G_DL: 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), subGFX); + nodeWithText(cmd0, fmt::format("G_DL: 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), subGFX); cmd++; } else { - node_with_text(cmd0, fmt::format("G_DL (branch): 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), - subGFX); + nodeWithText(cmd0, fmt::format("G_DL (branch): 0x{:x} -> {}", cmd->words.w1, (void*)subGFX), + subGFX); return; } break; @@ -194,14 +196,14 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 << 32) + cmd->words.w1; const char* dlName = ResourceGetNameByCrc(hash); - if (!dlName) + if (!dlName) { dlName = "UNKNOWN"; + } - node_with_text(cmd0, fmt::format("G_MARKER: {}", dlName)); + nodeWithText(cmd0, fmt::format("G_MARKER: {}", dlName)); cmd++; break; } @@ -227,7 +230,7 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector {}", segAddr, (void*)subGFX), subGFX); + nodeWithText(cmd0, fmt::format("G_DL_INDEX: 0x{:x} -> {}", segAddr, (void*)subGFX), subGFX); cmd++; } else { - node_with_text(cmd0, fmt::format("G_DL_INDEX (branch): 0x{:x} -> {}", segAddr, (void*)subGFX), - subGFX); + nodeWithText(cmd0, fmt::format("G_DL_INDEX (branch): 0x{:x} -> {}", segAddr, (void*)subGFX), + subGFX); return; } @@ -292,10 +295,10 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 << 32) + cmd->words.w1; const char* name = ResourceGetNameByCrc(hash); - if (!name) + if (!name) { name = "UNKNOWN"; + } - node_with_text(cmd0, fmt::format("G_SETTIMG_OTR_HASH: {}", name)); + nodeWithText(cmd0, fmt::format("G_SETTIMG_OTR_HASH: {}", name)); cmd++; break; @@ -317,7 +321,7 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; - node_with_text(cmd0, fmt::format("G_SETTIMG_OTR_FILEPATH: {}", fileName)); + nodeWithText(cmd0, fmt::format("G_SETTIMG_OTR_FILEPATH: {}", fileName)); cmd++; break; @@ -327,10 +331,11 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 << 32) + cmd->words.w1; const char* name = ResourceGetNameByCrc(hash); - if (!name) + if (!name) { name = "UNKNOWN"; + } - node_with_text(cmd0, fmt::format("G_VTX_OTR_HASH: {}", name)); + nodeWithText(cmd0, fmt::format("G_VTX_OTR_HASH: {}", name)); cmd++; break; @@ -338,7 +343,7 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; - node_with_text(cmd0, fmt::format("G_VTX_OTR_FILEPATH: {}", fileName)); + nodeWithText(cmd0, fmt::format("G_VTX_OTR_FILEPATH: {}", fileName)); cmd += 2; break; @@ -348,10 +353,11 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 << 32) + cmd->words.w1; const char* name = ResourceGetNameByCrc(hash); - if (!name) + if (!name) { name = "UNKNOWN"; + } - node_with_text(cmd0, fmt::format("G_MTX_OTR: {}", name)); + nodeWithText(cmd0, fmt::format("G_MTX_OTR: {}", name)); cmd++; break; @@ -359,7 +365,7 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; - node_with_text(cmd0, fmt::format("G_MTX_OTR2: {}", fileName)); + nodeWithText(cmd0, fmt::format("G_MTX_OTR2: {}", fileName)); cmd++; break; @@ -371,30 +377,30 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w0 << 32) + cmd->words.w1; const char* name = ResourceGetNameByCrc(hash); - if (!name) + if (!name) { name = "UNKNOWN"; + } - node_with_text(cmd0, fmt::format("G_MOVEMEM_HASH: idx {}, offset {}, {}", index, offset, name)); + nodeWithText(cmd0, fmt::format("G_MOVEMEM_HASH: idx {}, offset {}, {}", index, offset, name)); cmd++; break; } case OTR_G_IMAGERECT: { - node_with_text(cmd0, fmt::format("G_IMAGERECT")); + nodeWithText(cmd0, fmt::format("G_IMAGERECT")); cmd += 3; break; } case OTR_G_TRI1_OTR: { - node_with_text(cmd0, - fmt::format("G_TRI1_OTR: v00 {}, v01 {}, v02 {}", C0(0, 16), C1(16, 16), C1(0, 16))); + nodeWithText(cmd0, fmt::format("G_TRI1_OTR: v00 {}, v01 {}, v02 {}", C0(0, 16), C1(16, 16), C1(0, 16))); cmd++; break; } case OTR_G_PUSHCD: { - node_with_text(cmd0, fmt::format("G_PUSHCD: filename {}", cmd->words.w1)); + nodeWithText(cmd0, fmt::format("G_PUSHCD: filename {}", cmd->words.w1)); cmd++; break; } @@ -402,13 +408,13 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; if (texAddr == 0) { - node_with_text(cmd0, fmt::format("G_INVALTEXCACHE: clear all entries")); + nodeWithText(cmd0, fmt::format("G_INVALTEXCACHE: clear all entries")); } else { if (((uintptr_t)texAddr & 1) == 0 && Ship::Context::GetInstance()->GetResourceManager()->OtrSignatureCheck(texAddr)) { - node_with_text(cmd0, fmt::format("G_INVALTEXCACHE: {}", texAddr)); + nodeWithText(cmd0, fmt::format("G_INVALTEXCACHE: {}", texAddr)); } else { - node_with_text(cmd0, fmt::format("G_INVALTEXCACHE: 0x{:x}", (uintptr_t)texAddr)); + nodeWithText(cmd0, fmt::format("G_INVALTEXCACHE: 0x{:x}", (uintptr_t)texAddr)); } } @@ -417,26 +423,26 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1)); + nodeWithText(cmd0, fmt::format("G_SETTIMG_FB: src FB {}", (int32_t)cmd->words.w1)); cmd++; break; } case OTR_G_COPYFB: { - node_with_text(cmd0, fmt::format("G_COPYFB: src FB {}, dest FB {}, new frames only {}", C0(0, 11), - C0(11, 11), C0(22, 1))); + nodeWithText(cmd0, fmt::format("G_COPYFB: src FB {}, dest FB {}, new frames only {}", C0(0, 11), + C0(11, 11), C0(22, 1))); cmd++; break; } case OTR_G_SETFB: { - node_with_text(cmd0, fmt::format("G_SETFB: src FB {}", (int32_t)cmd->words.w1)); + nodeWithText(cmd0, fmt::format("G_SETFB: src FB {}", (int32_t)cmd->words.w1)); cmd++; break; } case OTR_G_RESETFB: { - node_with_text(cmd0, fmt::format("G_RESETFB")); + nodeWithText(cmd0, fmt::format("G_RESETFB")); cmd++; break; } @@ -445,9 +451,8 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vector> 8; int32_t uly = (int32_t)(C1(0, 24) << 8) >> 8; - node_with_text(cmd0, fmt::format("G_FILLWIDERECT: ulx {}, uly {}, lrx {}, lry {}", ulx, uly, lrx, lry)); + nodeWithText(cmd0, fmt::format("G_FILLWIDERECT: ulx {}, uly {}, lrx {}, lry {}", ulx, uly, lrx, lry)); cmd++; break; } case OTR_G_SETGRAYSCALE: { - node_with_text(cmd0, fmt::format("G_SETGRAYSCALE: Enable {}", (uint32_t)cmd->words.w1)); + nodeWithText(cmd0, fmt::format("G_SETGRAYSCALE: Enable {}", (uint32_t)cmd->words.w1)); cmd++; break; } case OTR_G_SETINTENSITY: { - node_with_text(cmd0, fmt::format("G_SETINTENSITY: red {}, green {}, blue {}, alpha {}", C1(24, 8), - C1(16, 8), C1(8, 8), C1(0, 8))); + nodeWithText(cmd0, fmt::format("G_SETINTENSITY: red {}, green {}, blue {}, alpha {}", C1(24, 8), + C1(16, 8), C1(8, 8), C1(0, 8))); cmd++; break; } @@ -502,13 +507,13 @@ void GfxDebuggerWindow::DrawDisasNode(const F3DGfx* cmd, std::vectorwords.w1; uint32_t clearBits = ~C0(0, 24); - node_with_text(cmd0, fmt::format("G_EXTRAGEOMETRYMODE: Set {}, Clear {}", setBits, clearBits)); + nodeWithText(cmd0, fmt::format("G_EXTRAGEOMETRYMODE: Set {}, Clear {}", setBits, clearBits)); cmd++; break; } default: { - simple_node(cmd, opcode); + simpleNode(cmd, opcode); cmd++; break; } @@ -673,8 +678,8 @@ void GfxDebuggerWindow::DrawDisas() { ImGui::BeginChild("##Disassembler", ImVec2(0.0f, 0.0f), true); { - std::vector gfx_path; - DrawDisasNode(dlist, gfx_path); + std::vector gfxPath; + DrawDisasNode(dlist, gfxPath); } ImGui::EndChild(); } diff --git a/src/window/gui/GfxDebuggerWindow.h b/src/window/gui/GfxDebuggerWindow.h index fa9a2dddb..d1fa51376 100644 --- a/src/window/gui/GfxDebuggerWindow.h +++ b/src/window/gui/GfxDebuggerWindow.h @@ -18,7 +18,7 @@ class GfxDebuggerWindow : public Ship::GuiWindow { void DrawElement() override; private: - void DrawDisasNode(const F3DGfx* cmd, std::vector& gfx_path, float parentPosY) const; + void DrawDisasNode(const F3DGfx* cmd, std::vector& gfxPath, float parentPosY) const; void DrawDisas(); private: