From 89c96142a17d9ad7e5ad433bbeeb6516e411d6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 19 Aug 2022 00:34:02 +0200 Subject: [PATCH] Really not sure how we can detect whether a depth deswizzle is needed :( Hopefully temporary flag... --- Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + Core/CoreParameter.h | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 12 ++++++++++-- assets/compat.ini | 10 ++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index c56cf702f8..f17c1fd6a1 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -97,6 +97,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "ZZT3SelectHack", &flags_.ZZT3SelectHack); CheckSetting(iniFile, gameID, "AllowLargeFBTextureOffsets", &flags_.AllowLargeFBTextureOffsets); CheckSetting(iniFile, gameID, "AtracLoopHack", &flags_.AtracLoopHack); + CheckSetting(iniFile, gameID, "DeswizzleDepth", &flags_.DeswizzleDepth); } void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index c293fdfa17..29345aee42 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -87,6 +87,7 @@ struct CompatFlags { bool ZZT3SelectHack; bool AllowLargeFBTextureOffsets; bool AtracLoopHack; + bool DeswizzleDepth; }; class IniFile; diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index 7e9ea60b2e..9ef01c4d9b 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -66,7 +66,7 @@ struct CoreParameter { bool headLess; // Try to avoid messageboxes etc // Internal PSP rendering resolution and scale factor. - int renderScaleFactor; + int renderScaleFactor = 1; int renderWidth; int renderHeight; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index c1052b785d..1bfdafb5eb 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -551,7 +551,7 @@ void FramebufferManagerCommon::CopyToDepthFromOverlappingFramebuffers(VirtualFra // For now, let's just do the last thing, if there are multiple. // for (auto &source : sources) { - if (sources.size()) { + if (!sources.empty()) { auto &source = sources.back(); if (source.channel == RASTER_DEPTH) { // Good old depth->depth copy. @@ -563,11 +563,19 @@ void FramebufferManagerCommon::CopyToDepthFromOverlappingFramebuffers(VirtualFra if (src->drawnFormat != GE_FORMAT_565) { WARN_LOG_ONCE(not565, G3D, "Drawn format of buffer at %08x not 565 as expected", src->fb_address); } + + // Really hate to do this, but tracking the depth swizzle state across multiple + // copies is not easy. + Draw2DShader shader = DRAW2D_565_TO_DEPTH; + if (PSP_CoreParameter().compat.flags().DeswizzleDepth) { + shader = DRAW2D_565_TO_DEPTH_DESWIZZLE; + } + // Copying color to depth. BlitUsingRaster( src->fbo, 0.0f, 0.0f, src->renderWidth, src->renderHeight, dest->fbo, 0.0f, 0.0f, src->renderWidth, src->renderHeight, - false, DRAW2D_565_TO_DEPTH_DESWIZZLE, "565_to_depth"); + false, shader, "565_to_depth"); } } diff --git a/assets/compat.ini b/assets/compat.ini index c6011605d7..0903e52441 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1266,3 +1266,13 @@ ULES00618 = true # Silver Fall ULES00808 = true ULUS10270 = true + +[DeswizzleDepth] +UCUS98633 = true +UCAS40145 = true +UCES00420 = true +UCJS10052 = true +UCKS45048 = true +UCJS18030 = true +UCJS18047 = true +NPJG00015 = true