Skip to content

Commit

Permalink
Merge pull request #18461 from hrydgard/compat-allow-delayed-readback
Browse files Browse the repository at this point in the history
Add a compat.ini setting to allow delayed GPU readbacks
  • Loading branch information
hrydgard committed Dec 2, 2023
2 parents a981ea2 + 4ef5416 commit 5bd9437
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions Core/Compatibility.cpp
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions Core/Compatibility.h
Expand Up @@ -104,6 +104,7 @@ struct CompatFlags {
bool Fontltn12Hack;
bool LoadCLUTFromCurrentFrameOnly;
bool ForceUMDReadSpeed;
bool AllowDelayedReadbacks;
};

struct VRCompat {
Expand Down
12 changes: 10 additions & 2 deletions GPU/Common/FramebufferManagerCommon.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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<int>(srcX * srcXFactor), srcY, static_cast<int>(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<int>(srcX * srcXFactor), srcY, static_cast<int>(srcRect.w_bytes * srcXFactor), srcRect.h, RASTER_COLOR, readbackMode);
srcRect.vfb->usageFlags = (srcRect.vfb->usageFlags | FB_USAGE_DOWNLOAD) & ~FB_USAGE_DOWNLOAD_CLEAR;
}
}
Expand Down
12 changes: 9 additions & 3 deletions assets/compat.ini
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

0 comments on commit 5bd9437

Please sign in to comment.