From f58fa2297ead00ae0424c0bad40a55e8ba8c8d57 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 28 Jan 2025 17:33:34 +1000 Subject: [PATCH] GPU/TextureCache: Only use a single palette record for C16 Stops C16 textures larger than 256x256 being split up. --- src/core/gpu_hw_texture_cache.cpp | 17 +++++++++++++++-- src/core/gpu_hw_texture_cache.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw_texture_cache.cpp b/src/core/gpu_hw_texture_cache.cpp index 1694c365b..7d6339422 100644 --- a/src/core/gpu_hw_texture_cache.cpp +++ b/src/core/gpu_hw_texture_cache.cpp @@ -1818,8 +1818,21 @@ void GPUTextureCache::UpdateVRAMWriteSources(VRAMWrite* entry, SourceKey source_ return; // Add to the palette tracking list - auto iter = std::find_if(entry->palette_records.begin(), entry->palette_records.end(), - [&source_key](const auto& it) { return (it.key == source_key); }); + std::vector::iterator iter; + if (source_key.HasPalette()) + { + // Palette requires exact match. + iter = std::find_if(entry->palette_records.begin(), entry->palette_records.end(), + [&source_key](const auto& it) { return (it.key == source_key); }); + } + else + { + // C16 only needs to match on the mode, palette is not used, and page doesn't matter. + // In theory we could extend the page skipping to palette textures too, but is it needed? + iter = std::find_if(entry->palette_records.begin(), entry->palette_records.end(), + [&source_key](const auto& it) { return (it.key.mode == source_key.mode); }); + } + if (iter != entry->palette_records.end()) { iter->rect = iter->rect.runion(write_intersection); diff --git a/src/core/gpu_hw_texture_cache.h b/src/core/gpu_hw_texture_cache.h index 42ad5f3bf..258c81f37 100644 --- a/src/core/gpu_hw_texture_cache.h +++ b/src/core/gpu_hw_texture_cache.h @@ -58,7 +58,7 @@ struct TListNode TListNode* next; }; -struct SourceKey +struct alignas(4) SourceKey { u8 page; GPUTextureMode mode;