GS: Move privileged register dump to GSRenderer.cpp

This commit is contained in:
Stenzek 2023-12-23 00:44:10 +10:00 committed by Connor McLaughlin
parent 31e9206fc0
commit 0dd5e7c081
3 changed files with 111 additions and 117 deletions

View File

@ -1309,122 +1309,6 @@ struct GSPrivRegSet
u8 _pad17[0x1000];
};
void Dump(FILE* fp)
{
for (int i = 0; i < 2; i++)
{
if (!fp)
return;
if (i == 0 && !PMODE.EN1)
continue;
if (i == 1 && !PMODE.EN2)
continue;
fprintf(fp, "DISPFB[%d] BP=%05x BW=%u PSM=%u DBX=%u DBY=%u\n",
i,
DISP[i].DISPFB.Block(),
DISP[i].DISPFB.FBW,
DISP[i].DISPFB.PSM,
DISP[i].DISPFB.DBX,
DISP[i].DISPFB.DBY);
fprintf(fp, "DISPLAY[%d] DX=%u DY=%u DW=%u DH=%u MAGH=%u MAGV=%u\n",
i,
DISP[i].DISPLAY.DX,
DISP[i].DISPLAY.DY,
DISP[i].DISPLAY.DW,
DISP[i].DISPLAY.DH,
DISP[i].DISPLAY.MAGH,
DISP[i].DISPLAY.MAGV);
}
fprintf(fp, "PMODE EN1=%u EN2=%u CRTMD=%u MMOD=%u AMOD=%u SLBG=%u ALP=%u\n",
PMODE.EN1,
PMODE.EN2,
PMODE.CRTMD,
PMODE.MMOD,
PMODE.AMOD,
PMODE.SLBG,
PMODE.ALP);
fprintf(fp, "SMODE1 CLKSEL=%u CMOD=%u EX=%u GCONT=%u LC=%u NVCK=%u PCK2=%u PEHS=%u PEVS=%u PHS=%u PRST=%u PVS=%u RC=%u SINT=%u SLCK=%u SLCK2=%u SPML=%u T1248=%u VCKSEL=%u VHP=%u XPCK=%u\n",
SMODE1.CLKSEL,
SMODE1.CMOD,
SMODE1.EX,
SMODE1.GCONT,
SMODE1.LC,
SMODE1.NVCK,
SMODE1.PCK2,
SMODE1.PEHS,
SMODE1.PEVS,
SMODE1.PHS,
SMODE1.PRST,
SMODE1.PVS,
SMODE1.RC,
SMODE1.SINT,
SMODE1.SLCK,
SMODE1.SLCK2,
SMODE1.SPML,
SMODE1.T1248,
SMODE1.VCKSEL,
SMODE1.VHP,
SMODE1.XPCK);
fprintf(fp, "SMODE2 INT=%u FFMD=%u DPMS=%u\n",
SMODE2.INT,
SMODE2.FFMD,
SMODE2.DPMS);
fprintf(fp, "SRFSH %08x_%08x\n",
SRFSH.U32[0],
SRFSH.U32[1]);
fprintf(fp, "SYNCH1 %08x_%08x\n",
SYNCH1.U32[0],
SYNCH1.U32[1]);
fprintf(fp, "SYNCH2 %08x_%08x\n",
SYNCH2.U32[0],
SYNCH2.U32[1]);
fprintf(fp, "SYNCV VBP=%u VBPE=%u VDP=%u VFP=%u VFPE=%u VS=%u\n",
SYNCV.VBP,
SYNCV.VBPE,
SYNCV.VDP,
SYNCV.VFP,
SYNCV.VFPE,
SYNCV.VS);
fprintf(fp, "CSR %08x_%08x\n",
CSR.U32[0],
CSR.U32[1]);
fprintf(fp, "BGCOLOR B=%u G=%u R=%u\n",
BGCOLOR.B,
BGCOLOR.G,
BGCOLOR.R);
fprintf(fp, "EXTBUF BP=0x%x BW=%u FBIN=%u WFFMD=%u EMODA=%u EMODC=%u WDX=%u WDY=%u\n",
EXTBUF.EXBP, EXTBUF.EXBW, EXTBUF.FBIN, EXTBUF.WFFMD,
EXTBUF.EMODA, EXTBUF.EMODC, EXTBUF.WDX, EXTBUF.WDY);
fprintf(fp, "EXTDATA SX=%u SY=%u SMPH=%u SMPV=%u WW=%u WH=%u\n",
EXTDATA.SX, EXTDATA.SY, EXTDATA.SMPH, EXTDATA.SMPV, EXTDATA.WW, EXTDATA.WH);
fprintf(fp, "EXTWRITE EN=%u\n", EXTWRITE.WRITE);
}
void Dump(const std::string& filename)
{
FILE* fp = fopen(filename.c_str(), "wt");
if (fp)
{
Dump(fp);
fclose(fp);
}
}
};
#pragma pack(pop)

View File

@ -25,6 +25,7 @@
#include <immintrin.h>
#endif
#include <algorithm>
#include <cstring>
#ifdef _WIN32

View File

