Skip to content

Commit

Permalink
GPU/TextureCache: Look for replacements outside of subdirectory
Browse files Browse the repository at this point in the history
i.e. old setups that do not have the `replacements` subdirectory.
  • Loading branch information
stenzek committed Dec 11, 2024
1 parent d871c17 commit 69947fb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/core/gpu_hw_texture_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,9 @@ bool GPUTextureCache::HasValidReplacementExtension(const std::string_view path)

void GPUTextureCache::FindTextureReplacements(bool load_vram_write_replacements, bool load_texture_replacements)
{
if (s_state.game_id.empty())
return;

FileSystem::FindResultsArray files;
FileSystem::FindFiles(GetTextureReplacementDirectory().c_str(), "*",
FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_RECURSIVE, &files);
Expand Down Expand Up @@ -3028,6 +3031,9 @@ void GPUTextureCache::LoadTextureReplacementAliases(const ryml::ConstNodeRef& ro
bool load_vram_write_replacement_aliases,
bool load_texture_replacement_aliases)
{
if (s_state.game_id.empty())
return;

const std::string source_dir = GetTextureReplacementDirectory();

for (const ryml::ConstNodeRef& current : root.cchildren())
Expand Down Expand Up @@ -3303,8 +3309,18 @@ bool GPUTextureCache::EnsureGameDirectoryExists()

std::string GPUTextureCache::GetTextureReplacementDirectory()
{
return Path::Combine(EmuFolders::Textures,
SmallString::from_format("{}" FS_OSPATH_SEPARATOR_STR "replacements", s_state.game_id));
std::string dir = Path::Combine(
EmuFolders::Textures, SmallString::from_format("{}" FS_OSPATH_SEPARATOR_STR "replacements", s_state.game_id));
if (!FileSystem::DirectoryExists(dir.c_str()))
{
// Check for the old directory structure without a replacements subdirectory.
std::string altdir = Path::Combine(EmuFolders::Textures, s_state.game_id);
if (FileSystem::DirectoryExists(altdir.c_str()))
WARNING_LOG("Using deprecated texture replacement directory {}", altdir);
dir = std::move(altdir);
}

return dir;
}

std::string GPUTextureCache::GetTextureDumpDirectory()
Expand Down

0 comments on commit 69947fb

Please sign in to comment.