From a8ad59ee3e4345b9cc2fcf9bfe28e385a7e443c6 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sat, 12 May 2012 13:31:09 +0200 Subject: [PATCH] TextureCacheBase: Move texture dumping to a helper function. --- .../Core/VideoCommon/Src/TextureCacheBase.cpp | 36 ++++++++++--------- .../Core/VideoCommon/Src/TextureCacheBase.h | 1 + 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp index 34d4020c86..d01a68954c 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -195,6 +195,24 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign return ret; } +void TextureCache::DumpTexture(TCacheEntryBase* entry) +{ + char szTemp[MAX_PATH]; + std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) + + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID; + + // make sure that the directory exists + if (false == File::Exists(szDir) || false == File::IsDirectory(szDir)) + File::CreateDir(szDir.c_str()); + + sprintf(szTemp, "%s/%s_%08x_%i.png", szDir.c_str(), + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), + (u32) (entry->hash & 0x00000000FFFFFFFFLL), entry->format & 0xFFFF); // TODO: TLUT format should actually be here as well? :/ + + if (false == File::Exists(szTemp)) + entry->Save(szTemp); +} + TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, u32 address, unsigned int width, unsigned int height, int texformat, unsigned int tlutaddr, int tlutfmt, bool UseNativeMips, unsigned int maxlevel, bool from_tmem) @@ -379,24 +397,8 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, } // TODO: won't this cause loaded hires textures to be dumped as well? - // dump texture to file if (g_ActiveConfig.bDumpTextures) - { - char szTemp[MAX_PATH]; - std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) + - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID; - - // make sure that the directory exists - if (false == File::Exists(szDir) || false == File::IsDirectory(szDir)) - File::CreateDir(szDir.c_str()); - - sprintf(szTemp, "%s/%s_%08x_%i.png", szDir.c_str(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), - (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat); - - if (false == File::Exists(szTemp)) - entry->Save(szTemp); - } + DumpTexture(entry); INCSTAT(stats.numTexturesCreated); SETSTAT(stats.numTexturesAlive, textures.size()); diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.h b/Source/Core/VideoCommon/Src/TextureCacheBase.h index 4252b29d53..507af0e5ac 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.h +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.h @@ -128,6 +128,7 @@ protected: private: static PC_TexFormat LoadCustomTexture(u64 tex_hash, int texformat, unsigned int& width, unsigned int& height, u8* dest); + static void DumpTexture(TCacheEntryBase* entry); typedef std::map TexCache;