From 22ebdcf1cfe0bb45d7a837059cc64a1fbc81787e Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 8 Oct 2016 16:53:44 +0200 Subject: [PATCH] gsdx debug: create a nice dump function for kernel gs registers Add missing register --- plugins/GSdx/GS.h | 129 ++++++++++++++++++++++++++++++++-- plugins/GSdx/GSRenderer.cpp | 5 ++ plugins/GSdx/GSRendererSW.cpp | 90 +----------------------- 3 files changed, 131 insertions(+), 93 deletions(-) diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index a64a24a4c9..2a2867335e 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -1225,10 +1225,10 @@ struct GSPrivRegSet GSRegSYNCV SYNCV; uint64 _pad7; struct { - GSRegDISPFB DISPFB; - uint64 _pad1; - GSRegDISPLAY DISPLAY; - uint64 _pad2; + GSRegDISPFB DISPFB; + uint64 _pad1; + GSRegDISPLAY DISPLAY; + uint64 _pad2; } DISP[2]; GSRegEXTBUF EXTBUF; uint64 _pad8; @@ -1261,6 +1261,127 @@ struct GSPrivRegSet uint8 _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=%d PSM=%d DBX=%d DBY=%d\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=%d DY=%d DW=%d DH=%d MAGH=%d MAGV=%d\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 %08x_%08x\n", + SYNCV.u32[0], + SYNCV.u32[1] + ); + + 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) diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 4f9c9bb759..67ac0c71b7 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -349,6 +349,11 @@ void GSRenderer::VSync(int field) Flush(); + if(s_n >= s_saven) + { + m_regs->Dump(root_sw + format("%05d_f%lld_gs_reg.txt", s_n, m_perfmon.GetFrame())); + } + if(!m_dev->IsLost(true)) { if(!Merge(field ? 1 : 0)) diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index 50d8e9e8f1..cf18b69bd0 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -119,95 +119,7 @@ void GSRendererSW::VSync(int field) dr.x, dr.y, dr.z, dr.w, fr.x, fr.y, fr.z, fr.w); - for(int i = 0; i < 2; i++) - { - if(i == 0 && !m_regs->PMODE.EN1) continue; - if(i == 1 && !m_regs->PMODE.EN2) continue; - - fprintf(s_fp, "DISPFB[%d] BP=%05x BW=%d PSM=%d DBX=%d DBY=%d\n", - i, - m_regs->DISP[i].DISPFB.Block(), - m_regs->DISP[i].DISPFB.FBW, - m_regs->DISP[i].DISPFB.PSM, - m_regs->DISP[i].DISPFB.DBX, - m_regs->DISP[i].DISPFB.DBY - ); - - fprintf(s_fp, "DISPLAY[%d] DX=%d DY=%d DW=%d DH=%d MAGH=%d MAGV=%d\n", - i, - m_regs->DISP[i].DISPLAY.DX, - m_regs->DISP[i].DISPLAY.DY, - m_regs->DISP[i].DISPLAY.DW, - m_regs->DISP[i].DISPLAY.DH, - m_regs->DISP[i].DISPLAY.MAGH, - m_regs->DISP[i].DISPLAY.MAGV - ); - } - - fprintf(s_fp, "PMODE EN1=%u EN2=%u CRTMD=%u MMOD=%u AMOD=%u SLBG=%u ALP=%u\n", - m_regs->PMODE.EN1, - m_regs->PMODE.EN2, - m_regs->PMODE.CRTMD, - m_regs->PMODE.MMOD, - m_regs->PMODE.AMOD, - m_regs->PMODE.SLBG, - m_regs->PMODE.ALP - ); - - fprintf(s_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", - m_regs->SMODE1.CLKSEL, - m_regs->SMODE1.CMOD, - m_regs->SMODE1.EX, - m_regs->SMODE1.GCONT, - m_regs->SMODE1.LC, - m_regs->SMODE1.NVCK, - m_regs->SMODE1.PCK2, - m_regs->SMODE1.PEHS, - m_regs->SMODE1.PEVS, - m_regs->SMODE1.PHS, - m_regs->SMODE1.PRST, - m_regs->SMODE1.PVS, - m_regs->SMODE1.RC, - m_regs->SMODE1.SINT, - m_regs->SMODE1.SLCK, - m_regs->SMODE1.SLCK2, - m_regs->SMODE1.SPML, - m_regs->SMODE1.T1248, - m_regs->SMODE1.VCKSEL, - m_regs->SMODE1.VHP, - m_regs->SMODE1.XPCK - ); - - fprintf(s_fp, "SMODE2 INT=%u FFMD=%u DPMS=%u\n", - m_regs->SMODE2.INT, - m_regs->SMODE2.FFMD, - m_regs->SMODE2.DPMS - ); - - fprintf(s_fp, "SRFSH %08x_%08x\n", - m_regs->SRFSH.u32[0], - m_regs->SRFSH.u32[1] - ); - - fprintf(s_fp, "SYNCH1 %08x_%08x\n", - m_regs->SYNCH1.u32[0], - m_regs->SYNCH1.u32[1] - ); - - fprintf(s_fp, "SYNCH2 %08x_%08x\n", - m_regs->SYNCH2.u32[0], - m_regs->SYNCH2.u32[1] - ); - - fprintf(s_fp, "SYNCV %08x_%08x\n", - m_regs->SYNCV.u32[0], - m_regs->SYNCV.u32[1] - ); - - fprintf(s_fp, "CSR %08x_%08x\n", - m_regs->CSR.u32[0], - m_regs->CSR.u32[1] - ); + m_regs->Dump(s_fp); fflush(s_fp); }