Don't try to replace or scale CLUT8-on-GPU textures.

See #8509
This commit is contained in:
Henrik Rydgård 2022-09-21 23:49:50 +02:00
parent c8c6b945bc
commit 8ed1694a2f

View File

@ -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 {