VideoCommon: Merge code to generate texture names on dumping
This commit is contained in:
parent
51bfc4c52a
commit
f8184858da
|
@ -80,7 +80,7 @@ void HiresTexture::Init(const std::string& gameCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HiresTexture* HiresTexture::Search(const u8* texture, size_t texture_size, const u8* tlut, size_t tlut_size, u32 width, u32 height, int format)
|
std::string HiresTexture::GenBaseName(const u8* texture, size_t texture_size, const u8* tlut, size_t tlut_size, u32 width, u32 height, int format)
|
||||||
{
|
{
|
||||||
u64 tex_hash = GetHashHiresTexture(texture, (int)texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
u64 tex_hash = GetHashHiresTexture(texture, (int)texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||||
u64 tlut_hash = 0;
|
u64 tlut_hash = 0;
|
||||||
|
@ -90,9 +90,14 @@ HiresTexture* HiresTexture::Search(const u8* texture, size_t texture_size, const
|
||||||
tlut_hash = GetHashHiresTexture(tlut, (int)tlut_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
tlut_hash = GetHashHiresTexture(tlut, (int)tlut_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
|
||||||
hash ^= tlut_hash;
|
hash ^= tlut_hash;
|
||||||
}
|
}
|
||||||
|
return StringFromFormat("%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32)hash, (u16)format);
|
||||||
|
}
|
||||||
|
|
||||||
|
HiresTexture* HiresTexture::Search(const u8* texture, size_t texture_size, const u8* tlut, size_t tlut_size, u32 width, u32 height, int format)
|
||||||
|
{
|
||||||
|
std::string base_filename = GenBaseName(texture, texture_size, tlut, tlut_size, width, height, format);
|
||||||
|
|
||||||
HiresTexture* ret = nullptr;
|
HiresTexture* ret = nullptr;
|
||||||
std::string base_filename = StringFromFormat("%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32)hash, format);
|
|
||||||
for (int level = 0;; level++)
|
for (int level = 0;; level++)
|
||||||
{
|
{
|
||||||
std::string filename = base_filename;
|
std::string filename = base_filename;
|
||||||
|
|
|
@ -21,6 +21,13 @@ public:
|
||||||
int format
|
int format
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static std::string GenBaseName(
|
||||||
|
const u8* texture, size_t texture_size,
|
||||||
|
const u8* tlut, size_t tlut_size,
|
||||||
|
u32 width, u32 height,
|
||||||
|
int format
|
||||||
|
);
|
||||||
|
|
||||||
~HiresTexture();
|
~HiresTexture();
|
||||||
|
|
||||||
struct Level
|
struct Level
|
||||||
|
|
|
@ -263,9 +263,8 @@ void TextureCache::ClearRenderTargets()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCache::DumpTexture(TCacheEntryBase* entry, unsigned int level)
|
void TextureCache::DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level)
|
||||||
{
|
{
|
||||||
std::string filename;
|
|
||||||
std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) +
|
std::string szDir = File::GetUserPath(D_DUMPTEXTURES_IDX) +
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID;
|
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID;
|
||||||
|
|
||||||
|
@ -273,20 +272,11 @@ void TextureCache::DumpTexture(TCacheEntryBase* entry, unsigned int level)
|
||||||
if (!File::Exists(szDir) || !File::IsDirectory(szDir))
|
if (!File::Exists(szDir) || !File::IsDirectory(szDir))
|
||||||
File::CreateDir(szDir);
|
File::CreateDir(szDir);
|
||||||
|
|
||||||
// For compatibility with old texture packs, don't print the LOD index for level 0.
|
if (level > 0)
|
||||||
// TODO: TLUT format should actually be stored in filename? :/
|
|
||||||
if (level == 0)
|
|
||||||
{
|
{
|
||||||
filename = StringFromFormat("%s/%s_%08x_%i.png", szDir.c_str(),
|
basename += StringFromFormat("_mip%i", level);
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(),
|
|
||||||
(u32)(entry->hash & 0x00000000FFFFFFFFLL), entry->format & 0xFFFF);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filename = StringFromFormat("%s/%s_%08x_%i_mip%i.png", szDir.c_str(),
|
|
||||||
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(),
|
|
||||||
(u32) (entry->hash & 0x00000000FFFFFFFFLL), entry->format & 0xFFFF, level);
|
|
||||||
}
|
}
|
||||||
|
std::string filename = szDir + "/" + basename + ".png";
|
||||||
|
|
||||||
if (!File::Exists(filename))
|
if (!File::Exists(filename))
|
||||||
entry->Save(filename, level);
|
entry->Save(filename, level);
|
||||||
|
@ -507,8 +497,17 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
|
||||||
else
|
else
|
||||||
entry->type = TCET_NORMAL;
|
entry->type = TCET_NORMAL;
|
||||||
|
|
||||||
|
std::string basename = "";
|
||||||
if (g_ActiveConfig.bDumpTextures && !hires_tex)
|
if (g_ActiveConfig.bDumpTextures && !hires_tex)
|
||||||
DumpTexture(entry, 0);
|
{
|
||||||
|
basename = HiresTexture::GenBaseName(
|
||||||
|
src_data, texture_size,
|
||||||
|
&texMem[tlutaddr], palette_size,
|
||||||
|
width, height,
|
||||||
|
texformat
|
||||||
|
);
|
||||||
|
DumpTexture(entry, basename, 0);
|
||||||
|
}
|
||||||
|
|
||||||
u32 level = 1;
|
u32 level = 1;
|
||||||
// load mips - TODO: Loading mipmaps from tmem is untested!
|
// load mips - TODO: Loading mipmaps from tmem is untested!
|
||||||
|
@ -543,7 +542,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
|
||||||
entry->Load(mip_width, mip_height, expanded_mip_width, level);
|
entry->Load(mip_width, mip_height, expanded_mip_width, level);
|
||||||
|
|
||||||
if (g_ActiveConfig.bDumpTextures)
|
if (g_ActiveConfig.bDumpTextures)
|
||||||
DumpTexture(entry, level);
|
DumpTexture(entry, basename, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (using_custom_lods)
|
else if (using_custom_lods)
|
||||||
|
|
|
@ -120,7 +120,7 @@ protected:
|
||||||
static size_t temp_size;
|
static size_t temp_size;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void DumpTexture(TCacheEntryBase* entry, unsigned int level);
|
static void DumpTexture(TCacheEntryBase* entry, std::string basename, unsigned int level);
|
||||||
static void CheckTempSize(size_t required_size);
|
static void CheckTempSize(size_t required_size);
|
||||||
|
|
||||||
static TCacheEntryBase* AllocateRenderTarget(unsigned int width, unsigned int height);
|
static TCacheEntryBase* AllocateRenderTarget(unsigned int width, unsigned int height);
|
||||||
|
|
Loading…
Reference in New Issue