Fix another replacer lifecycle issue, causing unnecessary texture invalidation.

This commit is contained in:
Henrik Rydgård 2023-03-09 14:57:38 +01:00
parent 44c4e63753
commit b253225815
2 changed files with 11 additions and 8 deletions

View file

@ -515,6 +515,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *texture, u64 cachekey
if (!foundReplacement || ignored) { if (!foundReplacement || ignored) {
// nothing to do? // nothing to do?
texture->prepareDone_ = true;
return; return;
} }

View file

@ -529,16 +529,18 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
int h0 = gstate.getTextureHeight(0); int h0 = gstate.getTextureHeight(0);
int d0 = 1; int d0 = 1;
ReplacedTexture *replaced = FindReplacement(entry, w0, h0, d0); ReplacedTexture *replaced = FindReplacement(entry, w0, h0, d0);
if (replaced && replaced->IsInvalid()) { if (replaced) {
entry->status &= ~TexCacheEntry::STATUS_TO_REPLACE; if (replaced->IsInvalid()) {
if (g_Config.bSaveNewTextures) { entry->status &= ~TexCacheEntry::STATUS_TO_REPLACE;
// Load once more to actually save. if (g_Config.bSaveNewTextures) {
// Load once more to actually save.
match = false;
reason = "replacing";
}
} else {
match = false; match = false;
reason = "replacing"; reason = "replacing";
} }
} else {
match = false;
reason = "replacing";
} }
} }
@ -2784,7 +2786,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
if (canReplace) { if (canReplace) {
plan.replaced = FindReplacement(entry, plan.w, plan.h, plan.depth); 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 { } else {
plan.replaced = nullptr; plan.replaced = nullptr;
plan.replaceValid = false; plan.replaceValid = false;