Merge pull request #9711 from iwubcode/enhance-wildcard-support
VideoCommon: enhance wildcard support in hi res texture lookup
This commit is contained in:
commit
c788beecfc
|
@ -221,20 +221,29 @@ std::string HiresTexture::GenBaseName(TextureInfo& texture_info, bool dump)
|
||||||
|
|
||||||
const auto texture_name_details = texture_info.CalculateTextureName();
|
const auto texture_name_details = texture_info.CalculateTextureName();
|
||||||
|
|
||||||
// try to match a wildcard template
|
// look for an exact match first
|
||||||
if (!dump)
|
|
||||||
{
|
|
||||||
const std::string texture_name =
|
|
||||||
fmt::format("{}_${}", texture_name_details.base_name, texture_name_details.format_name);
|
|
||||||
if (s_textureMap.find(texture_name) != s_textureMap.end())
|
|
||||||
return texture_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// else generate the complete texture
|
|
||||||
const std::string full_name = texture_name_details.GetFullName();
|
const std::string full_name = texture_name_details.GetFullName();
|
||||||
if (dump || s_textureMap.find(full_name) != s_textureMap.end())
|
if (dump || s_textureMap.find(full_name) != s_textureMap.end())
|
||||||
return full_name;
|
return full_name;
|
||||||
|
|
||||||
|
// else try and find a wildcard
|
||||||
|
if (!dump)
|
||||||
|
{
|
||||||
|
// Single wildcard ignoring the tlut hash
|
||||||
|
const std::string texture_name_single_wildcard_tlut =
|
||||||
|
fmt::format("{}_{}_$_{}", texture_name_details.base_name, texture_name_details.texture_name,
|
||||||
|
texture_name_details.format_name);
|
||||||
|
if (s_textureMap.find(texture_name_single_wildcard_tlut) != s_textureMap.end())
|
||||||
|
return texture_name_single_wildcard_tlut;
|
||||||
|
|
||||||
|
// Single wildcard ignoring the texture hash
|
||||||
|
const std::string texture_name_single_wildcard_tex =
|
||||||
|
fmt::format("{}_${}_{}", texture_name_details.base_name, texture_name_details.tlut_name,
|
||||||
|
texture_name_details.format_name);
|
||||||
|
if (s_textureMap.find(texture_name_single_wildcard_tex) != s_textureMap.end())
|
||||||
|
return texture_name_single_wildcard_tex;
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "VideoCommon/TextureInfo.h"
|
#include "VideoCommon/TextureInfo.h"
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
#include <xxhash.h>
|
#include <xxhash.h>
|
||||||
|
|
||||||
#include "Common/Align.h"
|
#include "Common/Align.h"
|
||||||
|
@ -95,6 +96,11 @@ TextureInfo::TextureInfo(const u8* ptr, const u8* tlut_ptr, u32 address,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TextureInfo::NameDetails::GetFullName() const
|
||||||
|
{
|
||||||
|
return fmt::format("{}_{}{}_{}", base_name, texture_name, tlut_name, format_name);
|
||||||
|
}
|
||||||
|
|
||||||
TextureInfo::NameDetails TextureInfo::CalculateTextureName()
|
TextureInfo::NameDetails TextureInfo::CalculateTextureName()
|
||||||
{
|
{
|
||||||
if (!m_ptr)
|
if (!m_ptr)
|
||||||
|
@ -151,10 +157,11 @@ TextureInfo::NameDetails TextureInfo::CalculateTextureName()
|
||||||
const u64 tlut_hash = tlut_size ? XXH64(tlut, tlut_size, 0) : 0;
|
const u64 tlut_hash = tlut_size ? XXH64(tlut, tlut_size, 0) : 0;
|
||||||
|
|
||||||
NameDetails result;
|
NameDetails result;
|
||||||
result.base_name = fmt::format("{}{}x{}{}_{:016x}", format_prefix, m_raw_width, m_raw_height,
|
result.base_name = fmt::format("{}{}x{}{}", format_prefix, m_raw_width, m_raw_height,
|
||||||
m_mipmaps_enabled ? "_m" : "", tex_hash);
|
m_mipmaps_enabled ? "_m" : "");
|
||||||
|
result.texture_name = fmt::format("{:016x}", tex_hash);
|
||||||
result.tlut_name = tlut_size ? fmt::format("_{:016x}", tlut_hash) : "";
|
result.tlut_name = tlut_size ? fmt::format("_{:016x}", tlut_hash) : "";
|
||||||
result.format_name = fmt::format("_{}", static_cast<int>(m_texture_format));
|
result.format_name = fmt::to_string(static_cast<int>(m_texture_format));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,11 @@ public:
|
||||||
struct NameDetails
|
struct NameDetails
|
||||||
{
|
{
|
||||||
std::string base_name;
|
std::string base_name;
|
||||||
|
std::string texture_name;
|
||||||
std::string tlut_name;
|
std::string tlut_name;
|
||||||
std::string format_name;
|
std::string format_name;
|
||||||
|
|
||||||
std::string GetFullName() const { return base_name + tlut_name + format_name; }
|
std::string GetFullName() const;
|
||||||
};
|
};
|
||||||
NameDetails CalculateTextureName();
|
NameDetails CalculateTextureName();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue