Merge pull request #18083 from hrydgard/tex-loader-safety

Add some texture loading safety checks
This commit is contained in:
Henrik Rydgård 2023-09-06 16:52:33 +02:00 committed by GitHub
commit fa9a13a99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -2918,6 +2918,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt
}
if (plan.isVideo || plan.depth != 1 || plan.decodeToClut8) {
plan.levelsToLoad = 1;
plan.maxPossibleLevels = 1;
} else {
plan.maxPossibleLevels = log2i(std::min(plan.createW, plan.createH)) + 1;

View File

@ -442,6 +442,8 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
dstFmt = VULKAN_CLUT8_FORMAT;
}
_dbg_assert_(plan.levelsToLoad <= plan.maxPossibleLevels);
// We don't generate mipmaps for 512x512 textures because they're almost exclusively used for menu backgrounds
// and similar, which don't really need it.
// Also, if using replacements, check that we really can generate mips for this format - that's not possible for compressed ones.