From 8ed1694a2ff5bc80c075b42883e021f483a86df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 21 Sep 2022 23:49:50 +0200 Subject: [PATCH] Don't try to replace or scale CLUT8-on-GPU textures. See #8509 --- GPU/Common/TextureCacheCommon.cpp | 41 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 8bc072114b..17624f1e02 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2634,14 +2634,32 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt } } - if (isPPGETexture) { - plan.replaced = &replacer_.FindNone(); - plan.replaceValid = false; + bool canReplace = !isPPGETexture; + if (entry->status & TexCacheEntry::TexStatus::STATUS_CLUT_GPU) { + _dbg_assert_(entry->format == GE_TFMT_CLUT4 || entry->format == GE_TFMT_CLUT8); + plan.decodeToClut8 = true; + // We only support 1 mip level when doing CLUT on GPU for now. + // Supporting more would be possible, just not very interesting until we need it. + plan.levelsToCreate = 1; + plan.levelsToLoad = 1; + plan.maxPossibleLevels = 1; + plan.scaleFactor = 1; + plan.saveTexture = false; // Can't yet save these properly. + canReplace = false; } else { + plan.decodeToClut8 = false; + } + + if (canReplace) { plan.replaced = &FindReplacement(entry, plan.w, plan.h, plan.depth); plan.replaceValid = plan.replaced->Valid(); + } else { + plan.replaced = &replacer_.FindNone(); + plan.replaceValid = false; } + // NOTE! Last chance to change scale factor here! + plan.saveTexture = false; if (plan.replaceValid) { // We're replacing, so we won't scale. @@ -2652,7 +2670,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt // But, we still need to create the texture at a larger size. plan.replaced->GetSize(0, plan.createW, plan.createH); } else { - if (replacer_.Enabled() && !plan.replaceValid && plan.depth == 1) { + if (replacer_.Enabled() && !plan.replaceValid && plan.depth == 1 && canReplace) { ReplacedTextureDecodeInfo replacedInfo; // TODO: Do we handle the race where a replacement becomes valid AFTER this but before we save? replacedInfo.cachekey = entry->CacheKey(); @@ -2683,21 +2701,6 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt plan.maxPossibleLevels = log2i(std::min(plan.createW, plan.createH)) + 1; } - if (entry->status & TexCacheEntry::TexStatus::STATUS_CLUT_GPU) { - _dbg_assert_(entry->format == GE_TFMT_CLUT4 || entry->format == GE_TFMT_CLUT8); - plan.decodeToClut8 = true; - // We only support 1 mip level when doing CLUT on GPU for now. - // Supporting more would be possible, just not very interesting until we need it. - plan.levelsToCreate = 1; - plan.levelsToLoad = 1; - plan.maxPossibleLevels = 1; - plan.scaleFactor = 1; - plan.saveTexture = false; // Can't yet save these properly. - // TODO: Also forcibly disable replacement, or check that the replacement is a 8-bit paletted texture. - } else { - plan.decodeToClut8 = false; - } - if (plan.levelsToCreate == 1) { entry->status |= TexCacheEntry::STATUS_NO_MIPS; } else {