FifoAnalyzer: Remove old code that was meant to handle EFB copies

It wasn't working, I'm not really sure why.
Since #2997 we rely on video common to mark efb copies 'written'
during recording, and for old dffs we just ignore the bad texture
while playing back in the texture cache.
This commit is contained in:
Scott Mansell 2015-11-08 17:03:05 +13:00
parent 0367c3107d
commit 9872f5b518
4 changed files with 1 additions and 198 deletions

View File

@ -20,7 +20,6 @@ namespace FifoAnalyzer
{
bool s_DrawingObject;
BPMemory s_BpMem;
FifoAnalyzer::CPMemory s_CpMem;
void Init()
@ -109,18 +108,6 @@ u32 AnalyzeCommand(u8* data, DecodeMode mode)
{
s_DrawingObject = false;
u32 cmd2 = ReadFifo32(data);
if (mode == DECODE_PLAYBACK)
{
BPCmd bp = DecodeBPCmd(cmd2, s_BpMem);
LoadBPReg(bp, s_BpMem);
if (bp.address == BPMEM_TRIGGER_EFB_COPY)
{
FifoPlaybackAnalyzer::StoreEfbCopyRegion();
}
}
break;
}
@ -172,28 +159,6 @@ void InitBPMemory(BPMemory* bpMem)
bpMem->bpMask = 0x00FFFFFF;
}
BPCmd DecodeBPCmd(u32 value, const BPMemory& bpMem)
{
//handle the mask register
int opcode = value >> 24;
int oldval = ((u32*)&bpMem)[opcode];
int newval = (oldval & ~bpMem.bpMask) | (value & bpMem.bpMask);
int changes = (oldval ^ newval) & 0xFFFFFF;
BPCmd bp = {opcode, changes, newval};
return bp;
}
void LoadBPReg(const BPCmd& bp, BPMemory& bpMem)
{
((u32*)&bpMem)[bp.address] = bp.newvalue;
//reset the mask register
if (bp.address != 0xFE)
bpMem.bpMask = 0xFFFFFF;
}
void LoadCPReg(u32 subCmd, u32 value, CPMemory& cpMem)
{
switch (subCmd & 0xF0)

View File

@ -25,11 +25,6 @@ namespace FifoAnalyzer
u32 AnalyzeCommand(u8* data, DecodeMode mode);
// TODO- move to video common
void InitBPMemory(BPMemory* bpMem);
BPCmd DecodeBPCmd(u32 value, const BPMemory &bpMem);
void LoadBPReg(const BPCmd& bp, BPMemory &bpMem);
struct CPMemory
{
TVtxDesc vtxDesc;
@ -43,6 +38,5 @@ namespace FifoAnalyzer
void CalculateVertexElementSizes(int sizes[], int vatIndex, const CPMemory& cpMem);
extern bool s_DrawingObject;
extern BPMemory s_BpMem;
extern FifoAnalyzer::CPMemory s_CpMem;
}

View File

@ -22,23 +22,8 @@ struct CmdData
u8* ptr;
};
struct MemoryRange
{
u32 begin;
u32 end;
};
static std::vector<MemoryRange> s_WrittenMemory;
static void AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo& frameInfo);
static void StoreWrittenRegion(u32 address, u32 size);
void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file, std::vector<AnalyzedFrameInfo>& frameInfo)
{
// Load BP memory
u32* bpMem = file->GetBPMem();
memcpy(&s_BpMem, bpMem, sizeof(BPMemory));
u32* cpMem = file->GetCPMem();
FifoAnalyzer::LoadCPReg(0x50, cpMem[0x50], s_CpMem);
FifoAnalyzer::LoadCPReg(0x60, cpMem[0x60], s_CpMem);
@ -73,7 +58,7 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file, std::vector<Analyze
// Add memory updates that have occurred before this point in the frame
while (nextMemUpdate < frame.memoryUpdates.size() && frame.memoryUpdates[nextMemUpdate].fifoPosition <= cmdStart)
{
AddMemoryUpdate(frame.memoryUpdates[nextMemUpdate], analyzed);
analyzed.memoryUpdates.push_back(frame.memoryUpdates[nextMemUpdate]);
++nextMemUpdate;
}
@ -114,142 +99,3 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file, std::vector<Analyze
analyzed.objectEnds.push_back(cmdStart);
}
}
static void AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo& frameInfo)
{
u32 begin = memUpdate.address;
u32 end = memUpdate.address + memUpdate.size;
// Remove portions of memUpdate that overlap with memory ranges that have been written by the GP
for (const auto& range : s_WrittenMemory)
{
if (range.begin < end &&
range.end > begin)
{
s32 preSize = range.begin - begin;
s32 postSize = end - range.end;
if (postSize > 0)
{
if (preSize > 0)
{
memUpdate.size = preSize;
AddMemoryUpdate(memUpdate, frameInfo);
}
u32 bytesToRangeEnd = range.end - memUpdate.address;
memUpdate.data += bytesToRangeEnd;
memUpdate.size = postSize;
memUpdate.address = range.end;
}
else if (preSize > 0)
{
memUpdate.size = preSize;
}
else
{
// Ignore all of memUpdate
return;
}
}
}
frameInfo.memoryUpdates.push_back(memUpdate);
}
void FifoPlaybackAnalyzer::StoreEfbCopyRegion()
{
UPE_Copy peCopy = s_BpMem.triggerEFBCopy;
u32 copyfmt = peCopy.tp_realFormat();
bool bFromZBuffer = s_BpMem.zcontrol.pixel_format == PEControl::Z24;
u32 address = bpmem.copyTexDest << 5;
u32 format = copyfmt;
if (peCopy.copy_to_xfb)
{
// Fake format to calculate size correctly
format = GX_TF_IA8;
}
else if (bFromZBuffer)
{
format |= _GX_TF_ZTF;
if (copyfmt == 11)
{
format = GX_TF_Z16;
}
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
{
format |= _GX_TF_CTF;
}
}
else
{
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !peCopy.intensity_fmt))
format |= _GX_TF_CTF;
}
int width = (s_BpMem.copyTexSrcWH.x + 1) >> peCopy.half_scale;
int height = (s_BpMem.copyTexSrcWH.y + 1) >> peCopy.half_scale;
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
s32 expandedWidth = (width + blkW) & (~blkW);
s32 expandedHeight = (height + blkH) & (~blkH);
int sizeInBytes = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, format);
StoreWrittenRegion(address, sizeInBytes);
}
static void StoreWrittenRegion(u32 address, u32 size)
{
u32 end = address + size;
auto newRangeIter = s_WrittenMemory.end();
// Search for overlapping memory regions and expand them to include the new region
for (auto iter = s_WrittenMemory.begin(); iter != s_WrittenMemory.end();)
{
MemoryRange &range = *iter;
if (range.begin < end && range.end > address)
{
// range at iterator and new range overlap
if (newRangeIter == s_WrittenMemory.end())
{
// Expand range to include the written region
range.begin = std::min(address, range.begin);
range.end = std::max(end, range.end);
newRangeIter = iter;
++iter;
}
else
{
// Expand region at rangeIter to include this range
MemoryRange &used = *newRangeIter;
used.begin = std::min(used.begin, range.begin);
used.end = std::max(used.end, range.end);
// Remove this entry
iter = s_WrittenMemory.erase(iter);
}
}
else
{
++iter;
}
}
if (newRangeIter == s_WrittenMemory.end())
{
MemoryRange range;
range.begin = address;
range.end = end;
s_WrittenMemory.push_back(range);
}
}

View File

@ -20,6 +20,4 @@ struct AnalyzedFrameInfo
namespace FifoPlaybackAnalyzer
{
void AnalyzeFrames(FifoDataFile* file, std::vector<AnalyzedFrameInfo>& frameInfo);
void StoreEfbCopyRegion();
};