From de382199275202987c128d3eb28ec1a94d043931 Mon Sep 17 00:00:00 2001 From: Gauvain 'GovanifY' Roussel-Tarbouriech Date: Fri, 5 Mar 2021 13:42:52 +0100 Subject: [PATCH] gsdump: parse gsdump packets into treeview --- pcsx2/gui/Dialogs/GSDumpDialog.cpp | 86 ++++++++++++++++++++++++++++-- pcsx2/gui/Dialogs/ModalPopups.h | 5 ++ 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/pcsx2/gui/Dialogs/GSDumpDialog.cpp b/pcsx2/gui/Dialogs/GSDumpDialog.cpp index e851e478dd..23181d1e52 100644 --- a/pcsx2/gui/Dialogs/GSDumpDialog.cpp +++ b/pcsx2/gui/Dialogs/GSDumpDialog.cpp @@ -54,6 +54,8 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) , m_selected_dump(new wxString("")) , m_debug_mode(new wxCheckBox(this, wxID_ANY, _("Debug Mode"))) , m_renderer_overrides(new wxRadioBox()) + , m_gif_list(new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(250, 200), wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS)) + , m_gif_packet(new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(250, 200), wxTR_HIDE_ROOT | wxTR_HAS_BUTTONS)) { const float scale = MSW_GetDPIScale(); SetMinWidth(scale * 460); @@ -81,7 +83,7 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) // debugger dbg_tree += new wxStaticText(this, wxID_ANY, _("GIF Packets")); - dbg_tree += new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(250, 200)); + dbg_tree += m_gif_list; dbg_actions += m_debug_mode; dbg_actions += new wxButton(this, ID_RUN_START, _("Go to Start")); dbg_actions += new wxButton(this, ID_RUN_STEP, _("Step")); @@ -90,7 +92,7 @@ Dialogs::GSDumpDialog::GSDumpDialog(wxWindow* parent) // gif gif += new wxStaticText(this, wxID_ANY, _("Packet Content")); - gif += new wxTreeCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(250, 200)); + gif += m_gif_packet; debugger += dbg_tree; @@ -185,7 +187,7 @@ void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event) freezeData fd = {0, (s8*)state_data}; std::vector dump; - while (dump_file.Tell() <= dump_file.Length()) + while (dump_file.Tell() < dump_file.Length()) { GSType id = Transfer; dump_file.Read(&id, 1); @@ -230,6 +232,11 @@ void Dialogs::GSDumpDialog::RunDump(wxCommandEvent& event) } } + if (m_debug_mode->GetValue()) + GenPacketList(dump); + + return; + GSinit(); GSsetBaseMem((void*)regs); if (GSopen2((void*)pDsp, renderer_override) != 0) @@ -389,4 +396,77 @@ void Dialogs::GSDumpDialog::ToVSync(wxCommandEvent& event) void Dialogs::GSDumpDialog::ToStart(wxCommandEvent& event) { m_button_events.push_back(GSEvent{RunCursor, 0}); +} + +void Dialogs::GSDumpDialog::GenPacketList(std::vector& dump) +{ + int i = 0; + m_gif_list->DeleteAllItems(); + wxTreeItemId mainrootId = m_gif_list->AddRoot("root"); + wxTreeItemId rootId = m_gif_list->AppendItem(mainrootId, "VSync"); + for (auto& element : dump) + { + switch (element.id) + { + case Transfer: + { + switch (element.path) + { + case Path1Old: + { + wxString s; + s.Printf("%d - Transfer - Path1Old - %d byte", i, element.length); + m_gif_list->AppendItem(rootId, s); + break; + } + case Path1New: + { + wxString s; + s.Printf("%d - Transfer - Path1New - %d byte", i, element.length); + m_gif_list->AppendItem(rootId, s); + break; + } + case Path2: + { + wxString s; + s.Printf("%d - Transfer - Path2 - %d byte", i, element.length); + m_gif_list->AppendItem(rootId, s); + break; + } + case Path3: + { + wxString s; + s.Printf("%d - Transfer - Path3 - %d byte", i, element.length); + m_gif_list->AppendItem(rootId, s); + break; + } + } + break; + } + case VSync: + { + wxString s; + s.Printf("%d - VSync - %d byte", i, element.length); + m_gif_list->SetItemText(rootId, s); + rootId = m_gif_list->AppendItem(mainrootId, "VSync"); + break; + } + case ReadFIFO2: + { + wxString s; + s.Printf("%d - ReadFIFO2 - %d byte", i, element.length); + m_gif_list->AppendItem(rootId, s); + break; + } + case Registers: + { + wxString s; + s.Printf("%d - Registers - %d byte", i, element.length); + m_gif_list->AppendItem(rootId, s); + break; + } + } + i++; + } + m_gif_list->Delete(rootId); } \ No newline at end of file diff --git a/pcsx2/gui/Dialogs/ModalPopups.h b/pcsx2/gui/Dialogs/ModalPopups.h index ede9c4313b..89f14e6823 100644 --- a/pcsx2/gui/Dialogs/ModalPopups.h +++ b/pcsx2/gui/Dialogs/ModalPopups.h @@ -20,6 +20,8 @@ #include "Panels/ConfigurationPanels.h" #include +#include + class FirstTimeWizard : public wxWizard { @@ -89,6 +91,8 @@ namespace Dialogs wxString* m_selected_dump; wxCheckBox* m_debug_mode; wxRadioBox* m_renderer_overrides; + wxTreeCtrl* m_gif_list; + wxTreeCtrl* m_gif_packet; void GetDumpsList(); void SelectedDump(wxListEvent& evt); void RunDump(wxCommandEvent& event); @@ -140,6 +144,7 @@ namespace Dialogs }; std::vector m_button_events; void ProcessDumpEvent(GSData event, char* regs); + void GenPacketList(std::vector& dump); };