From 375ef41765bdcf7f0b004cd39edbd8aa30abccd6 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sun, 8 Nov 2015 17:03:05 +1300 Subject: [PATCH] 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. --- Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp | 35 ---- Source/Core/Core/FifoPlayer/FifoAnalyzer.h | 6 - .../Core/FifoPlayer/FifoPlaybackAnalyzer.cpp | 156 +----------------- .../Core/FifoPlayer/FifoPlaybackAnalyzer.h | 2 - 4 files changed, 1 insertion(+), 198 deletions(-) diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp index 332cd29959a4..b792bf6929d4 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.cpp @@ -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) diff --git a/Source/Core/Core/FifoPlayer/FifoAnalyzer.h b/Source/Core/Core/FifoPlayer/FifoAnalyzer.h index f15f8cc97ea7..328b035a9aff 100644 --- a/Source/Core/Core/FifoPlayer/FifoAnalyzer.h +++ b/Source/Core/Core/FifoPlayer/FifoAnalyzer.h @@ -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; } diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp index 914e5445490a..9f54b6a095f8 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp @@ -22,23 +22,8 @@ struct CmdData u8* ptr; }; -struct MemoryRange -{ - u32 begin; - u32 end; -}; - -static std::vector s_WrittenMemory; - -static void AddMemoryUpdate(MemoryUpdate memUpdate, AnalyzedFrameInfo& frameInfo); -static void StoreWrittenRegion(u32 address, u32 size); - void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file, std::vector& 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 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); - } -} diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.h b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.h index 4c956a789173..bd558b9d8a1a 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.h +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.h @@ -20,6 +20,4 @@ struct AnalyzedFrameInfo namespace FifoPlaybackAnalyzer { void AnalyzeFrames(FifoDataFile* file, std::vector& frameInfo); - - void StoreEfbCopyRegion(); };