GSDumpGUI: Parse all the packets in a transfer

This commit is contained in:
TellowKrinkle 2021-09-09 04:06:55 -05:00 committed by lightningterror
parent 7288a1fcb2
commit 234d643dd3
2 changed files with 101 additions and 64 deletions

View File

@ -422,6 +422,26 @@ void Dialogs::GSDumpDialog::ToStart(wxCommandEvent& event)
// GSDumpDialog Packet Parsing
// --------------------------------------------------------------------------------------
u32 Dialogs::GSDumpDialog::ReadPacketSize(const void* packet)
{
u128 tag;
memcpy(&tag, packet, sizeof(tag));
u32 nloop = GetBits(tag, 0, 15);
GIFFlag flg = GetBits<GIFFlag>(tag, 58, 2);
u32 nreg = GetBits(tag, 60, 4);
if (nreg == 0)
nreg = 16;
switch (flg)
{
case GIFFlag::PACKED:
return 16 + nloop * nreg * 16;
case GIFFlag::REGLIST:
return 16 + (nloop * nreg * 8 + 8) & ~15;
default:
return 16 + nloop * 16;
}
}
void Dialogs::GSDumpDialog::GenPacketList()
{
int i = 0;
@ -460,9 +480,45 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
{
case GSType::Transfer:
{
wxTreeItemId trootId = m_gif_packet->AppendItem(rootId, wxString::Format("Transfer Path %s", GetName(dump.path)));
u64 tag = *(u64*)(dump.data.get());
u64 regs = *(u64*)(dump.data.get() + 8);
char* data = dump.data.get();
u32 remaining = dump.length;
int idx = 0;
while (remaining >= 16)
{
wxTreeItemId trootId = m_gif_packet->AppendItem(rootId, wxString::Format("Transfer Path %s Packet %u", GetName(dump.path), idx));
ParseTransfer(trootId, data);
m_gif_packet->Expand(trootId);
u32 size = ReadPacketSize(data);
remaining -= size;
data += size;
idx++;
}
break;
}
case GSType::VSync:
{
wxString s;
s.Printf("Field = %u", *(u8*)(dump.data.get()));
m_gif_packet->AppendItem(rootId, s);
break;
}
case GSType::ReadFIFO2:
{
wxString s;
s.Printf("ReadFIFO2: Size = %d byte", dump.length);
m_gif_packet->AppendItem(rootId, s);
break;
}
case GSType::Registers:
m_gif_packet->AppendItem(rootId, "Registers");
break;
}
}
void Dialogs::GSDumpDialog::ParseTransfer(wxTreeItemId& trootId, char* data)
{
u64 tag = *(u64*)data;
u64 regs = *(u64*)(data + 8);
u32 nloop = GetBits(tag, 0, 15);
u8 eop = GetBits(tag, 15, 1);
u8 pre = GetBits(tag, 46, 1);
@ -497,7 +553,7 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
for (u32 i = 0; i < nreg; i++)
{
u128 reg_data;
memcpy(&reg_data, dump.data.get() + p, 16);
memcpy(&reg_data, data + p, 16);
ParseTreeReg(regId, GetBits<GIFReg>(regs, i * 4, 4), reg_data, true);
p += 16;
}
@ -511,7 +567,7 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
for (u32 i = 0; i < nreg; i++)
{
u128 reg_data;
memcpy(&reg_data.lo, dump.data.get() + p, 8);
memcpy(&reg_data.lo, data + p, 8);
reg_data.hi = 0;
ParseTreeReg(regId, GetBits<GIFReg>(regs, i * 4, 4), reg_data, false);
p += 8;
@ -524,28 +580,7 @@ void Dialogs::GSDumpDialog::GenPacketInfo(GSData& dump)
m_gif_packet->AppendItem(regId, wxString::Format("IMAGE %d bytes", nloop * 16));
break;
}
m_gif_packet->Expand(trootId);
m_gif_packet->Expand(regId);
break;
}
case GSType::VSync:
{
wxString s;
s.Printf("Field = %u", *(u8*)(dump.data.get()));
m_gif_packet->AppendItem(rootId, s);
break;
}
case GSType::ReadFIFO2:
{
wxString s;
s.Printf("ReadFIFO2: Size = %d byte", dump.length);
m_gif_packet->AppendItem(rootId, s);
break;
}
case GSType::Registers:
m_gif_packet->AppendItem(rootId, "Registers");
break;
}
}
void Dialogs::GSDumpDialog::ParsePacket(wxTreeEvent& event)

View File

@ -256,8 +256,10 @@ namespace Dialogs
float m_stored_q = 1.0;
void ProcessDumpEvent(const GSData& event, char* regs);
u32 ReadPacketSize(const void* packet);
void GenPacketList();
void GenPacketInfo(GSData& dump);
void ParseTransfer(wxTreeItemId& id, char* data);
void ParseTreeReg(wxTreeItemId& id, GIFReg reg, u128 data, bool packed);
void ParseTreePrim(wxTreeItemId& id, u32 prim);
void CloseDump(wxCommandEvent& event);