VideoCommon: fix regression with texture load order where the custom texture code was always updating the asset map for each texture with each entry, making it so the last value actually would be loaded instead of the first

This commit is contained in:
iwubcode 2023-08-11 00:36:41 -05:00 committed by Nayla Hanegan
commit 89723e03c1
No known key found for this signature in database
GPG key ID: 3075216CED0DB01D

View file

@ -120,10 +120,18 @@ void HiresTexture::Update()
if (has_arbitrary_mipmaps) if (has_arbitrary_mipmaps)
filename.erase(arb_index, 4); filename.erase(arb_index, 4);
const auto [it, inserted] =
s_hires_texture_id_to_arbmipmap.try_emplace(filename, has_arbitrary_mipmaps);
if (!inserted)
{
failed_insert = true;
}
else
{
// Since this is just a texture (single file) the mapper doesn't really matter // Since this is just a texture (single file) the mapper doesn't really matter
// just provide a string // just provide a string
s_file_library->SetAssetIDMapData(filename, s_file_library->SetAssetIDMapData(
std::map<std::string, std::filesystem::path>{{"", path}}); filename, std::map<std::string, std::filesystem::path>{{"", path}});
if (g_ActiveConfig.bCacheHiresTextures) if (g_ActiveConfig.bCacheHiresTextures)
{ {
@ -132,11 +140,6 @@ void HiresTexture::Update()
system.GetCustomAssetLoader().LoadGameTexture(filename, s_file_library)); system.GetCustomAssetLoader().LoadGameTexture(filename, s_file_library));
s_hires_texture_cache.try_emplace(filename, std::move(hires_texture)); s_hires_texture_cache.try_emplace(filename, std::move(hires_texture));
} }
const auto [it, inserted] =
s_hires_texture_id_to_arbmipmap.try_emplace(filename, has_arbitrary_mipmaps);
if (!inserted)
{
failed_insert = true;
} }
} }
} }