diff options
| author | donkopunchstania <donkopunchstania@gmail.com> | 2011-03-27 02:55:08 +0000 |
|---|---|---|
| committer | donkopunchstania <donkopunchstania@gmail.com> | 2011-03-27 02:55:08 +0000 |
| commit | 07c4da6084e6d87cf25f87868da10c068721c19f (patch) | |
| tree | 5fbbd3476f80cfdb891e8c1f2cbeac86ec85c8b5 /Source/Core/VideoCommon | |
| parent | f8037e3ccf7723c2c02f7cfae74128561e304727 (diff) | |
Add graphics FIFO recorder and player for debugging the graphics system.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7414 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/CPMemory.h | 3 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpcodeDecoding.cpp | 14 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/OpcodeDecoding.h | 3 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/RenderBase.cpp | 46 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/RenderBase.h | 5 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexLoaderManager.cpp | 21 |
6 files changed, 92 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/Src/CPMemory.h b/Source/Core/VideoCommon/Src/CPMemory.h index c7de2afc6d..c4a24ba7a4 100644 --- a/Source/Core/VideoCommon/Src/CPMemory.h +++ b/Source/Core/VideoCommon/Src/CPMemory.h @@ -262,4 +262,7 @@ extern VAT g_VtxAttr[8]; // Might move this into its own file later. void LoadCPReg(u32 SubCmd, u32 Value); +// Fills memory with data from CP regs +void FillCPMemoryArray(u32 *memory); + #endif // _CPMEMORY_H diff --git a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp index 6d939882e7..18d6726ae3 100644 --- a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp @@ -33,6 +33,7 @@ #include "Core.h" #include "Host.h" #include "HW/Memmap.h" +#include "FifoPlayer/FifoRecorder.h" #include "VertexLoaderManager.h" @@ -50,6 +51,8 @@ #include "VideoConfig.h" u8* g_pVideoData = 0; +bool g_bRecordFifoData = false; + #if _M_SSE >= 0x301 DataReadU32xNfunc DataReadU32xFuncs_SSSE3[16] = { DataReadU32xN_SSSE3<1>, @@ -254,6 +257,8 @@ bool FifoCommandRunnable() static void Decode() { + u8 *opcodeStart = g_pVideoData; + int cmd_byte = DataReadU8(); switch (cmd_byte) { @@ -338,10 +343,16 @@ static void Decode() } break; } + + // Display lists get added directly into the FIFO stream + if (g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL) + FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, g_pVideoData - opcodeStart); } static void DecodeSemiNop() { + u8 *opcodeStart = g_pVideoData; + int cmd_byte = DataReadU8(); switch (cmd_byte) { @@ -416,6 +427,9 @@ static void DecodeSemiNop() } break; } + + if (g_bRecordFifoData && cmd_byte != GX_CMD_CALL_DL) + FifoRecorder::GetInstance().WriteGPCommand(opcodeStart, g_pVideoData - opcodeStart); } void OpcodeDecoder_Init() diff --git a/Source/Core/VideoCommon/Src/OpcodeDecoding.h b/Source/Core/VideoCommon/Src/OpcodeDecoding.h index 9989f0fd24..f2e9cd1321 100644 --- a/Source/Core/VideoCommon/Src/OpcodeDecoding.h +++ b/Source/Core/VideoCommon/Src/OpcodeDecoding.h @@ -45,6 +45,9 @@ #define GX_DRAW_LINE_STRIP 0x6 // 0xB0 #define GX_DRAW_POINTS 0x7 // 0xB8 #define GX_DRAW_NONE 0x1; //Tis is a fake value to used in the backends + +extern bool g_bRecordFifoData; + void OpcodeDecoder_Init(); void OpcodeDecoder_Shutdown(); void OpcodeDecoder_Run(bool skipped_frame); diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp index c7b18e509c..9029f5eff9 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.cpp +++ b/Source/Core/VideoCommon/Src/RenderBase.cpp @@ -28,14 +28,20 @@ #include "RenderBase.h" #include "Atomic.h" +#include "BPMemory.h" +#include "CommandProcessor.h" +#include "CPMemory.h" #include "MainBase.h" #include "VideoConfig.h" #include "FramebufferManagerBase.h" #include "TextureCacheBase.h" #include "Fifo.h" +#include "OpcodeDecoding.h" #include "Timer.h" #include "StringUtil.h" #include "Host.h" +#include "XFMemory.h" +#include "FifoPlayer/FifoRecorder.h" #include <cmath> #include <string> @@ -75,6 +81,7 @@ int Renderer::s_LastEFBScale; bool Renderer::s_skipSwap; bool Renderer::XFBWrited; +bool Renderer::s_EnableDLCachingAfterRecording; unsigned int Renderer::prev_efb_format = (unsigned int)-1; @@ -91,6 +98,8 @@ Renderer::~Renderer() void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc, float Gamma) { + CheckFifoRecording(); + if (!fbWidth || !fbHeight) return; @@ -332,6 +341,43 @@ void Renderer::SetWindowSize(int width, int height) Host_RequestRenderWindowSize(width, height); } +void Renderer::CheckFifoRecording() +{ + bool wasRecording = g_bRecordFifoData; + g_bRecordFifoData = FifoRecorder::GetInstance().IsRecording(); + + if (g_bRecordFifoData) + { + if (!wasRecording) + { + // Disable display list caching because the recorder does not handle it + s_EnableDLCachingAfterRecording = g_ActiveConfig.bDlistCachingEnable; + g_ActiveConfig.bDlistCachingEnable = false; + + RecordVideoMemory(); + } + + FifoRecorder::GetInstance().EndFrame(CommandProcessor::fifo.CPBase, CommandProcessor::fifo.CPEnd); + } + else if (wasRecording) + { + g_ActiveConfig.bDlistCachingEnable = s_EnableDLCachingAfterRecording; + } +} + +void Renderer::RecordVideoMemory() +{ + u32 *bpMem = (u32*)&bpmem; + u32 cpMem[256]; + u32 *xfMem = (u32*)xfmem; + u32 *xfRegs = (u32*)&xfregs; + + memset(cpMem, 0, 256 * 4); + FillCPMemoryArray(cpMem); + + FifoRecorder::GetInstance().SetVideoMemory(bpMem, cpMem, xfMem, xfRegs, sizeof(XFRegisters) / 4); +} + void UpdateViewport() { g_renderer->UpdateViewport(); diff --git a/Source/Core/VideoCommon/Src/RenderBase.h b/Source/Core/VideoCommon/Src/RenderBase.h index 9872200688..98f32c443c 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.h +++ b/Source/Core/VideoCommon/Src/RenderBase.h @@ -151,6 +151,9 @@ protected: static bool CalculateTargetSize(int multiplier = 1); static void CalculateXYScale(const TargetRectangle& dst_rect); + static void CheckFifoRecording(); + static void RecordVideoMemory(); + static volatile bool s_bScreenshot; // The framebuffer size @@ -178,6 +181,8 @@ protected: static bool s_skipSwap; static bool XFBWrited; + static bool s_EnableDLCachingAfterRecording; + private: static unsigned int prev_efb_format; }; diff --git a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp index 564892cb98..316941a639 100644 --- a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp @@ -214,6 +214,27 @@ void LoadCPReg(u32 sub_cmd, u32 value) } } +void FillCPMemoryArray(u32 *memory) +{ + memory[0x30] = MatrixIndexA.Hex; + memory[0x40] = MatrixIndexB.Hex; + memory[0x50] = (u32)g_VtxDesc.Hex; + memory[0x60] = (u32)(g_VtxDesc.Hex >> 17); + + for (int i = 0; i < 8; ++i) + { + memory[0x70 + i] = g_VtxAttr[i].g0.Hex; + memory[0x80 + i] = g_VtxAttr[i].g1.Hex; + memory[0x90 + i] = g_VtxAttr[i].g2.Hex; + } + + for (int i = 0; i < 16; ++i) + { + memory[0xA0 + i] = arraybases[i]; + memory[0xB0 + i] = arraystrides[i]; + } +} + void RecomputeCachedArraybases() { for (int i = 0; i < 16; i++) |
