From 3ffcf267cb06a86e0892d2c897513314c1f7e299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Dec 2023 19:06:20 +0100 Subject: [PATCH 1/2] Allow replacing mip levels of a texture even without a ini file. Probably niche. --- GPU/Common/ReplacedTexture.cpp | 2 +- GPU/Common/TextureReplacer.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index 8447fe1eae1e..fd24a3e1afca 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -223,7 +223,7 @@ void ReplacedTexture::Prepare(VFSBackend *vfs) { VFSFileReference *fileRef = vfs_->GetFile(desc_.filenames[i].c_str()); if (!fileRef) { if (i == 0) { - WARN_LOG(G3D, "Texture replacement file '%s' not found", desc_.filenames[i].c_str()); + INFO_LOG(G3D, "Texture replacement file '%s' not found", desc_.filenames[i].c_str()); // No file at all. Mark as NOT_FOUND. SetState(ReplacementState::NOT_FOUND); return; diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 57148110ab62..88ae5feee432 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -593,7 +593,12 @@ ReplacedTexture *TextureReplacer::FindReplacement(u64 cachekey, u32 hash, int w, } desc.logId = desc.filenames[0]; desc.hashfiles = desc.filenames[0]; // The generated filename of the top level is used as the key in the data cache. - hashfiles = desc.filenames[0]; + hashfiles.clear(); + hashfiles.reserve(desc.filenames[0].size() * (desc.filenames.size() + 1)); + for (int level = 0; level < desc.filenames.size(); level++) { + hashfiles += desc.filenames[level]; + hashfiles.push_back('|'); + } } else { desc.logId = hashfiles; SplitString(hashfiles, '|', desc.filenames); From daa9fab32a49289f62418be356d4a9bda21faa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Dec 2023 19:06:43 +0100 Subject: [PATCH 2/2] Don't try to replace textures if there's just an empty TEXTURES/{GAMEID} folder. --- GPU/Common/TextureReplacer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 88ae5feee432..11421fb71e46 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -180,6 +180,12 @@ bool TextureReplacer::LoadIni() { // Do what we can do anyway: Scan for textures and build the map. std::map> filenameMap; ScanForHashNamedFiles(dir, filenameMap); + + if (filenameMap.empty()) { + WARN_LOG(G3D, "No replacement textures found."); + return false; + } + ComputeAliasMap(filenameMap); } }