From 90e285df2a4f569c97df81eefa5a93e32b67ed80 Mon Sep 17 00:00:00 2001 From: refractionpcsx2 Date: Sat, 8 Feb 2025 07:50:05 +0000 Subject: [PATCH] GS/HW: Add CRC fixes for DT Carnage/Racer/Axel Impact --- bin/resources/GameIndex.yaml | 17 +++++++- pcsx2/GS/Renderers/HW/GSHwHack.cpp | 55 ++++++++++++++++++++++++++ pcsx2/GS/Renderers/HW/GSHwHack.h | 1 + pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 2 +- 4 files changed, 73 insertions(+), 2 deletions(-) diff --git a/bin/resources/GameIndex.yaml b/bin/resources/GameIndex.yaml index 9ef791a3c7..c52c4f36a6 100644 --- a/bin/resources/GameIndex.yaml +++ b/bin/resources/GameIndex.yaml @@ -10365,9 +10365,14 @@ SCPS-56016: gameFixes: - GIFFIFOHack gsHWFixes: + halfPixelOffset: 2 # Fixes post processing position. + nativeScaling: 2 # Fixes post effects. estimateTextureRegion: 1 # Improves performance and reduces hash cache size. gpuPaletteConversion: 2 # Improves performance and reduces hash cache size. autoFlush: 1 # Corrects shadows (Currently still broken even with this). + recommendedBlendingLevel: 4 # Fixes car shadows but addeds about 5000 barriers, might impact slower machines. + gpuTargetCLUT: 2 # Fixes light flicker. + getSkipCount: "GSC_DTGames" SCPS-72001: name: "GRAN TURISMO3 A-spec [MEGA HITS!]" name-sort: "ぐらんつーりすも3 A-spec [MEGA HITS!]" @@ -23969,9 +23974,13 @@ SLES-53904: clampModes: vuClampMode: 0 # Fixes black artifacts on tracks gsHWFixes: + halfPixelOffset: 2 # Fixes post processing position. + nativeScaling: 2 # Fixes post effects. estimateTextureRegion: 1 # Improves performance and reduces hash cache size. gpuPaletteConversion: 2 # Improves performance and reduces hash cache size. autoFlush: 1 # Corrects shadows (Currently still broken even with this). + gpuTargetCLUT: 2 # Fixes light flicker. + getSkipCount: "GSC_DTGames" SLES-53906: name: "50 Cent - Bulletproof" region: "PAL-F" @@ -66754,9 +66763,13 @@ SLUS-21095: region: "NTSC-U" compat: 5 gsHWFixes: + halfPixelOffset: 2 # Fixes post processing position. + nativeScaling: 2 # Fixes post effects. estimateTextureRegion: 1 # Improves performance and reduces hash cache size. gpuPaletteConversion: 2 # Improves performance and reduces hash cache size. autoFlush: 1 # Corrects shadows (Currently still broken even with this). + gpuTargetCLUT: 2 # Fixes light flicker. + getSkipCount: "GSC_DTGames" SLUS-21096: name: "Ape Escape - Pumped & Primed" region: "NTSC-U" @@ -70873,10 +70886,12 @@ SLUS-21793: compat: 3 gsHWFixes: halfPixelOffset: 2 # Fixes post processing position. - nativeScaling: 1 # Fixes post effects. + nativeScaling: 2 # Fixes post effects. estimateTextureRegion: 1 # Improves performance and reduces hash cache size. gpuPaletteConversion: 2 # Improves performance and reduces hash cache size. autoFlush: 1 # Corrects shadows (Currently still broken even with this). + gpuTargetCLUT: 2 # Fixes light flicker. + getSkipCount: "GSC_DTGames" SLUS-21794: name: "Go, Diego, Go! Great Dinosaur Rescue" region: "NTSC-U" diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.cpp b/pcsx2/GS/Renderers/HW/GSHwHack.cpp index 2d7239692d..e395b1484d 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.cpp +++ b/pcsx2/GS/Renderers/HW/GSHwHack.cpp @@ -154,6 +154,60 @@ bool GSHwHack::GSC_SFEX3(GSRendererHW& r, int& skip) return true; } +bool GSHwHack::GSC_DTGames(GSRendererHW& r, int& skip) +{ + if (skip == 0) + { + // The game does a shuffle based on the result of a copy from the depth buffer, which ends up looking bizzare so PCSX2 doesn't know how to deal with it. + // What they're actually doing is copying the red/green channel of the result (kind of a shadow stencil) to the alpha channel. + // The further problem to this is the limitation of alpha we can save on an RT as they copy in 255, so I can cheese it here pretending it's RTA'd + if (RTME && RFPSM == PSMCT32 && RTBP0 == RFBP && RTPSM == PSMCT16 && RTEST.ATE && RTEST.ATST == ATST_NEVER && RTEST.AFAIL == AFAIL_FB_ONLY && RFBMSK == 0xFFFFFF) + { + GSTextureCache::Target* rt = g_texture_cache->LookupTarget(GIFRegTEX0::Create(RTBP0, RFBW, RFPSM), + GSVector2i(1, 1), r.GetTextureScaleFactor(), GSTextureCache::RenderTarget); + + if (!rt) + return false; + + // Clear down the alpha first. + GSHWDrawConfig& clear = r.BeginHLEHardwareDraw( + rt->GetTexture(), nullptr, rt->GetScale(), nullptr, rt->GetScale(), rt->GetUnscaledRect()); + clear.colormask.wrgba = 0; + clear.colormask.wa = 1; + r.EndHLEHardwareDraw(false); + + // Shuffle the green channel in to alpha. + GSHWDrawConfig& config = r.BeginHLEHardwareDraw( + rt->GetTexture(), nullptr, rt->GetScale(), rt->GetTexture(), rt->GetScale(), rt->GetUnscaledRect()); + config.ps.shuffle = 1; + config.ps.dst_fmt = GSLocalMemory::PSM_FMT_32; + config.ps.write_rg = 0; + config.ps.shuffle_same = 0; + config.ps.real16src = 0; + config.ps.shuffle_across = 1; + config.ps.process_rg = r.SHUFFLE_READ; + config.ps.process_ba = r.SHUFFLE_WRITE; + config.colormask.wrgba = 0; + config.colormask.wa = 1; + config.ps.rta_correction = 1; + config.ps.tfx = TFX_DECAL; + config.ps.tcc = true; + r.EndHLEHardwareDraw(true); + + rt->m_alpha_min = 0; + rt->m_alpha_max = 255; + skip = 69; + } + } + else + { + if (RTPSM != PSMCT16) + skip = 0; + } + + return true; +} + bool GSHwHack::GSC_Tekken5(GSRendererHW& r, int& skip) { if (skip == 0) @@ -1471,6 +1525,7 @@ const GSHwHack::Entry GSHwHack::s_get_skip_count_function CRC_F(GSC_SakuraWarsSoLongMyLove), CRC_F(GSC_Simple2000Vol114), CRC_F(GSC_SFEX3), + CRC_F(GSC_DTGames), CRC_F(GSC_TalesOfLegendia), CRC_F(GSC_TalesofSymphonia), CRC_F(GSC_UrbanReign), diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.h b/pcsx2/GS/Renderers/HW/GSHwHack.h index 2da65232a1..11d36c17da 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.h +++ b/pcsx2/GS/Renderers/HW/GSHwHack.h @@ -11,6 +11,7 @@ public: static bool GSC_Manhunt2(GSRendererHW& r, int& skip); static bool GSC_SacredBlaze(GSRendererHW& r, int& skip); static bool GSC_SFEX3(GSRendererHW& r, int& skip); + static bool GSC_DTGames(GSRendererHW& r, int& skip); static bool GSC_Tekken5(GSRendererHW& r, int& skip); static bool GSC_BurnoutGames(GSRendererHW& r, int& skip); static bool GSC_BlackAndBurnoutSky(GSRendererHW& r, int& skip); diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 8dd044e047..65a0eea5e7 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -554,7 +554,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(u32& process_rg, u32& process_ba, } else { - if ((floor(m_vt.m_max.p.y) <= rt->m_valid.w) && ((floor(m_vt.m_max.p.x) > (m_cached_ctx.FRAME.FBW * 64)) || (rt->m_TEX0.TBW != m_cached_ctx.FRAME.FBW))) + if (((m_r.width() + 8) & ~(GSLocalMemory::m_psm[m_cached_ctx.FRAME.PSM].pgs.x - 1)) != GSLocalMemory::m_psm[m_cached_ctx.FRAME.PSM].pgs.x && (floor(m_vt.m_max.p.y) <= rt->m_valid.w) && ((floor(m_vt.m_max.p.x) > (m_cached_ctx.FRAME.FBW * 64)) || (rt->m_TEX0.TBW < m_cached_ctx.FRAME.FBW))) { half_bottom_vert = false; half_bottom_uv = false;