FifoDataFile: Convert FifoFrameInfo's fifoData member into a vector

This commit is contained in:
Lioncash 2016-06-28 22:25:22 -04:00
parent 437b1294bb
commit 396ae89e5c
11 changed files with 27 additions and 36 deletions

View File

@ -27,30 +27,30 @@ void Init()
VertexLoader_Normal::Init();
}
u8 ReadFifo8(u8*& data)
u8 ReadFifo8(const u8*& data)
{
u8 value = data[0];
data += 1;
return value;
}
u16 ReadFifo16(u8*& data)
u16 ReadFifo16(const u8*& data)
{
u16 value = Common::swap16(data);
data += 2;
return value;
}
u32 ReadFifo32(u8*& data)
u32 ReadFifo32(const u8*& data)
{
u32 value = Common::swap32(data);
data += 4;
return value;
}
u32 AnalyzeCommand(u8* data, DecodeMode mode)
u32 AnalyzeCommand(const u8* data, DecodeMode mode)
{
u8* dataStart = data;
const u8* dataStart = data;
int cmd = ReadFifo8(data);

View File

@ -13,9 +13,9 @@ namespace FifoAnalyzer
{
void Init();
u8 ReadFifo8(u8*& data);
u16 ReadFifo16(u8*& data);
u32 ReadFifo32(u8*& data);
u8 ReadFifo8(const u8*& data);
u16 ReadFifo16(const u8*& data);
u32 ReadFifo32(const u8*& data);
enum DecodeMode
{
@ -23,7 +23,7 @@ enum DecodeMode
DECODE_PLAYBACK,
};
u32 AnalyzeCommand(u8* data, DecodeMode mode);
u32 AnalyzeCommand(const u8* data, DecodeMode mode);
struct CPMemory
{

View File

@ -18,10 +18,6 @@ FifoDataFile::FifoDataFile() : m_Flags(0)
FifoDataFile::~FifoDataFile()
{
for (auto& frame : m_Frames)
{
delete[] frame.fifoData;
}
}
bool FifoDataFile::HasBrokenEFBCopies() const
@ -103,17 +99,17 @@ bool FifoDataFile::Save(const std::string& filename)
// Write FIFO data
file.Seek(0, SEEK_END);
u64 dataOffset = file.Tell();
file.WriteBytes(srcFrame.fifoData, srcFrame.fifoDataSize);
file.WriteBytes(srcFrame.fifoData.data(), srcFrame.fifoData.size());
u64 memoryUpdatesOffset = WriteMemoryUpdates(srcFrame.memoryUpdates, file);
FileFrameInfo dstFrame;
dstFrame.fifoDataSize = srcFrame.fifoDataSize;
dstFrame.fifoDataSize = static_cast<u32>(srcFrame.fifoData.size());
dstFrame.fifoDataOffset = dataOffset;
dstFrame.fifoStart = srcFrame.fifoStart;
dstFrame.fifoEnd = srcFrame.fifoEnd;
dstFrame.memoryUpdatesOffset = memoryUpdatesOffset;
dstFrame.numMemoryUpdates = (u32)srcFrame.memoryUpdates.size();
dstFrame.numMemoryUpdates = static_cast<u32>(srcFrame.memoryUpdates.size());
// Write frame info
u64 frameOffset = frameListOffset + (i * sizeof(FileFrameInfo));
@ -179,13 +175,12 @@ std::unique_ptr<FifoDataFile> FifoDataFile::Load(const std::string& filename, bo
file.ReadBytes(&srcFrame, sizeof(FileFrameInfo));
FifoFrameInfo dstFrame;
dstFrame.fifoData = new u8[srcFrame.fifoDataSize];
dstFrame.fifoDataSize = srcFrame.fifoDataSize;
dstFrame.fifoData.resize(srcFrame.fifoDataSize);
dstFrame.fifoStart = srcFrame.fifoStart;
dstFrame.fifoEnd = srcFrame.fifoEnd;
file.Seek(srcFrame.fifoDataOffset, SEEK_SET);
file.ReadBytes(dstFrame.fifoData, srcFrame.fifoDataSize);
file.ReadBytes(dstFrame.fifoData.data(), srcFrame.fifoDataSize);
ReadMemoryUpdates(srcFrame.memoryUpdatesOffset, srcFrame.numMemoryUpdates,
dstFrame.memoryUpdates, file);

View File

@ -33,8 +33,7 @@ struct MemoryUpdate
struct FifoFrameInfo
{
u8* fifoData;
u32 fifoDataSize;
std::vector<u8> fifoData;
u32 fifoStart;
u32 fifoEnd;

View File

@ -19,7 +19,7 @@ struct CmdData
{
u32 size;
u32 offset;
u8* ptr;
const u8* ptr;
};
void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
@ -51,10 +51,10 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
#if LOG_FIFO_CMDS
// Debugging
vector<CmdData> prevCmds;
std::vector<CmdData> prevCmds;
#endif
while (cmdStart < frame.fifoDataSize)
while (cmdStart < frame.fifoData.size())
{
// Add memory updates that have occurred before this point in the frame
while (nextMemUpdate < frame.memoryUpdates.size() &&

View File

@ -207,7 +207,7 @@ void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo&
// Core timing information
m_CyclesPerFrame = SystemTimers::GetTicksPerSecond() / VideoInterface::GetTargetRefreshRate();
m_ElapsedCycles = 0;
m_FrameFifoSize = frame.fifoDataSize;
m_FrameFifoSize = static_cast<u32>(frame.fifoData.size());
// Determine start and end objects
u32 numObjects = (u32)(info.objectStarts.size());
@ -256,7 +256,7 @@ void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo&
}
// Write data after the last object
WriteFramePart(position, frame.fifoDataSize, memoryUpdate, frame, info);
WriteFramePart(position, static_cast<u32>(frame.fifoData.size()), memoryUpdate, frame, info);
FlushWGP();
@ -271,7 +271,7 @@ void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo&
void FifoPlayer::WriteFramePart(u32 dataStart, u32 dataEnd, u32& nextMemUpdate,
const FifoFrameInfo& frame, const AnalyzedFrameInfo& info)
{
u8* data = frame.fifoData;
const u8* const data = frame.fifoData.data();
while (nextMemUpdate < frame.memoryUpdates.size() && dataStart < dataEnd)
{
@ -326,7 +326,7 @@ void FifoPlayer::WriteMemory(const MemoryUpdate& memUpdate)
std::copy(memUpdate.data.begin(), memUpdate.data.end(), mem);
}
void FifoPlayer::WriteFifo(u8* data, u32 start, u32 end)
void FifoPlayer::WriteFifo(const u8* data, u32 start, u32 end)
{
u32 written = start;
u32 lastBurstEnd = end - 1;

View File

@ -104,7 +104,7 @@ private:
// writes a range of data to the fifo
// start and end must be relative to frame's fifo data so elapsed cycles are figured correctly
void WriteFifo(u8* data, u32 start, u32 end);
void WriteFifo(const u8* data, u32 start, u32 end);
void SetupFifo();

View File

@ -38,7 +38,7 @@ void FifoRecordAnalyzer::ProcessLoadIndexedXf(u32 val, int array)
FifoRecorder::GetInstance().UseMemory(address, size * 4, MemoryUpdate::XF_DATA);
}
void FifoRecordAnalyzer::WriteVertexArray(int arrayIndex, u8* vertexData, int vertexSize,
void FifoRecordAnalyzer::WriteVertexArray(int arrayIndex, const u8* vertexData, int vertexSize,
int numVertices)
{
// Skip if not indexed array

View File

@ -16,5 +16,5 @@ namespace FifoRecordAnalyzer
void Initialize(u32* cpMem);
void ProcessLoadIndexedXf(u32 val, int array);
void WriteVertexArray(int arrayIndex, u8* vertexData, int vertexSize, int numVertices);
void WriteVertexArray(int arrayIndex, const u8* vertexData, int vertexSize, int numVertices);
};

View File

@ -78,10 +78,7 @@ void FifoRecorder::WriteGPCommand(u8* data, u32 size)
if (m_FrameEnded && m_FifoData.size() > 0)
{
size_t dataSize = m_FifoData.size();
m_CurrentFrame.fifoDataSize = (u32)dataSize;
m_CurrentFrame.fifoData = new u8[dataSize];
memcpy(m_CurrentFrame.fifoData, m_FifoData.data(), dataSize);
m_CurrentFrame.fifoData = m_FifoData;
{
std::lock_guard<std::recursive_mutex> lk(sMutex);

View File

@ -928,7 +928,7 @@ wxString FifoPlayerDlg::CreateRecordingFifoSizeLabel() const
{
size_t fifoBytes = 0;
for (size_t i = 0; i < file->GetFrameCount(); ++i)
fifoBytes += file->GetFrame(i).fifoDataSize;
fifoBytes += file->GetFrame(i).fifoData.size();
return wxString::Format(_("%zu FIFO bytes"), fifoBytes);
}