From e743c5d1b14a42ac1628e0c67f0b0ad03be8c5dd Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 22 Jul 2024 21:25:11 +1000 Subject: [PATCH] GPU/HW: Force update CLUT on save state Fixes switching from hardware->software renderer in games that are drawing without reloading the CLUT. --- src/core/gpu_hw.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 64a03c632..9f8660306 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -284,9 +284,17 @@ bool GPU_HW::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di { // Need to download local VRAM copy before calling the base class, because it serializes this. if (m_sw_renderer) + { m_sw_renderer->Sync(true); + } else if (sw.IsWriting() && !host_texture) + { + // If SW renderer readbacks aren't enabled, the CLUT won't be populated, which means it'll be invalid if the user + // loads this state with software instead of hardware renderers. So force-update the CLUT. ReadVRAM(0, 0, VRAM_WIDTH, VRAM_HEIGHT); + if (IsCLUTValid()) + GPU::ReadCLUT(g_gpu_clut, GPUTexturePaletteReg{Truncate16(m_current_clut_reg_bits)}, m_current_clut_is_8bit); + } if (!GPU::DoState(sw, host_texture, update_display)) return false;