@ -44,6 +44,8 @@
#include <thread>
#include <mutex>
static void DumpGSPrivRegs(const GSPrivRegSet& r, const std::string& filename);
static constexpr std::array<PresentShader, 8> s_tv_shader_indices = {
PresentShader::COPY, PresentShader::SCANLINE,
PresentShader::DIAGONAL_FILTER, PresentShader::TRIANGULAR_FILTER,
@ -551,7 +553,7 @@ void GSRenderer::VSync(u32 field, bool registers_written, bool idle_frame)
{
if (GSConfig.DumpGSData && s_n >= GSConfig.SaveN)
{
m_regs->Dump(GetDrawDumpPath("vsync_%05d_f%lld_gs_reg.txt", s_n, g_perfmon.GetFrame()));
DumpGSPrivRegs(*m_regs, GetDrawDumpPath("vsync_%05d_f%lld_gs_reg.txt", s_n, g_perfmon.GetFrame()));
}
const int fb_sprite_blits = g_perfmon.GetDisplayFramebufferSpriteBlits();
@ -1031,3 +1033,110 @@ bool GSRenderer::SaveSnapshotToMemory(u32 window_width, u32 window_height, bool
pixels->clear();
return false;
}
void DumpGSPrivRegs(const GSPrivRegSet& r, const std::string& filename)
{
auto fp = FileSystem::OpenManagedCFile(filename.c_str(), "wt");
if (!fp)
return;
for (int i = 0; i < 2; i++)
{
if (i == 0 && !r.PMODE.EN1)
continue;
if (i == 1 && !r.PMODE.EN2)
continue;
std::fprintf(fp.get(), "DISPFB[%d] BP=%05x BW=%u PSM=%u DBX=%u DBY=%u\n",
i,
r.DISP[i].DISPFB.Block(),
r.DISP[i].DISPFB.FBW,
r.DISP[i].DISPFB.PSM,
r.DISP[i].DISPFB.DBX,
r.DISP[i].DISPFB.DBY);
std::fprintf(fp.get(), "DISPLAY[%d] DX=%u DY=%u DW=%u DH=%u MAGH=%u MAGV=%u\n",
i,
r.DISP[i].DISPLAY.DX,
r.DISP[i].DISPLAY.DY,
r.DISP[i].DISPLAY.DW,
r.DISP[i].DISPLAY.DH,
r.DISP[i].DISPLAY.MAGH,
r.DISP[i].DISPLAY.MAGV);
}
std::fprintf(fp.get(), "PMODE EN1=%u EN2=%u CRTMD=%u MMOD=%u AMOD=%u SLBG=%u ALP=%u\n",
r.PMODE.EN1,
r.PMODE.EN2,
r.PMODE.CRTMD,
r.PMODE.MMOD,
r.PMODE.AMOD,
r.PMODE.SLBG,
r.PMODE.ALP);
std::fprintf(fp.get(), "SMODE1 CLKSEL=%u CMOD=%u EX=%u GCONT=%u LC=%u NVCK=%u PCK2=%u PEHS=%u PEVS=%u PHS=%u PRST=%u PVS=%u RC=%u SINT=%u SLCK=%u SLCK2=%u SPML=%u T1248=%u VCKSEL=%u VHP=%u XPCK=%u\n",
r.SMODE1.CLKSEL,
r.SMODE1.CMOD,
r.SMODE1.EX,
r.SMODE1.GCONT,
r.SMODE1.LC,
r.SMODE1.NVCK,
r.SMODE1.PCK2,
r.SMODE1.PEHS,
r.SMODE1.PEVS,
r.SMODE1.PHS,
r.SMODE1.PRST,
r.SMODE1.PVS,
r.SMODE1.RC,
r.SMODE1.SINT,
r.SMODE1.SLCK,
r.SMODE1.SLCK2,
r.SMODE1.SPML,
r.SMODE1.T1248,
r.SMODE1.VCKSEL,
r.SMODE1.VHP,
r.SMODE1.XPCK);
std::fprintf(fp.get(), "SMODE2 INT=%u FFMD=%u DPMS=%u\n",
r.SMODE2.INT,
r.SMODE2.FFMD,
r.SMODE2.DPMS);
std::fprintf(fp.get(), "SRFSH %08x_%08x\n",
r.SRFSH.U32[0],
r.SRFSH.U32[1]);
std::fprintf(fp.get(), "SYNCH1 %08x_%08x\n",
r.SYNCH1.U32[0],
r.SYNCH1.U32[1]);
std::fprintf(fp.get(), "SYNCH2 %08x_%08x\n",
r.SYNCH2.U32[0],
r.SYNCH2.U32[1]);
std::fprintf(fp.get(), "SYNCV VBP=%u VBPE=%u VDP=%u VFP=%u VFPE=%u VS=%u\n",
r.SYNCV.VBP,
r.SYNCV.VBPE,
r.SYNCV.VDP,
r.SYNCV.VFP,
r.SYNCV.VFPE,
r.SYNCV.VS);
std::fprintf(fp.get(), "CSR %08x_%08x\n",
r.CSR.U32[0],
r.CSR.U32[1]);
std::fprintf(fp.get(), "BGCOLOR B=%u G=%u R=%u\n",
r.BGCOLOR.B,
r.BGCOLOR.G,
r.BGCOLOR.R);
std::fprintf(fp.get(), "EXTBUF BP=0x%x BW=%u FBIN=%u WFFMD=%u EMODA=%u EMODC=%u WDX=%u WDY=%u\n",
r.EXTBUF.EXBP, r.EXTBUF.EXBW, r.EXTBUF.FBIN, r.EXTBUF.WFFMD,
r.EXTBUF.EMODA, r.EXTBUF.EMODC, r.EXTBUF.WDX, r.EXTBUF.WDY);
std::fprintf(fp.get(), "EXTDATA SX=%u SY=%u SMPH=%u SMPV=%u WW=%u WH=%u\n",
r.EXTDATA.SX, r.EXTDATA.SY, r.EXTDATA.SMPH, r.EXTDATA.SMPV, r.EXTDATA.WW, r.EXTDATA.WH);
std::fprintf(fp.get(), "EXTWRITE EN=%u\n", r.EXTWRITE.WRITE);
}