From 3968a82775908a77bc1a338d5bb1c3ac172e01dd Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 4 May 2023 18:50:57 +1000 Subject: [PATCH] GS/HW: Turn GT4 CRC hack into a GSC instead Keep the hacks with the rest of the hacks. --- bin/resources/GameIndex.yaml | 85 ++++++++++-- pcsx2/GS/GSCrc.cpp | 36 ----- pcsx2/GS/GSCrc.h | 1 - pcsx2/GS/Renderers/HW/GSHwHack.cpp | 46 +++++++ pcsx2/GS/Renderers/HW/GSHwHack.h | 1 + pcsx2/GS/Renderers/HW/GSRendererHW.cpp | 162 +++++++++++++++++++---- pcsx2/GS/Renderers/HW/GSRendererHW.h | 7 + pcsx2/GS/Renderers/HW/GSTextureCache.cpp | 77 ++--------- pcsx2/GS/Renderers/HW/GSTextureCache.h | 2 + 9 files changed, 277 insertions(+), 140 deletions(-) diff --git a/bin/resources/GameIndex.yaml b/bin/resources/GameIndex.yaml index ffc1f9a8b1..507c15fca6 100644 --- a/bin/resources/GameIndex.yaml +++ b/bin/resources/GameIndex.yaml @@ -114,6 +114,8 @@ PAPX-90202: PAPX-90203: name: "Gran Turismo 2000 [Trial]" region: "NTSC-J" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. PAPX-90215: name: "Ka [Trial]" region: "NTSC-J" @@ -141,6 +143,8 @@ PAPX-90231: PAPX-90504: name: "Gran Turismo Concept - Airtrek Turbo Special Edition [Demo]" region: "NTSC-J" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. PAPX-90505: name: "2002 Natsu no Osusume Soft Otameshi Disc" region: "NTSC-J" @@ -158,11 +162,12 @@ PAPX-90512: region: "NTSC-J" clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. - # eeClampMode = 3 Text in races works. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. PAPX-90516: name: "Jak and Daxter II [Trial]" region: "NTSC-J" @@ -272,6 +277,8 @@ PBPX-95503: memcardFilters: - "PBPX-95503" - "SCUS-97102" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. PBPX-95506: name: "PlayStation 2 - Demo Disc 2001" region: "PAL-M5" @@ -311,6 +318,7 @@ PBPX-95523: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. # eeClampMode = 3 Text in races works. # vuClampMode = 2 Text in GT mode works. PBPX-95524: @@ -321,6 +329,7 @@ PBPX-95524: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. # eeClampMode = 3 Text in races works. # vuClampMode = 2 Text in GT mode works. PBPX-95601: @@ -333,6 +342,7 @@ PBPX-95601: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -354,6 +364,8 @@ PCPX-96306: PCPX-96311: name: "Gran Turismo 3 Trial Disk Volume 1" region: "NTSC-J" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. PCPX-96317: name: "Ka [Trial]" region: "NTSC-J" @@ -393,12 +405,15 @@ PCPX-96649: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. # eeClampMode = 3 Text in races works. PCPX-96660: name: "Tourist Trophy [Demo]" region: "NTSC-J" clampModes: vuClampMode: 2 # Fixes SPS in TT Mode menu caused by the moving tooltips. + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. PCPX-98017: name: "Ratchet & Clank - Giri Giri Ginga no Giga Battle [Demo]" region: "NTSC-J" @@ -749,6 +764,7 @@ SCAJ-20066: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -1361,6 +1377,8 @@ SCAJ-20170: compat: 5 clampModes: vuClampMode: 2 # Fixes SPS in TT Mode menu caused by the moving tooltips. + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCAJ-20171: name: "Zettai Zetsumei Toshi 2 - Itetsuita Kioku Tachi" region: "NTSC-J" @@ -1602,6 +1620,7 @@ SCAJ-30006: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -1620,20 +1639,24 @@ SCAJ-30007: compat: 5 clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. - # eeClampMode = 3 Text in races works. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCAJ-30008: name: "Gran Turismo 4 [PlayStation 2 The Best]" region: "NTSC-Unk" clampModes: vuClampMode: 2 # Text in GT mode works. + # Comments from old GameIndex.dbf for this Game. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -1645,8 +1668,6 @@ SCAJ-30008: - "SCPS-19304" - "SCPS-15009" - "SCPS-55007" - # Comments from old GameIndex.dbf for this Game. - # eeClampMode = 3 Text in races works. SCAJ-30010: name: "God of War" region: "NTSC-E" @@ -1742,6 +1763,7 @@ SCCS-60002: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCED-50041: name: "Tekken Tag Tournament [Demo]" region: "PAL-E" @@ -2351,6 +2373,7 @@ SCED-52578: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCED-52619: name: "Official PlayStation 2 Magazine Demo 48" region: "PAL-M5" @@ -2361,6 +2384,7 @@ SCED-52681: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCED-52687: name: "Formula One 04 [Demo]" region: "PAL-M11" @@ -2997,6 +3021,8 @@ SCES-50294: name: "Gran Turismo 3 - A-Spec" region: "PAL-M5" compat: 5 + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCES-50295: name: "Dark Cloud" region: "PAL-M5" @@ -3581,15 +3607,16 @@ SCES-51719: compat: 5 clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCES-51719" - "SCES-52438" - "SCES-50294" - # eeClampMode = 3 Text in races works. SCES-51725: name: "Everquest Online Adventures" region: "PAL-M3" @@ -3820,6 +3847,7 @@ SCES-52438: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCES-51719" - "SCES-52438" @@ -4136,6 +4164,8 @@ SCES-53372: compat: 5 clampModes: vuClampMode: 2 # Fixes SPS in TT Mode menu caused by the moving tooltips. + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCES-53397: name: "SingStar Pop - World Events Code" region: "PAL-Unk" @@ -5101,6 +5131,7 @@ SCKA-20022: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. # eeClampMode = 3 Text in races works. # vuClampMode = 2 Text in GT mode works. SCKA-20023: @@ -5143,6 +5174,8 @@ SCKA-20028: SCKA-20029: name: "Gran Turismo Concept 2002 Tokyo-Seoul [PlayStation 2 Big Hit Series]" region: "NTSC-K" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCKA-20030: name: "Sly Cooper - Jeonseolui Bibeobseoreul Chajaseo" region: "NTSC-K" @@ -5567,11 +5600,12 @@ SCKA-30001: region: "NTSC-K" clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. - # eeClampMode = 3 Text in races works. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCKA-30002: name: "God of War" region: "NTSC-K" @@ -5595,6 +5629,8 @@ SCPM-85101: SCPM-85301: name: "Gran Turismo Concept - Copen Special Edition [Demo]" region: "NTSC-J" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCPN-60101: name: "PlayStation BB Navigator - Version 0.10 [Prerelease] [Disc 1]" region: "NTSC-J" @@ -5791,6 +5827,8 @@ SCPS-15008: SCPS-15009: name: "Gran Turismo 3 - A-Spec" region: "NTSC-J" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCPS-15010: name: "Gran Turismo - Concept 2001 Tokyo" region: "NTSC-J" @@ -5995,6 +6033,7 @@ SCPS-15055: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -6316,6 +6355,8 @@ SCPS-15105: region: "NTSC-J" clampModes: vuClampMode: 2 # Fixes SPS in TT Mode menu caused by the moving tooltips. + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCPS-15106: name: "Siren 2" region: "NTSC-J" @@ -6396,10 +6437,12 @@ SCPS-17001: compat: 5 clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -6411,7 +6454,6 @@ SCPS-17001: - "SCPS-19304" - "SCPS-15009" - "SCPS-55007" - # eeClampMode = 3 Text in races works. SCPS-17002: name: "Wild ARMs - Alter Code F" region: "NTSC-J" @@ -6575,10 +6617,12 @@ SCPS-19252: region: "NTSC-J" clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -6590,7 +6634,6 @@ SCPS-19252: - "SCPS-19304" - "SCPS-15009" - "SCPS-55007" - # eeClampMode = 3 Text in races works. SCPS-19253: name: "Wild ARMs - Alter Code F [PlayStation 2 The Best - Reprint]" region: "NTSC-J" @@ -6626,6 +6669,7 @@ SCPS-19304: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCAJ-20066" - "SCAJ-30006" @@ -6820,6 +6864,8 @@ SCPS-19324: region: "NTSC-J" clampModes: vuClampMode: 2 # Fixes SPS in TT Mode menu caused by the moving tooltips. + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCPS-19325: name: "Ape Escape - Million Monkeys [PlayStation 2 The Best]" region: "NTSC-J" @@ -6955,6 +7001,8 @@ SCPS-55006: SCPS-55007: name: "Gran Turismo 3 - A-Spec" region: "NTSC-J" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCPS-55008: name: "Thunderstrike" region: "NTSC-J" @@ -7213,6 +7261,8 @@ SCPS-56004: SCPS-56005: name: "Gran Turismo Concept 2002 Tokyo-Seoul" region: "NTSC-K" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCPS-56006: name: "Tekken 4" region: "NTSC-K" @@ -7315,6 +7365,8 @@ SCUS-97102: name: "Gran Turismo 3 - A-Spec" region: "NTSC-U" compat: 5 + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCUS-97104: name: "ATV Offroad Fury" region: "NTSC-U" @@ -7370,6 +7422,8 @@ SCUS-97114: SCUS-97115: name: "Gran Turismo 3 - A-Spec [Demo]" region: "NTSC-U" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCUS-97116: name: "Kiosk Demo Disc 2.01" region: "NTSC-U" @@ -7769,6 +7823,8 @@ SCUS-97219: memcardFilters: - "SCUS-97219" - "SCUS-97102" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCUS-97220: name: "NHL FaceOff 2003" region: "NTSC-U" @@ -8085,17 +8141,18 @@ SCUS-97328: compat: 5 clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: # Allows car imports from GT3 or something. - "SCUS-97328" - "SCUS-97436" - "SCUS-97102" - "SCUS-97219" - "SCUS-97512" - # eeClampMode = 3 Text in races works. SCUS-97329: name: "Downhill Domination [Demo]" region: "NTSC-U" @@ -8470,17 +8527,18 @@ SCUS-97436: region: "NTSC-U" clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. memcardFilters: - "SCUS-97328" - "SCUS-97436" - "SCUS-97102" - "SCUS-97219" - "SCUS-97512" - # eeClampMode = 3 Text in races works. SCUS-97437: name: "ATV Offroad Fury 3 [Demo]" region: "NTSC-U" @@ -8680,11 +8738,12 @@ SCUS-97483: region: "NTSC-U" clampModes: vuClampMode: 2 # Text in GT mode works. + # eeClampMode = 3 Text in races works. gsHWFixes: mipmap: 2 # Mipmap + trilinear, improves ground textures to match sw renderer. trilinearFiltering: 1 halfPixelOffset: 1 # Fixes weird edge shadows and depth bleed which happens on the edge as well. - # eeClampMode = 3 Text in races works. + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCUS-97484: name: "Sly 3 - Honor Among Thieves [E3 Demo]" region: "NTSC-U" @@ -8800,6 +8859,8 @@ SCUS-97502: compat: 5 clampModes: vuClampMode: 2 # Fixes SPS in TT Mode menu caused by the moving tooltips. + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCUS-97503: name: "MLB '06 - The Show [Demo]" region: "NTSC-U" @@ -8844,6 +8905,8 @@ SCUS-97512: memcardFilters: - "SCUS-97512" - "SCUS-97102" + gsHWFixes: + getSkipCount: "GSC_PolyphonyDigitalGames" # Fixes post processing. SCUS-97513: name: "Ratchet & Clank 2 - Going Commando [Greatest Hits]" region: "NTSC-U" diff --git a/pcsx2/GS/GSCrc.cpp b/pcsx2/GS/GSCrc.cpp index 7a590bb83e..2365e065ac 100644 --- a/pcsx2/GS/GSCrc.cpp +++ b/pcsx2/GS/GSCrc.cpp @@ -31,42 +31,6 @@ const CRC::Game CRC::m_games[] = {0x5C991F4E, ICO /* EU */}, {0x788D8B4F, ICO /* EU */}, {0x29C28734, ICO /* CH */}, - {0x60013EBD, PolyphonyDigitalGames /* EU */}, // Gran Turismo Concept - {0x6810C3BC, PolyphonyDigitalGames /* CH */}, // Gran Turismo Concept 2002 Tokyo-Geneva - {0x0EEF32A3, PolyphonyDigitalGames /* KO */}, // Gran Turismo Concept 2002 Tokyo-Seoul - {0x3E9D448A, PolyphonyDigitalGames /* CH */}, // GT3 - {0xAD66643C, PolyphonyDigitalGames /* CH */}, // GT3 - {0x85AE91B3, PolyphonyDigitalGames /* US */}, // GT3 - {0x8AA991B0, PolyphonyDigitalGames /* US */}, // GT3 - {0xC220951A, PolyphonyDigitalGames /* JP */}, // GT3 - {0x9DE5CF65, PolyphonyDigitalGames /* JP */}, // GT3 - {0x706DFF80, PolyphonyDigitalGames /* JP */}, // GT3 Store Disc Vol. 2 - {0x55CE5111, PolyphonyDigitalGames /* JP */}, // Gran Turismo 2000 Body Omen - {0xE9A7E08D, PolyphonyDigitalGames /* JP */}, // Gran Turismo 2000 Body Omen - {0xB590CE04, PolyphonyDigitalGames /* EU */}, // GT3 - {0xC02C653E, PolyphonyDigitalGames /* CH */}, // GT4 - {0x7ABDBB5E, PolyphonyDigitalGames /* CH */}, // GT4 - {0xAEAD1CA3, PolyphonyDigitalGames /* JP */}, // GT4 - {0xA3AF15A0, PolyphonyDigitalGames /* JP */}, // GT4 PS2 Racing Pack - {0xE906EA37, PolyphonyDigitalGames /* JP */}, // GT4 First Preview - {0xCA6243B9, PolyphonyDigitalGames /* JP */}, // GT4 Prologue - {0xDD764BBE, PolyphonyDigitalGames /* JP */}, // GT4 Prologue - {0xE1258846, PolyphonyDigitalGames /* JP */}, // GT4 Prologue - {0x27B8F05F, PolyphonyDigitalGames /* JP */}, // GT4 Prius Trial Version - {0x30E41D93, PolyphonyDigitalGames /* KO */}, // GT4 - {0x715CF2EC, PolyphonyDigitalGames /* EU */}, // GT4 - {0x44A61C8F, PolyphonyDigitalGames /* EU */}, // GT4 - {0x0086E35B, PolyphonyDigitalGames /* EU */}, // GT4 - {0x3FB69323, PolyphonyDigitalGames /* EU */}, // GT4 Prologue - {0x77E61C8A, PolyphonyDigitalGames /* US */}, // GT4 - {0x33C6E35E, PolyphonyDigitalGames /* US */}, // GT4 - {0x70538747, PolyphonyDigitalGames /* US */}, // GT4 Toyota Prius Trial - {0x32A1C752, PolyphonyDigitalGames /* US */}, // GT4 Online Beta - {0x2A84A1E2, PolyphonyDigitalGames /* US */}, // GT4 Mazda MX-5 Edition - {0x0087EEC4, PolyphonyDigitalGames /* NoRegion */}, // GT4 Online Beta, JP and US versions have the same CRC - {0x5AC7E79C, PolyphonyDigitalGames /* CH */}, // TouristTrophy - {0xFF9C0E93, PolyphonyDigitalGames /* US */}, // TouristTrophy - {0xCA9AA903, PolyphonyDigitalGames /* EU */}, // TouristTrophy {0xFC46EA61, Tekken5 /* JP */}, {0x1F88EE37, Tekken5 /* EU */}, {0x1F88BECD, Tekken5 /* EU */}, // language selector... diff --git a/pcsx2/GS/GSCrc.h b/pcsx2/GS/GSCrc.h index 865faffa52..f232a6ddbd 100644 --- a/pcsx2/GS/GSCrc.h +++ b/pcsx2/GS/GSCrc.h @@ -25,7 +25,6 @@ public: NoTitle, GetawayGames, ICO, - PolyphonyDigitalGames, SMTNocturne, Tekken5, TitleCount, diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.cpp b/pcsx2/GS/Renderers/HW/GSHwHack.cpp index 0297425192..b0069487dc 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.cpp +++ b/pcsx2/GS/Renderers/HW/GSHwHack.cpp @@ -771,6 +771,51 @@ bool GSHwHack::GSC_NFSUndercover(GSRendererHW& r, int& skip) return false; } +bool GSHwHack::GSC_PolyphonyDigitalGames(GSRendererHW& r, int& skip) +{ + // These games appear to grab red and write it to a new page-sized render target, then + // grab green and blue, with alpha blending turned on, to accumulate them to the temporary + // target, then copy the temporary target back to the main FB. The CLUT is set to an offset + // ramp texture, presumably this is for screen brightness. + + const bool is_cs = r.IsPossibleChannelShuffle(); + if (r.m_channel_shuffle && is_cs) + { + skip = true; + return true; + } + else if (!is_cs) + { + return false; + } + + GL_PUSH("GSC_PolyphonyDigitalGames(): HLE Gran Turismo RGB channel shuffle"); + + GSTextureCache::Target* tex = g_texture_cache->LookupTarget(RTEX0, GSVector2i(1, 1), r.GetTextureScaleFactor(), GSTextureCache::RenderTarget); + if (!tex) + return false; + + // 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(GSLocalMemory::m_psm[RTEX0.PSM].pal, true); + if (!palette) + return false; + + // skip this draw, and until the end of the CS, ignoring fbmsk and cbp + r.m_channel_shuffle = true; + skip = 1; + + GSHWDrawConfig& config = r.BeginHLEHardwareDraw( + tex->GetTexture(), nullptr, tex->GetScale(), tex->GetTexture(), tex->GetScale(), tex->GetUnscaledRect()); + config.pal = palette->GetPaletteGSTexture(); + config.ps.channel = ChannelFetch_RGB; + config.colormask.wrgba = 1 | 2 | 4; + r.EndHLEHardwareDraw(false); + + return true; +} + bool GSHwHack::GSC_BlueTongueGames(GSRendererHW& r, int& skip) { GSDrawingContext* context = r.m_context; @@ -1173,6 +1218,7 @@ const GSHwHack::Entry GSHwHack::s_get_skip_count_function CRC_F(GSC_BlueTongueGames, CRCHackLevel::Partial), CRC_F(GSC_Battlefield2, CRCHackLevel::Partial), CRC_F(GSC_NFSUndercover, CRCHackLevel::Partial), + CRC_F(GSC_PolyphonyDigitalGames, CRCHackLevel::Partial), // Channel Effect CRC_F(GSC_GiTS, CRCHackLevel::Partial), diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.h b/pcsx2/GS/Renderers/HW/GSHwHack.h index 7d5685d075..6c9ab028ca 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.h +++ b/pcsx2/GS/Renderers/HW/GSHwHack.h @@ -52,6 +52,7 @@ public: static bool GSC_BlueTongueGames(GSRendererHW& r, int& skip); static bool GSC_Battlefield2(GSRendererHW& r, int& skip); static bool GSC_NFSUndercover(GSRendererHW& r, int& skip); + static bool GSC_PolyphonyDigitalGames(GSRendererHW& r, int& skip); static bool OI_PointListPalette(GSRendererHW& r, GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t); static bool OI_BigMuthaTruckers(GSRendererHW& r, GSTexture* rt, GSTexture* ds, GSTextureCache::Source* t); diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 8b1a751c9d..3c00641621 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -2745,29 +2745,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::PolyphonyDigitalGames) - { - // These games appear to grab red and write it to a new page-sized render target, then - // grab green and blue, with alpha blending turned on, to accumulate them to the temporary - // target, then copy the temporary target back to the main FB. The CLUT is set to an offset - // ramp texture, presumably this is for screen brightness. - GL_INS("Gran Turismo RGB Channel"); - if (test_only) - { - // Since test_only gets executed when creating a source, before target lookup, we can hack - // the FBP here to point to the source, which is where it will eventually be copied back to. - // We need to force it to PSMCT24, the crossfade draw ends up reading the RT instead of local - // memory, which ends up with blue rubbish becuase the shuffle isn't correctly emulated. - pxAssertMsg((m_context->TEX0.TBP0 & 31) == 0, "TEX0 should be page aligned"); - m_cached_ctx.FRAME.FBP = m_context->TEX0.TBP0 >> 5; - m_cached_ctx.FRAME.PSM = PSMCT24; - return true; - } - - m_conf.ps.channel = ChannelFetch_RGB; - m_cached_ctx.TEX0.TFX = TFX_DECAL; - } - else if (m_game.title == CRC::Tekken5) + if (m_game.title == CRC::Tekken5) { if (m_cached_ctx.FRAME.FBW == 1) { @@ -5246,3 +5224,141 @@ bool GSRendererHW::IsConstantDirectWriteMemClear() return false; } + +GSHWDrawConfig& GSRendererHW::BeginHLEHardwareDraw( + GSTexture* rt, GSTexture* ds, float rt_scale, GSTexture* tex, float tex_scale, const GSVector4i& unscaled_rect) +{ + ResetStates(); + + // Bit gross, but really no other way to ensure there's nothing of the last draw left over. + GSHWDrawConfig& config = m_conf; + std::memset(&config.cb_vs, 0, sizeof(config.cb_vs)); + std::memset(&config.cb_ps, 0, sizeof(config.cb_ps)); + + // Reused between draws, since the draw config is shared, you can't have multiple draws in flight anyway. + static GSVertex vertices[4]; + static constexpr u16 indices[6] = {0, 1, 2, 2, 1, 3}; + +#define V(i, x, y, u, v) \ + do \ + { \ + vertices[i].XYZ.X = x; \ + vertices[i].XYZ.Y = y; \ + vertices[i].U = u; \ + vertices[i].V = v; \ + } while (0) + + const GSVector4i fp_rect = unscaled_rect.sll32(4); + V(0, fp_rect.x, fp_rect.y, fp_rect.x, fp_rect.y); // top-left + V(1, fp_rect.z, fp_rect.y, fp_rect.z, fp_rect.y); // top-right + V(2, fp_rect.x, fp_rect.w, fp_rect.x, fp_rect.w); // bottom-left + V(3, fp_rect.z, fp_rect.w, fp_rect.z, fp_rect.w); // bottom-right + +#undef V + + GSTexture* rt_or_ds = rt ? rt : ds; + config.rt = rt; + config.ds = ds; + config.tex = tex; + config.pal = nullptr; + config.indices = indices; + config.verts = vertices; + config.nverts = static_cast(std::size(vertices)); + config.nindices = static_cast(std::size(indices)); + config.indices_per_prim = 3; + config.drawlist = nullptr; + config.scissor = rt_or_ds->GetRect().rintersect(GSVector4i(GSVector4(rt->GetRect()) * tex_scale)); + config.drawarea = config.scissor; + config.topology = GSHWDrawConfig::Topology::Triangle; + config.blend = GSHWDrawConfig::BlendState(); + config.depth = GSHWDrawConfig::DepthStencilSelector::NoDepth(); + config.colormask = GSHWDrawConfig::ColorMaskSelector(); + config.colormask.wrgba = 0xf; + config.require_one_barrier = false; + config.require_full_barrier = false; + config.destination_alpha = GSHWDrawConfig::DestinationAlphaMode::Off; + config.datm = false; + config.line_expand = false; + config.separate_alpha_pass = false; + config.second_separate_alpha_pass = false; + config.alpha_second_pass.enable = false; + config.vs.key = 0; + config.vs.tme = tex != nullptr; + config.vs.iip = true; + config.vs.fst = true; + config.ps.key_lo = 0; + config.ps.key_hi = 0; + config.ps.tfx = tex ? TFX_DECAL : TFX_NONE; + config.ps.iip = true; + config.ps.fst = true; + + if (tex) + { + const GSVector2i texsize = tex->GetSize(); + config.cb_ps.WH = GSVector4(static_cast(texsize.x) / tex_scale, + static_cast(texsize.y) / tex_scale, static_cast(texsize.x), static_cast(texsize.y)); + config.cb_ps.STScale = GSVector2(1.0f); + config.cb_vs.texture_scale = GSVector2((1.0f / 16.0f) / config.cb_ps.WH.x, (1.0f / 16.0f) / config.cb_ps.WH.y); + } + + const GSVector2i rtsize = rt_or_ds->GetSize(); + config.cb_vs.vertex_scale = GSVector2(2.0f * rt_scale / (rtsize.x << 4), 2.0f * rt_scale / (rtsize.y << 4)); + config.cb_vs.vertex_offset = GSVector2(-1.0f / rtsize.x + 1.0f, -1.0f / rtsize.y + 1.0f); + + return config; +} + +void GSRendererHW::EndHLEHardwareDraw(bool force_copy_on_hazard /* = false */) +{ + GSHWDrawConfig& config = m_conf; + + GL_PUSH("HLE hardware draw in %d,%d => %d,%d", config.drawarea.left, config.drawarea.top, config.drawarea.right, + config.drawarea.bottom); + + GSTexture* copy = nullptr; + if (config.tex && (config.tex == config.rt || config.tex == config.ds)) + { + const GSDevice::FeatureSupport features = g_gs_device->Features(); + + if (!force_copy_on_hazard && config.tex == config.rt && features.texture_barrier) + { + // Sample RT 1:1. + config.require_one_barrier = !features.framebuffer_fetch; + config.ps.tex_is_fb = true; + } + else if (!force_copy_on_hazard && config.tex == config.ds && !config.depth.zwe && + features.test_and_sample_depth) + { + // Safe to read depth buffer. + } + else + { + // Have to copy texture. Assume the whole thing is read, in all the cases this is used, it is. + GSTexture* src = (config.tex == config.rt) ? config.rt : config.ds; + copy = g_gs_device->CreateTexture(src->GetWidth(), src->GetHeight(), 1, src->GetFormat(), true); + if (!copy) + { + Console.Error("Texture allocation failure in EndHLEHardwareDraw()"); + return; + } + + // DX11 can't partial copy depth textures. + const GSVector4i copy_rect = (src->IsDepthStencil() && !features.test_and_sample_depth) ? + src->GetRect() : + config.drawarea.rintersect(src->GetRect()); + g_gs_device->CopyRect(src, copy, copy_rect - copy_rect.xyxy(), copy_rect.x, copy_rect.y); + config.tex = copy; + } + } + + // Drop color1 if dual-source is not being used. + config.ps.no_color = !config.rt; + config.ps.no_color1 = !config.rt || !config.blend.enable || + (!GSDevice::IsDualSourceBlendFactor(config.blend.src_factor) && + !GSDevice::IsDualSourceBlendFactor(config.blend.dst_factor)); + + g_gs_device->RenderHW(m_conf); + + if (copy) + g_gs_device->Recycle(copy); +} diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.h b/pcsx2/GS/Renderers/HW/GSRendererHW.h index 826cbc29e0..5d3f4829e3 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.h +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.h @@ -193,4 +193,11 @@ public: /// Returns true if the specified texture address matches the frame or Z buffer. bool IsTBPFrameOrZ(u32 tbp) const; + + /// Starts a HLE'ed hardware draw, which can be further customized by the caller. + GSHWDrawConfig& BeginHLEHardwareDraw( + GSTexture* rt, GSTexture* ds, float rt_scale, GSTexture* tex, float tex_scale, const GSVector4i& unscaled_rect); + + /// Submits a previously set up HLE hardware draw, copying any textures as needed if there's hazards. + void EndHLEHardwareDraw(bool force_copy_on_hazard = false); }; diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index e17071076b..76678cde87 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -2581,80 +2581,14 @@ bool GSTextureCache::ShuffleMove(u32 BP, u32 BW, u32 PSM, int sx, int sy, int dx const bool read_ba = (diff_x < 0); const bool write_rg = (diff_x < 0); - const GSVector4i bbox(write_rg ? GSVector4i(dx, dy, dx + w, dy + h) : GSVector4i(sx, sy, sx + w, sy + h)); + const GSVector4i bbox = write_rg ? GSVector4i(dx, dy, dx + w, dy + h) : GSVector4i(sx, sy, sx + w, sy + h); - GSVertex vertices[4] = {}; -#define V(i, x, y, u, v) \ - do \ - { \ - vertices[i].XYZ.X = x; \ - vertices[i].XYZ.Y = y; \ - vertices[i].U = u; \ - vertices[i].V = v; \ - } while (0) - - const GSVector4i bbox_fp(bbox.sll32(4)); - V(0, bbox_fp.x, bbox_fp.y, bbox_fp.x, bbox_fp.y); // top-left - V(1, bbox_fp.z, bbox_fp.y, bbox_fp.z, bbox_fp.y); // top-right - V(2, bbox_fp.x, bbox_fp.w, bbox_fp.x, bbox_fp.w); // bottom-left - V(3, bbox_fp.z, bbox_fp.w, bbox_fp.z, bbox_fp.w); // bottom-right - -#undef V - - static constexpr u16 indices[6] = { 0, 1, 2, 2, 1, 3 }; - - // If we ever do this sort of thing somewhere else, extract this to a helper function. - GSHWDrawConfig config; - config.rt = tgt->m_texture; - config.ds = nullptr; - config.tex = tgt->m_texture; - config.pal = nullptr; - config.indices = indices; - config.verts = vertices; - config.nverts = static_cast(std::size(vertices)); - config.nindices = static_cast(std::size(indices)); - config.indices_per_prim = 3; - config.drawlist = nullptr; - config.scissor = GSVector4i(0, 0, tgt->m_texture->GetWidth(), tgt->m_texture->GetHeight()); - config.drawarea = GSVector4i(GSVector4(bbox) * GSVector4(tgt->m_scale)); - config.topology = GSHWDrawConfig::Topology::Triangle; - config.blend = GSHWDrawConfig::BlendState(); - config.depth = GSHWDrawConfig::DepthStencilSelector::NoDepth(); - config.colormask = GSHWDrawConfig::ColorMaskSelector(); + GSHWDrawConfig& config = GSRendererHW::GetInstance()->BeginHLEHardwareDraw(tgt->m_texture, nullptr, tgt->m_scale, tgt->m_texture, tgt->m_scale, bbox); config.colormask.wrgba = (write_rg ? (1 | 2) : (4 | 8)); - config.require_one_barrier = !g_gs_device->Features().framebuffer_fetch; - config.require_full_barrier = false; - config.destination_alpha = GSHWDrawConfig::DestinationAlphaMode::Off; - config.datm = false; - config.line_expand = false; - config.separate_alpha_pass = false; - config.second_separate_alpha_pass = false; - config.alpha_second_pass.enable = false; - config.vs.key = 0; - config.vs.tme = true; - config.vs.iip = true; - config.vs.fst = true; - config.ps.key_lo = 0; - config.ps.key_hi = 0; config.ps.read_ba = read_ba; config.ps.write_rg = write_rg; config.ps.shuffle = true; - config.ps.iip = true; - config.ps.fst = true; - config.ps.tex_is_fb = true; - config.ps.tfx = TFX_DECAL; - - const GSVector2i rtsize(tgt->m_texture->GetSize()); - const float rtscale = tgt->m_scale; - config.cb_ps.WH = GSVector4(static_cast(rtsize.x) / rtscale, static_cast(rtsize.y) / rtscale, - static_cast(rtsize.x), static_cast(rtsize.y)); - config.cb_ps.STScale = GSVector2(1.0f); - - config.cb_vs.vertex_scale = GSVector2(2.0f * rtscale / (rtsize.x << 4), 2.0f * rtscale / (rtsize.y << 4)); - config.cb_vs.vertex_offset = GSVector2(-1.0f / rtsize.x + 1.0f, -1.0f / rtsize.y + 1.0f); - config.cb_vs.texture_scale = GSVector2((1.0f / 16.0f) / config.cb_ps.WH.x, (1.0f / 16.0f) / config.cb_ps.WH.y); - - g_gs_device->RenderHW(config); + GSRendererHW::GetInstance()->EndHLEHardwareDraw(false); return true; } @@ -3871,6 +3805,11 @@ GSTexture* GSTextureCache::LookupPaletteSource(u32 CBP, u32 CPSM, u32 CBW, GSVec return nullptr; } +std::shared_ptr GSTextureCache::LookupPaletteObject(u16 pal, bool need_gs_texture) +{ + return m_palette_map.LookupPalette(pal, need_gs_texture); +} + void GSTextureCache::Read(Target* t, const GSVector4i& r) { if ((!t->m_dirty.empty() && !t->m_dirty.GetTotalRect(t->m_TEX0, t->m_unscaled_size).rintersect(r).rempty()) diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.h b/pcsx2/GS/Renderers/HW/GSTextureCache.h index e1eb311b0f..b5cae058ab 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.h +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.h @@ -142,6 +142,7 @@ public: bool m_32_bits_fmt = false; // Allow to detect the casting of 32 bits as 16 bits texture bool m_shared_texture = false; + __fi GSTexture* GetTexture() const { return m_texture; } __fi int GetUnscaledWidth() const { return m_unscaled_size.x; } __fi int GetUnscaledHeight() const { return m_unscaled_size.y; } __fi const GSVector2i& GetUnscaledSize() const { return m_unscaled_size; } @@ -435,6 +436,7 @@ public: void DirtyRectByPage(u32 sbp, u32 spsm, u32 sbw, Target* t, GSVector4i src_r); GSTexture* LookupPaletteSource(u32 CBP, u32 CPSM, u32 CBW, GSVector2i& offset, float* scale, const GSVector2i& size); + std::shared_ptr LookupPaletteObject(u16 pal, bool need_gs_texture); Source* LookupSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, const GSVector4i& r, const GSVector2i* lod); Source* LookupDepthSource(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, const GSVector4i& r, bool palette = false);