From 4ef54169af74f47d0000a45392eea450df553993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 2 Dec 2023 11:34:59 +0100 Subject: [PATCH] Add a compat.ini setting to allow delayed GPU readbacks, for experimentation. --- Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + GPU/Common/FramebufferManagerCommon.cpp | 12 ++++++++++-- assets/compat.ini | 12 +++++++++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 29a8874039..5e2c1205dd 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -134,6 +134,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "Fontltn12Hack", &flags_.Fontltn12Hack); CheckSetting(iniFile, gameID, "LoadCLUTFromCurrentFrameOnly", &flags_.LoadCLUTFromCurrentFrameOnly); CheckSetting(iniFile, gameID, "ForceUMDReadSpeed", &flags_.ForceUMDReadSpeed); + CheckSetting(iniFile, gameID, "AllowDelayedReadbacks", &flags_.AllowDelayedReadbacks); } void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index a917d17e5e..7cff655b0d 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -104,6 +104,7 @@ struct CompatFlags { bool Fontltn12Hack; bool LoadCLUTFromCurrentFrameOnly; bool ForceUMDReadSpeed; + bool AllowDelayedReadbacks; }; struct VRCompat { diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index e76c6ffa97..a3cdde39e8 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2125,7 +2125,11 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, if (srcH == 0 || srcY + srcH > srcBuffer->bufferHeight) { WARN_LOG_ONCE(btdcpyheight, G3D, "Memcpy fbo download %08x -> %08x skipped, %d+%d is taller than %d", src, dst, srcY, srcH, srcBuffer->bufferHeight); } else if (!g_Config.bSkipGPUReadbacks && (!srcBuffer->memoryUpdated || channel == RASTER_DEPTH)) { - ReadFramebufferToMemory(srcBuffer, 0, srcY, srcBuffer->width, srcH, channel, Draw::ReadbackMode::BLOCK); + Draw::ReadbackMode readbackMode = Draw::ReadbackMode::BLOCK; + if (PSP_CoreParameter().compat.flags().AllowDelayedReadbacks) { + readbackMode = Draw::ReadbackMode::OLD_DATA_OK; + } + ReadFramebufferToMemory(srcBuffer, 0, srcY, srcBuffer->width, srcH, channel, readbackMode); srcBuffer->usageFlags = (srcBuffer->usageFlags | FB_USAGE_DOWNLOAD) & ~FB_USAGE_DOWNLOAD_CLEAR; } return false; @@ -2649,7 +2653,11 @@ bool FramebufferManagerCommon::NotifyBlockTransferBefore(u32 dstBasePtr, int dst if (tooTall) { WARN_LOG_ONCE(btdheight, G3D, "Block transfer download %08x -> %08x dangerous, %d+%d is taller than %d", srcBasePtr, dstBasePtr, srcRect.y, srcRect.h, srcRect.vfb->bufferHeight); } - ReadFramebufferToMemory(srcRect.vfb, static_cast(srcX * srcXFactor), srcY, static_cast(srcRect.w_bytes * srcXFactor), srcRect.h, RASTER_COLOR, Draw::ReadbackMode::BLOCK); + Draw::ReadbackMode readbackMode = Draw::ReadbackMode::BLOCK; + if (PSP_CoreParameter().compat.flags().AllowDelayedReadbacks) { + readbackMode = Draw::ReadbackMode::OLD_DATA_OK; + } + ReadFramebufferToMemory(srcRect.vfb, static_cast(srcX * srcXFactor), srcY, static_cast(srcRect.w_bytes * srcXFactor), srcRect.h, RASTER_COLOR, readbackMode); srcRect.vfb->usageFlags = (srcRect.vfb->usageFlags | FB_USAGE_DOWNLOAD) & ~FB_USAGE_DOWNLOAD_CLEAR; } } diff --git a/assets/compat.ini b/assets/compat.ini index cac7e2377c..c0c1da77f0 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1649,7 +1649,7 @@ NPEG90002 = true # Demo SYPH04036 = true # Prototype? [ForceUMDReadSpeed] -# Aces of War required slow read speed (even in Real PSP) see #11062 +# Aces of War required slow read speed (even in Real PSP), see #11062 ULES00590 = true ULJM05075 = true # Sengoku Musou 3Z Special DLC see #9993 @@ -1660,11 +1660,11 @@ ULJM06024 = true NPUG30038 = true NPEG00036 = true -# Doko Demo Issho,load savedata error see #18420 +# Doko Demo Issho, load savedata error see #18420 UCJS10002 = true UCJS18002 = true -# Driver 76 ,see #16904 #12054 +# Driver 76, see #16904 #12054 ULUS10235 = true ULES00740 = true @@ -1682,3 +1682,9 @@ ULJS00290 = true ULKS46254 = true ULJS19057 = true NPJH50263 = true + +[AllowDelayedReadbacks] +# NOTE: This only affects Vulkan currently. +# Added for easy experimentation. Many games using readbacks do not work well delaying them, though. +# For example, Motorstorm lighting adaptation goes into self-oscillation (!) +# UCES01250 = true