diff options
| author | Scott Mansell <phiren@gmail.com> | 2015-09-23 00:17:37 +1200 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2015-09-23 00:17:37 +1200 |
| commit | a537ca7543bb3b147a9fbb1c6f44083902848d2d (patch) | |
| tree | d9e904cd8883829f55e3462070ed0992c7cc8390 /Source/Core/VideoCommon | |
| parent | 79bf93996fbfc713c1d6aa641b3af061d1d33c36 (diff) | |
| parent | aa1fec6fc303eee7a510930c4d809bbe419a604d (diff) | |
Merge pull request #2997 from phire/FixFifoRecorder
FifoRecorder: Use Texture Cache to record efb copies correctly.
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/BPStructs.cpp | 29 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/OpcodeDecoding.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 38 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VideoCommon.h | 3 |
4 files changed, 54 insertions, 18 deletions
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index e30aa2fcaa..4dc4643afb 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -8,6 +8,7 @@ #include "Common/Thread.h" #include "Core/ConfigManager.h" #include "Core/Core.h" +#include "Core/FifoPlayer/FifoRecorder.h" #include "Core/HW/Memmap.h" #include "VideoCommon/BoundingBox.h" @@ -281,6 +282,9 @@ static void BPWritten(const BPCmd& bp) Memory::CopyFromEmu(texMem + tlutTMemAddr, addr, tlutXferCount); + if (g_bRecordFifoData) + FifoRecorder::GetInstance().UseMemory(addr, tlutXferCount, MemoryUpdate::TMEM); + return; } case BPMEM_FOGRANGE: // Fog Settings Control @@ -455,15 +459,16 @@ static void BPWritten(const BPCmd& bp) BPS_TmemConfig& tmem_cfg = bpmem.tmem_config; u32 src_addr = tmem_cfg.preload_addr << 5; // TODO: Should we add mask here on GC? - u32 size = tmem_cfg.preload_tile_info.count * TMEM_LINE_SIZE; + u32 bytes_read = 0; u32 tmem_addr_even = tmem_cfg.preload_tmem_even * TMEM_LINE_SIZE; if (tmem_cfg.preload_tile_info.type != 3) { - if (tmem_addr_even + size > TMEM_SIZE) - size = TMEM_SIZE - tmem_addr_even; + bytes_read = tmem_cfg.preload_tile_info.count * TMEM_LINE_SIZE; + if (tmem_addr_even + bytes_read > TMEM_SIZE) + bytes_read = TMEM_SIZE - tmem_addr_even; - Memory::CopyFromEmu(texMem + tmem_addr_even, src_addr, size); + Memory::CopyFromEmu(texMem + tmem_addr_even, src_addr, bytes_read); } else // RGBA8 tiles (and CI14, but that might just be stupid libogc!) { @@ -471,21 +476,23 @@ static void BPWritten(const BPCmd& bp) // AR and GB tiles are stored in separate TMEM banks => can't use a single memcpy for everything u32 tmem_addr_odd = tmem_cfg.preload_tmem_odd * TMEM_LINE_SIZE; + u32 bytes_read = 0; for (u32 i = 0; i < tmem_cfg.preload_tile_info.count; ++i) { - if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || - tmem_addr_odd + TMEM_LINE_SIZE > TMEM_SIZE) - return; + if (tmem_addr_even + TMEM_LINE_SIZE > TMEM_SIZE || tmem_addr_odd + TMEM_LINE_SIZE > TMEM_SIZE) + break; - // TODO: This isn't very optimised, does a whole lot of small memcpys - memcpy(texMem + tmem_addr_even, src_ptr, TMEM_LINE_SIZE); - memcpy(texMem + tmem_addr_odd, src_ptr + TMEM_LINE_SIZE, TMEM_LINE_SIZE); + memcpy(texMem + tmem_addr_even, src_ptr + bytes_read, TMEM_LINE_SIZE); + memcpy(texMem + tmem_addr_odd, src_ptr + bytes_read + TMEM_LINE_SIZE, TMEM_LINE_SIZE); tmem_addr_even += TMEM_LINE_SIZE; tmem_addr_odd += TMEM_LINE_SIZE; - src_ptr += TMEM_LINE_SIZE * 2; + bytes_read += TMEM_LINE_SIZE * 2; } } + + if (g_bRecordFifoData) + FifoRecorder::GetInstance().UseMemory(src_addr, bytes_read, MemoryUpdate::TMEM); } return; diff --git a/Source/Core/VideoCommon/OpcodeDecoding.h b/Source/Core/VideoCommon/OpcodeDecoding.h index ec1b2652e4..a79bf54be2 100644 --- a/Source/Core/VideoCommon/OpcodeDecoding.h +++ b/Source/Core/VideoCommon/OpcodeDecoding.h @@ -38,8 +38,6 @@ #define GX_DRAW_LINE_STRIP 0x6 // 0xB0 #define GX_DRAW_POINTS 0x7 // 0xB8 -extern bool g_bRecordFifoData; - void OpcodeDecoder_Init(); void OpcodeDecoder_Shutdown(); diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 694aa80c0a..e93e6955f4 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -11,6 +11,7 @@ #include "Core/ConfigManager.h" #include "Core/FifoPlayer/FifoPlayer.h" +#include "Core/FifoPlayer/FifoRecorder.h" #include "Core/HW/Memmap.h" #include "VideoCommon/Debugger.h" @@ -19,6 +20,7 @@ #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/TextureCacheBase.h" +#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" static const u64 TEXHASH_INVALID = 0; @@ -395,6 +397,25 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) full_format = texformat | (tlutfmt << 16); const u32 texture_size = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, texformat); + u32 additional_mips_size = 0; // not including level 0, which is texture_size + + // GPUs don't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain + // e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,0x0, so we limit the mipmap count to 6 there + tex_levels = std::min<u32>(IntLog2(std::max(width, height)) + 1, tex_levels); + + for (u32 level = 1; level != tex_levels; ++level) + { + // We still need to calculate the original size of the mips + const u32 expanded_mip_width = ROUND_UP(CalculateLevelSize(width, level), bsw); + const u32 expanded_mip_height = ROUND_UP(CalculateLevelSize(height, level), bsh); + + additional_mips_size += TexDecoder_GetTextureSizeInBytes(expanded_mip_width, expanded_mip_height, texformat); + } + + // If we are recording a FifoLog, keep track of what memory we read. + // FifiRecorder does it's own memory modification tracking independant of the texture hashing below. + if (g_bRecordFifoData && !from_tmem) + FifoRecorder::GetInstance().UseMemory(address, texture_size + additional_mips_size, MemoryUpdate::TEXTURE_MAP); const u8* src_data; if (from_tmem) @@ -415,10 +436,6 @@ TextureCache::TCacheEntryBase* TextureCache::Load(const u32 stage) full_hash = base_hash; } - // GPUs don't like when the specified mipmap count would require more than one 1x1-sized LOD in the mipmap chain - // e.g. 64x64 with 7 LODs would have the mipmap chain 64x64,32x32,16x16,8x8,4x4,2x2,1x1,0x0, so we limit the mipmap count to 6 there - tex_levels = std::min<u32>(IntLog2(std::max(width, height)) + 1, tex_levels); - // Search the texture cache for textures by address // // Find all texture cache entries for the current texture address, and decide whether to use one of @@ -740,7 +757,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat // // For historical reasons, Dolphin doesn't actually implement "pure" EFB to RAM emulation, but only EFB to texture and hybrid EFB copies. - float colmat[28] = {0}; + float colmat[28] = { 0 }; float *const fConstAdd = colmat + 16; float *const ColorMask = colmat + 20; ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f; @@ -1058,6 +1075,17 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat count++), 0); } + if (g_bRecordFifoData) + { + // Mark the memory behind this efb copy as dynamicly generated for the Fifo log + u32 address = dstAddr; + for (u32 i = 0; i < entry->NumBlocksY(); i++) + { + FifoRecorder::GetInstance().UseMemory(address, entry->CacheLinesPerRow() * 32, MemoryUpdate::TEXTURE_MAP, true); + address += entry->memory_stride; + } + } + textures_by_address.emplace((u64)dstAddr, entry); } diff --git a/Source/Core/VideoCommon/VideoCommon.h b/Source/Core/VideoCommon/VideoCommon.h index 4234bbb8be..ba339e5c4f 100644 --- a/Source/Core/VideoCommon/VideoCommon.h +++ b/Source/Core/VideoCommon/VideoCommon.h @@ -12,6 +12,9 @@ #include "Common/MathUtil.h" #include "VideoCommon/VideoBackendBase.h" +// Global flag to signal if FifoRecorder is active. +extern bool g_bRecordFifoData; + // These are accurate (disregarding AA modes). enum { |
