From 8e3428438ecd59da127c66ef83fd552aeae28ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 10 Mar 2023 23:58:15 +0100 Subject: [PATCH] Replacement: Fix mip level loading. Fix bug if LoadIni gets rerun for some reason. --- GPU/Common/TextureCacheCommon.cpp | 3 ++- GPU/Common/TextureReplacer.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 5c056eb87f..d852267f5c 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2829,8 +2829,9 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt if (plan.replaceValid) { // We're replacing, so we won't scale. plan.scaleFactor = 1; + // We're ignoring how many levels were specified - instead we just load all available from the replacer. plan.levelsToLoad = plan.replaced->NumLevels(); - plan.levelsToCreate = std::min(plan.levelsToLoad, plan.levelsToCreate); + plan.levelsToCreate = plan.levelsToLoad; // Or more, if we wanted to generate. plan.badMipSizes = false; // But, we still need to create the texture at a larger size. plan.replaced->GetSize(0, &plan.createW, &plan.createH); diff --git a/GPU/Common/TextureReplacer.cpp b/GPU/Common/TextureReplacer.cpp index 1ce1fd62ca..0a3889c062 100644 --- a/GPU/Common/TextureReplacer.cpp +++ b/GPU/Common/TextureReplacer.cpp @@ -191,6 +191,13 @@ bool TextureReplacer::LoadIni() { } vfs_ = dir; + + // If we have stuff loaded from before, need to update the vfs pointers to avoid + // crash on exit. The actual problem is that we tend to call LoadIni a little too much... + for (auto &repl : cache_) { + repl.second->vfs_ = vfs_; + } + INFO_LOG(G3D, "Texture pack activated from '%s'", basePath_.c_str()); // The ini doesn't have to exist for the texture directory or zip to be valid.