Merge pull request #4077 from lioncash/const

FifoPlayer: const correctness
This commit is contained in:
Pierre Bourdon 2016-08-02 01:04:29 +02:00 committed by GitHub
commit 84c936cab8
7 changed files with 19 additions and 18 deletions

View File

@ -145,7 +145,7 @@ std::unique_ptr<CPUCoreBase> FifoPlayer::GetCPUCore()
return std::make_unique<CPUCore>(this); return std::make_unique<CPUCore>(this);
} }
u32 FifoPlayer::GetFrameObjectCount() u32 FifoPlayer::GetFrameObjectCount() const
{ {
if (m_CurrentFrame < m_FrameInfo.size()) if (m_CurrentFrame < m_FrameInfo.size())
{ {
@ -413,7 +413,7 @@ void FifoPlayer::LoadMemory()
SetupFifo(); SetupFifo();
u32* regs = m_File->GetBPMem(); const u32* regs = m_File->GetBPMem();
for (int i = 0; i < FifoDataFile::BP_MEM_SIZE; ++i) for (int i = 0; i < FifoDataFile::BP_MEM_SIZE; ++i)
{ {
if (ShouldLoadBP(i)) if (ShouldLoadBP(i))
@ -494,7 +494,7 @@ void FifoPlayer::LoadXFReg(u16 reg, u32 value)
GPFifo::Write32(value); GPFifo::Write32(value);
} }
void FifoPlayer::LoadXFMem16(u16 address, u32* data) void FifoPlayer::LoadXFMem16(u16 address, const u32* data)
{ {
// Loads 16 * 4 bytes in xf memory starting at address // Loads 16 * 4 bytes in xf memory starting at address
GPFifo::Write8(0x10); // load XF reg GPFifo::Write8(0x10); // load XF reg

View File

@ -65,8 +65,8 @@ public:
// PowerPC state. // PowerPC state.
std::unique_ptr<CPUCoreBase> GetCPUCore(); std::unique_ptr<CPUCoreBase> GetCPUCore();
FifoDataFile* GetFile() { return m_File.get(); } FifoDataFile* GetFile() const { return m_File.get(); }
u32 GetFrameObjectCount(); u32 GetFrameObjectCount() const;
u32 GetCurrentFrameNum() const { return m_CurrentFrame; } u32 GetCurrentFrameNum() const { return m_CurrentFrame; }
const AnalyzedFrameInfo& GetAnalyzedFrameInfo(u32 frame) const { return m_FrameInfo[frame]; } const AnalyzedFrameInfo& GetAnalyzedFrameInfo(u32 frame) const { return m_FrameInfo[frame]; }
// Frame range // Frame range
@ -119,7 +119,7 @@ private:
void LoadBPReg(u8 reg, u32 value); void LoadBPReg(u8 reg, u32 value);
void LoadCPReg(u8 reg, u32 value); void LoadCPReg(u8 reg, u32 value);
void LoadXFReg(u16 reg, u32 value); void LoadXFReg(u16 reg, u32 value);
void LoadXFMem16(u16 address, u32* data); void LoadXFMem16(u16 address, const u32* data);
bool ShouldLoadBP(u8 address); bool ShouldLoadBP(u8 address);

View File

@ -13,7 +13,7 @@
using namespace FifoAnalyzer; using namespace FifoAnalyzer;
void FifoRecordAnalyzer::Initialize(u32* cpMem) void FifoRecordAnalyzer::Initialize(const u32* cpMem)
{ {
s_DrawingObject = false; s_DrawingObject = false;

View File

@ -9,7 +9,7 @@
namespace FifoRecordAnalyzer namespace FifoRecordAnalyzer
{ {
// Must call this before analyzing Fifo commands with FifoAnalyzer::AnalyzeCommand() // Must call this before analyzing Fifo commands with FifoAnalyzer::AnalyzeCommand()
void Initialize(u32* cpMem); void Initialize(const u32* cpMem);
void ProcessLoadIndexedXf(u32 val, int array); void ProcessLoadIndexedXf(u32 val, int array);
void WriteVertexArray(int arrayIndex, const u8* vertexData, int vertexSize, int numVertices); void WriteVertexArray(int arrayIndex, const u8* vertexData, int vertexSize, int numVertices);

View File

@ -59,7 +59,7 @@ void FifoRecorder::StopRecording()
m_RequestedRecordingEnd = true; m_RequestedRecordingEnd = true;
} }
void FifoRecorder::WriteGPCommand(u8* data, u32 size) void FifoRecorder::WriteGPCommand(const u8* data, u32 size)
{ {
if (!m_SkipNextData) if (!m_SkipNextData)
{ {
@ -181,7 +181,8 @@ void FifoRecorder::EndFrame(u32 fifoStart, u32 fifoEnd)
} }
} }
void FifoRecorder::SetVideoMemory(u32* bpMem, u32* cpMem, u32* xfMem, u32* xfRegs, u32 xfRegsSize) void FifoRecorder::SetVideoMemory(const u32* bpMem, const u32* cpMem, const u32* xfMem,
const u32* xfRegs, u32 xfRegsSize)
{ {
std::lock_guard<std::recursive_mutex> lk(sMutex); std::lock_guard<std::recursive_mutex> lk(sMutex);

View File

@ -19,11 +19,11 @@ public:
void StartRecording(s32 numFrames, CallbackFunc finishedCb); void StartRecording(s32 numFrames, CallbackFunc finishedCb);
void StopRecording(); void StopRecording();
FifoDataFile* GetRecordedFile() { return m_File; } FifoDataFile* GetRecordedFile() const { return m_File; }
// Called from video thread // Called from video thread
// Must write one full GP command at a time // Must write one full GP command at a time
void WriteGPCommand(u8* data, u32 size); void WriteGPCommand(const u8* data, u32 size);
// Track memory that has been used and write it to the fifolog if it has changed. // Track memory that has been used and write it to the fifolog if it has changed.
// If memory is updated by the video backend (dynamicUpdate == true) take special care to make // If memory is updated by the video backend (dynamicUpdate == true) take special care to make
@ -36,7 +36,8 @@ public:
// This function must be called before writing GP commands // This function must be called before writing GP commands
// bpMem must point to the actual bp mem array used by the plugin because it will be read as fifo // bpMem must point to the actual bp mem array used by the plugin because it will be read as fifo
// data is recorded // data is recorded
void SetVideoMemory(u32* bpMem, u32* cpMem, u32* xfMem, u32* xfRegs, u32 xfRegsSize); void SetVideoMemory(const u32* bpMem, const u32* cpMem, const u32* xfMem, const u32* xfRegs,
u32 xfRegsSize);
// Checked once per frame prior to callng EndFrame() // Checked once per frame prior to callng EndFrame()
bool IsRecording() const { return m_IsRecording; } bool IsRecording() const { return m_IsRecording; }

View File

@ -597,15 +597,14 @@ void Renderer::CheckFifoRecording()
void Renderer::RecordVideoMemory() void Renderer::RecordVideoMemory()
{ {
u32* bpmem_ptr = (u32*)&bpmem; const u32* bpmem_ptr = reinterpret_cast<const u32*>(&bpmem);
u32 cpmem[256]; u32 cpmem[256] = {};
// The FIFO recording format splits XF memory into xfmem and xfregs; follow // The FIFO recording format splits XF memory into xfmem and xfregs; follow
// that split here. // that split here.
u32* xfmem_ptr = (u32*)&xfmem; const u32* xfmem_ptr = reinterpret_cast<const u32*>(&xfmem);
u32* xfregs_ptr = (u32*)&xfmem + FifoDataFile::XF_MEM_SIZE; const u32* xfregs_ptr = reinterpret_cast<const u32*>(&xfmem) + FifoDataFile::XF_MEM_SIZE;
u32 xfregs_size = sizeof(XFMemory) / 4 - FifoDataFile::XF_MEM_SIZE; u32 xfregs_size = sizeof(XFMemory) / 4 - FifoDataFile::XF_MEM_SIZE;
memset(cpmem, 0, 256 * 4);
FillCPMemoryArray(cpmem); FillCPMemoryArray(cpmem);
FifoRecorder::GetInstance().SetVideoMemory(bpmem_ptr, cpmem, xfmem_ptr, xfregs_ptr, xfregs_size); FifoRecorder::GetInstance().SetVideoMemory(bpmem_ptr, cpmem, xfmem_ptr, xfregs_ptr, xfregs_size);