From 74e75f199683c9ce6408c9e6dd2673596061f45d Mon Sep 17 00:00:00 2001 From: GPUCode Date: Sun, 26 Feb 2023 19:03:21 +0200 Subject: [PATCH] rasterizer_cache: More texture pack nonsense * Some packs turn out have mipmaps but not the base level of a texture. Handle this to avoid black textures at a distance --- .../rasterizer_cache/rasterizer_cache.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.h b/src/video_core/rasterizer_cache/rasterizer_cache.h index 86e8581df..3645b5211 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache.h @@ -916,12 +916,20 @@ bool RasterizerCache::UploadCustomSurface(const Surface& surface, const Surfa const bool is_base_level = level == 0; const Texture& texture = custom_tex_manager.GetTexture(load_info, upload_data); - // The old texture pack system did not support mipmaps so older packs might do - // wonky things. For example Henriko's pack has mipmaps larger than the base - // level. To avoid crashes just don't upload mipmaps for custom surfaces - if (custom_tex_manager.CompatibilityMode() && surface->IsCustom() && !is_base_level) { - return true; + if (custom_tex_manager.CompatibilityMode() && !is_base_level) { + // Pack provides mipmap but not the base level. Fallback to normal upload + if (!surface->IsCustom() && texture) { + return false; + } + + // Pack provides base level but not any mipmaps. + // We can't fallback to normal upload so ignore it. + // The base level should already have generated mips for us. + if (surface->IsCustom() && !texture) { + return true; + } } + if (!texture) { return false; }