From 61541ab243552c755004e069ef392e68741966c8 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Wed, 1 Nov 2017 22:05:34 -0500 Subject: [PATCH] Enhance xfb dumping to distinguish between the xfbs created from memory and the xfbs created from overlapping copies --- Source/Core/VideoCommon/TextureCacheBase.cpp | 45 +++++++++++--------- Source/Core/VideoCommon/TextureCacheBase.h | 2 - 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 46e48673d0..ee43fba30f 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1111,7 +1111,9 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, TextureForma return nullptr; } - TCacheEntry* entry = GetXFBFromCache(tex_info.value()); + const TextureLookupInformation tex_info_value = tex_info.value(); + + TCacheEntry* entry = GetXFBFromCache(tex_info_value); if (entry != nullptr) { return entry; @@ -1128,15 +1130,29 @@ TextureCacheBase::GetXFBTexture(u32 address, u32 width, u32 height, TextureForma // this means the address is most likely not pointing at an xfb copy but instead // an area of memory. Let's attempt to stitch all entries in this memory space // together - if (LoadTextureFromOverlappingTextures(entry, tex_info.value())) + bool loaded_from_overlapping = LoadTextureFromOverlappingTextures(entry, tex_info_value); + + if (!loaded_from_overlapping) { - return entry; + // At this point, the xfb address is truly "bogus" + // it likely is an area of memory defined by the CPU + // so load it from memory + LoadTextureFromMemory(entry, tex_info_value); + } + + if (g_ActiveConfig.bDumpXFBTarget) + { + // While this isn't really an xfb copy, we can treat it as such + // for dumping purposes + static int xfb_count = 0; + const std::string xfb_type = loaded_from_overlapping ? "combined" : "from_memory"; + entry->texture->Save(StringFromFormat("%sxfb_%s_%i.png", + File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(), + xfb_type.c_str(), + xfb_count++), + 0); } - // At this point, the xfb address is truly "bogus" - // it likely is an area of memory defined by the CPU - // so load it from memory - LoadTextureFromMemory(entry, tex_info.value()); return entry; } @@ -1213,14 +1229,6 @@ std::optional TextureCacheBase::ComputeTextureInformat tex_info.full_hash = tex_info.base_hash; } - if (g_ActiveConfig.bDumpTextures) - { - tex_info.dump_base_name = HiresTexture::GenBaseName( - tex_info.src_data, tex_info.total_bytes, &texMem[tex_info.tlut_address], - tex_info.palette_size, tex_info.native_width, tex_info.native_height, - tex_info.full_format.texfmt, tex_info.use_mipmaps, true); - } - return tex_info; } @@ -1447,11 +1455,6 @@ TextureCacheBase::CreateNormalTexture(const TextureLookupInformation& tex_info) INCSTAT(stats.numTexturesUploaded); SETSTAT(stats.numTexturesAlive, textures_by_address.size()); - if (g_ActiveConfig.bDumpTextures) - { - DumpTexture(entry, tex_info.dump_base_name, 0); - } - return entry; } @@ -2015,7 +2018,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, EFBCopyFormat dstF if (g_ActiveConfig.bDumpXFBTarget && is_xfb_copy) { static int xfb_count = 0; - entry->texture->Save(StringFromFormat("%sxfb_frame_%i.png", + entry->texture->Save(StringFromFormat("%sxfb_copy_%i.png", File::GetUserPath(D_DUMPTEXTURES_IDX).c_str(), xfb_count++), 0); diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h index 696c6ec888..5eee06c6d8 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.h +++ b/Source/Core/VideoCommon/TextureCacheBase.h @@ -100,8 +100,6 @@ struct TextureLookupInformation int texture_cache_safety_color_sample_size = 0; // Default to safe hashing u8* src_data; - - std::string dump_base_name; }; class TextureCacheBase