From b2dc31ba80ef92508aa275f7e8e60b675070c208 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 30 Jul 2023 01:33:43 +1000 Subject: [PATCH] GS/HW: Move Tekken 5 CRC hack to the GSC --- pcsx2/GS/Renderers/HW/GSHwHack.cpp | 30 ++++++++++++++++++++++++ pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 32 +------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.cpp b/pcsx2/GS/Renderers/HW/GSHwHack.cpp index 7d86ddb815..b0c47d4c40 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.cpp +++ b/pcsx2/GS/Renderers/HW/GSHwHack.cpp @@ -195,6 +195,36 @@ bool GSHwHack::GSC_Tekken5(GSRendererHW& r, int& skip) { if (skip == 0) { + if (r.IsPossibleChannelShuffle()) + { + pxAssertMsg((RTBP0 & 31) == 0, "TEX0 should be page aligned"); + + GSTextureCache::Target* rt = g_texture_cache->LookupTarget(GIFRegTEX0::Create(RTBP0, RFBW, RFPSM), + GSVector2i(1, 1), r.GetTextureScaleFactor(), GSTextureCache::RenderTarget); + if (!rt) + return false; + + GL_INS("GSC_Tekken5(): HLE channel shuffle"); + + // have to set up the palette ourselves too, since GSC executes before it does + r.m_mem.m_clut.Read32(RTEX0, r.m_draw_env->TEXA); + std::shared_ptr palette = + g_texture_cache->LookupPaletteObject(r.m_mem.m_clut, GSLocalMemory::m_psm[RTEX0.PSM].pal, true); + if (!palette) + return false; + + GSHWDrawConfig& conf = r.BeginHLEHardwareDraw( + rt->GetTexture(), nullptr, rt->GetScale(), rt->GetTexture(), rt->GetScale(), rt->GetUnscaledRect()); + conf.pal = palette->GetPaletteGSTexture(); + conf.ps.channel = ChannelFetch_RGB; + conf.colormask.wa = false; + r.EndHLEHardwareDraw(false); + + // 12 pages: 2 calls by channel, 3 channels, 1 blit + skip = 12 * (3 + 3 + 1); + return true; + } + if (!s_nativeres && RTME && (RFBP == 0x02d60 || RFBP == 0x02d80 || RFBP == 0x02ea0 || RFBP == 0x03620 || RFBP == 0x03640) && RFPSM == RTPSM && RTBP0 == 0x00000 && RTPSM == PSMCT32) { // Don't enable hack on native res if crc is below aggressive. diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 181f550936..cfd29f80ec 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -3137,37 +3137,7 @@ bool GSRendererHW::TestChannelShuffle(GSTextureCache::Target* src) __ri bool GSRendererHW::EmulateChannelShuffle(GSTextureCache::Target* src, bool test_only) { - // First let's check we really have a channel shuffle effect - if (m_game.title == CRC::Tekken5) - { - if (m_cached_ctx.FRAME.FBW == 1) - { - // Used in stages: Secret Garden, Acid Rain, Moonlit Wilderness - GL_INS("Tekken5 RGB Channel"); - if (test_only) - { - pxAssertMsg((m_context->TEX0.TBP0 & 31) == 0, "TEX0 should be page aligned"); - m_cached_ctx.FRAME.FBP = m_context->TEX0.TBP0 >> 5; - return true; - } - - m_conf.ps.channel = ChannelFetch_RGB; - m_cached_ctx.FRAME.FBMSK = 0xFF000000; - // 12 pages: 2 calls by channel, 3 channels, 1 blit - // Minus current draw call - m_skip = 12 * (3 + 3 + 1) - 1; - } - else - { - // Could skip model drawing if wrongly detected - if (test_only) - return false; - - m_channel_shuffle = false; - return false; - } - } - else if ((src->m_texture->GetType() == GSTexture::Type::DepthStencil) && !src->m_32_bits_fmt) + if ((src->m_texture->GetType() == GSTexture::Type::DepthStencil) && !src->m_32_bits_fmt) { // So far 2 games hit this code path. Urban Chaos and Tales of Abyss // UC: will copy depth to green channel