From b253225815b1aee417d919f41039810c55a60b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 9 Mar 2023 14:57:38 +0100 Subject: [PATCH] Fix another replacer lifecycle issue, causing unnecessary texture invalidation. --- Core/TextureReplacer.cpp | 1 + GPU/Common/TextureCacheCommon.cpp | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 6fd0205f71..98de573b2f 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -515,6 +515,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *texture, u64 cachekey if (!foundReplacement || ignored) { // nothing to do? + texture->prepareDone_ = true; return; } diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index f89bf64898..8751efbb6e 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -529,16 +529,18 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { int h0 = gstate.getTextureHeight(0); int d0 = 1; ReplacedTexture *replaced = FindReplacement(entry, w0, h0, d0); - if (replaced && replaced->IsInvalid()) { - entry->status &= ~TexCacheEntry::STATUS_TO_REPLACE; - if (g_Config.bSaveNewTextures) { - // Load once more to actually save. + if (replaced) { + if (replaced->IsInvalid()) { + entry->status &= ~TexCacheEntry::STATUS_TO_REPLACE; + if (g_Config.bSaveNewTextures) { + // Load once more to actually save. + match = false; + reason = "replacing"; + } + } else { match = false; reason = "replacing"; } - } else { - match = false; - reason = "replacing"; } } @@ -2784,7 +2786,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt if (canReplace) { plan.replaced = FindReplacement(entry, plan.w, plan.h, plan.depth); - plan.replaceValid = plan.replaced ? plan.replaced->Valid() : plan.replaced; + plan.replaceValid = plan.replaced ? plan.replaced->Valid() : false; } else { plan.replaced = nullptr; plan.replaceValid = false;