From 16d073c4ad2fbad32ef242eebb6090b5fb699f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 24 Aug 2023 10:30:37 +0200 Subject: [PATCH] Add compat flag to not load CLUTs from old framebuffers --- Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + GPU/Common/TextureCacheCommon.cpp | 3 ++- assets/compat.ini | 11 +++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 11a404f7bc..58acbd7c69 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -132,6 +132,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "ForceMaxDepthResolution", &flags_.ForceMaxDepthResolution); CheckSetting(iniFile, gameID, "SOCOMClut8Replacement", &flags_.SOCOMClut8Replacement); CheckSetting(iniFile, gameID, "Fontltn12Hack", &flags_.Fontltn12Hack); + CheckSetting(iniFile, gameID, "LoadCLUTFromCurrentFrameOnly", &flags_.LoadCLUTFromCurrentFrameOnly); } void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index 896e8fa639..1079618c87 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -102,6 +102,7 @@ struct CompatFlags { bool ForceMaxDepthResolution; bool SOCOMClut8Replacement; bool Fontltn12Hack; + bool LoadCLUTFromCurrentFrameOnly; }; struct VRCompat { diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index d7ba813831..72d3d400ff 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1355,7 +1355,8 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) { // the framebuffer with the smallest offset. This is yet another framebuffer matching // loop with its own rules, eventually we'll probably want to do something // more systematic. - if (matchRange && !inMargin && offset < (int)clutRenderOffset_) { + bool okAge = !PSP_CoreParameter().compat.flags().LoadCLUTFromCurrentFrameOnly || framebuffer->last_frame_used == gpuStats.numFlips; + if (matchRange && !inMargin && offset < (int)clutRenderOffset_ && okAge) { WARN_LOG_N_TIMES(clutfb, 5, G3D, "Detected LoadCLUT(%d bytes) from framebuffer %08x (%s), byte offset %d, pixel offset %d", loadBytes, fb_address, GeBufferFormatToString(framebuffer->fb_format), offset, offset / fb_bpp); framebuffer->last_frame_clut = gpuStats.numFlips; diff --git a/assets/compat.ini b/assets/compat.ini index 756b95380c..684dba9510 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1593,3 +1593,14 @@ NPJG90068 = true # demo [Fontltn12Hack] #optimumFont do not return ltn12.pgf see #11055 NPJH00052 = true + +[LoadCLUTFromCurrentFrameOnly] +# Helps Syphon Filter: Logan's Shadow color issue, # where we accidentally load a CLUT from an outdated framebuffer. +# Perhaps this should be the default. +UCUS98606 = true +UCES00710 = true +NPUG80173 = true +NPUA80013 = true # Demo +UCUS98704 = true # Demo +NPEG90002 = true # Demo +SYPH04036 = true # Prototype?