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
This commit is contained in:
donkopunchstania
2011-03-27 02:55:08 +00:00
parent f8037e3ccf
commit 07c4da6084
35 changed files with 3275 additions and 6 deletions

View File

@ -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

View File

@ -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()

View File

@ -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);

View File

@ -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();

View File

@ -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;
};

View File

@ -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++)