Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS/HW: Overhaul Texture Shuffle detection and improve target sizing/clearing #9745

Merged
merged 10 commits into from
Aug 11, 2023
Merged
101 changes: 55 additions & 46 deletions bin/resources/GameIndex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,8 @@ SCAJ-20010:
name: "Bakusou Dekotora Densetsu - Otoko Hanamichi Yume Roman"
region: "NTSC-Unk"
gsHWFixes:
beforeDraw: "OI_BigMuthaTruckers"
textureInsideRT: 1 # Fixes inside RT shuffling.
getSkipCount: "GSC_BigMuthaTruckers"
SCAJ-20011:
name: "Armored Core 3 - Silent Line"
region: "NTSC-HK"
Expand Down Expand Up @@ -10905,9 +10906,8 @@ SLAJ-25080:
name: "Godfather, The"
region: "NTSC-Unk"
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLAJ-25081:
name: "FIFA World Cup - Germany 2006"
region: "NTSC-Unk"
Expand Down Expand Up @@ -11460,11 +11460,16 @@ SLED-53664:
SLED-53673:
name: "007 - From Russia with Love [Demo]"
region: "PAL-E"
gsHWFixes:
textureInsideRT: 1 # Required for complex offset shuffles.
recommendedBlendingLevel: 4 # Fixes lighting.
SLED-53681:
name: "007 - From Russia with Love & Need for Speed Most Wanted & SSX On Tour [Demo]"
region: "PAL-E"
gsHWFixes:
halfPixelOffset: 2 # Fixes blurriness.
textureInsideRT: 1 # Required for complex offset shuffles on 007.
recommendedBlendingLevel: 4 # Fixes lighting in 007.
SLED-53711:
name: "Brothers in Arms - Earned in Blood"
region: "PAL-A"
Expand Down Expand Up @@ -14582,6 +14587,7 @@ SLES-51230:
region: "PAL-E"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light bleed through objects.
autoFlush: 1 # Fixes light bloom intensity.
SLES-51232:
name: "Virtua Tennis 2"
region: "PAL-M4"
Expand Down Expand Up @@ -14831,11 +14837,13 @@ SLES-51317:
region: "PAL-F"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light bleed through objects.
autoFlush: 1 # Fixes light bloom intensity.
SLES-51318:
name: "Minority Report"
region: "PAL-G"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light bleed through objects.
autoFlush: 1 # Fixes light bloom intensity.
SLES-51322:
name: "Robotech Battlecry"
region: "PAL-M5"
Expand Down Expand Up @@ -14915,7 +14923,8 @@ SLES-51355:
region: "PAL-M5"
compat: 5
gsHWFixes:
beforeDraw: "OI_BigMuthaTruckers"
textureInsideRT: 1 # Fixes inside RT shuffling.
getSkipCount: "GSC_BigMuthaTruckers"
SLES-51356:
name: "Road Trip Adventure"
region: "PAL-M3"
Expand Down Expand Up @@ -17582,21 +17591,18 @@ SLES-52588:
name: "Mercenaries - Playground of Destruction"
region: "PAL-E"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLES-52589:
name: "Mercenaries - Playground of Destruction"
region: "PAL-F"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLES-52590:
name: "Mercenaries - Playground of Destruction"
region: "PAL-G"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLES-52591:
Expand Down Expand Up @@ -18719,7 +18725,6 @@ SLES-53008:
name: "Mercenaries - Playground of Destruction"
region: "PAL-I-S"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLES-53009:
Expand Down Expand Up @@ -20266,6 +20271,9 @@ SLES-53552:
SLES-53553:
name: "007 - From Russia with Love"
region: "PAL-M7"
gsHWFixes:
textureInsideRT: 1 # Required for complex offset shuffles.
recommendedBlendingLevel: 4 # Fixes lighting.
SLES-53556:
name: "Driver - Parallel Lines"
region: "PAL-M3"
Expand Down Expand Up @@ -21415,37 +21423,32 @@ SLES-53967:
name: "Godfather, The"
region: "PAL-M6"
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLES-53968:
name: "Parrain, Le"
region: "PAL-F"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLES-53969:
name: "Pate, Der"
region: "PAL-G"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLES-53970:
name: "Padrino, Il"
region: "PAL-I"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLES-53971:
name: "Padrino, El"
region: "PAL-S"
gsHWFixes:
cpuCLUTRender: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLES-53972:
name: "Stock Car Crash"
region: "PAL-E"
Expand Down Expand Up @@ -27517,9 +27520,8 @@ SLKA-25338:
name: "Godfather, The"
region: "NTSC-K"
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLKA-25339:
name: "Jin Samguk Mussang 4"
region: "NTSC-K"
Expand Down Expand Up @@ -33315,7 +33317,8 @@ SLPM-65234:
name: "Bakusou Dekotora Densetsu - Otoko Hanamichi Yume Roman"
region: "NTSC-J"
gsHWFixes:
beforeDraw: "OI_BigMuthaTruckers"
textureInsideRT: 1 # Fixes inside RT shuffling.
getSkipCount: "GSC_BigMuthaTruckers"
SLPM-65235:
name: "New Roommania - Porori Seishun"
region: "NTSC-J"
Expand Down Expand Up @@ -35846,7 +35849,6 @@ SLPM-65942:
name: "Mercenaries - Playground of Destruction"
region: "NTSC-J"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLPM-65943:
Expand Down Expand Up @@ -37446,6 +37448,9 @@ SLPM-66321:
SLPM-66322:
name: "007 - Russia yori Ai o Komete"
region: "NTSC-J"
gsHWFixes:
textureInsideRT: 1 # Required for complex offset shuffles.
recommendedBlendingLevel: 4 # Fixes lighting.
SLPM-66323:
name: "Princess Software Collection, The"
region: "NTSC-J"
Expand Down Expand Up @@ -38043,7 +38048,6 @@ SLPM-66465:
name: "Mercenaries - Playground of Destruction [EA Best Hits]"
region: "NTSC-J"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLPM-66467:
Expand Down Expand Up @@ -39049,9 +39053,8 @@ SLPM-66710:
name: "Godfather, The"
region: "NTSC-J"
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLPM-66712:
name: "Rozen Maiden - Geppetto Garden [Limited Edition]"
region: "NTSC-J"
Expand Down Expand Up @@ -39991,9 +39994,8 @@ SLPM-66966:
name: "Godfather, The [EA-SY! 1980]"
region: "NTSC-J"
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLPM-66967:
name: "Aria - The Natural - Tooi Yume no Mirage [Alchemist Best Collection]"
region: "NTSC-J"
Expand Down Expand Up @@ -48247,7 +48249,8 @@ SLUS-20291:
region: "NTSC-U"
compat: 5
gsHWFixes:
beforeDraw: "OI_BigMuthaTruckers"
textureInsideRT: 1 # Fixes inside RT shuffling.
getSkipCount: "GSC_BigMuthaTruckers"
SLUS-20292:
name: "Tsugunai - Atonement"
region: "NTSC-U"
Expand Down Expand Up @@ -48432,6 +48435,7 @@ SLUS-20331:
compat: 5
gsHWFixes:
cpuCLUTRender: 1 # Fixes light bleed through objects.
autoFlush: 1 # Fixes light bloom intensity.
SLUS-20332:
name: "NCAA March Madness 2002"
region: "NTSC-U"
Expand Down Expand Up @@ -49829,7 +49833,8 @@ SLUS-20605:
name: "Big Mutha Truckers"
region: "NTSC-U"
gsHWFixes:
beforeDraw: "OI_BigMuthaTruckers"
textureInsideRT: 1 # Fixes inside RT shuffling.
getSkipCount: "GSC_BigMuthaTruckers"
SLUS-20606:
name: "Bounty Hunter - Seek & Destroy"
region: "NTSC-U"
Expand Down Expand Up @@ -51500,7 +51505,6 @@ SLUS-20932:
region: "NTSC-U"
compat: 5
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLUS-20933:
Expand Down Expand Up @@ -53505,6 +53509,9 @@ SLUS-21282:
name: "007 - From Russia with Love"
region: "NTSC-U"
compat: 5
gsHWFixes:
textureInsideRT: 1 # Required for complex offset shuffles.
recommendedBlendingLevel: 4 # Fixes lighting.
SLUS-21283:
name: "Total Overdose - A Gunslinger's Tale in Mexico"
region: "NTSC-U"
Expand Down Expand Up @@ -54162,9 +54169,8 @@ SLUS-21385:
region: "NTSC-U"
compat: 5
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLUS-21386:
name: "Tales of the Abyss"
region: "NTSC-U"
Expand Down Expand Up @@ -54277,9 +54283,8 @@ SLUS-21406:
name: "Godfather, The - Collector's Edition"
region: "NTSC-U"
gsHWFixes:
gpuTargetCLUT: 1 # Fixes light occlusion.
skipDrawStart: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
skipDrawEnd: 1 # Removes mono-colored sepia bottom and vertical sepia bars on top.
textureInsideRT: 1 # Required for complex offset shuffles.
halfPixelOffset: 2 # Fixes center line in post processing.
SLUS-21407:
name: "NFL Head Coach"
region: "NTSC-U"
Expand Down Expand Up @@ -57498,7 +57503,6 @@ SLUS-29137:
name: "Mercenaries - Playground of Destruction [Demo]"
region: "NTSC-U"
gsHWFixes:
halfBottomOverride: 1 # Bottom screen has wrong colors.
autoFlush: 2 # Fixes missing lighting.
# halfPixelOffset: 1 # Fixes lighting misalignment. Do not enable this, it breaks a lot of graphics.
SLUS-29138:
Expand Down Expand Up @@ -57633,9 +57637,14 @@ SLUS-29167:
region: "NTSC-U"
gsHWFixes:
halfPixelOffset: 2 # Fixes blurriness.
textureInsideRT: 1 # Required for complex offset shuffles in 007.
recommendedBlendingLevel: 4 # Fixes lighting in 007.
SLUS-29168:
name: "007 - From Russia with Love [Demo]"
region: "NTSC-U"
gsHWFixes:
textureInsideRT: 1 # Required for complex offset shuffles.
recommendedBlendingLevel: 4 # Fixes lighting.
SLUS-29169:
name: "Resident Evil 4 [Demo]"
region: "NTSC-U"
Expand Down
19 changes: 17 additions & 2 deletions bin/resources/shaders/dx11/tfx.fx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define PS_POINT_SAMPLER 0
#define PS_REGION_RECT 0
#define PS_SHUFFLE 0
#define PS_SHUFFLE_SAME 0
#define PS_READ_BA 0
#define PS_READ16_SRC 0
#define PS_DFMT 0
Expand Down Expand Up @@ -940,8 +941,22 @@ PS_OUTPUT ps_main(PS_INPUT input)
{
uint4 denorm_c = uint4(C);
uint2 denorm_TA = uint2(float2(TA.xy) * 255.0f + 0.5f);

if (PS_READ16_SRC)

// Special case for 32bit input and 16bit output, shuffle used by The Godfather.
if (PS_SHUFFLE_SAME)
{
if (PS_READ_BA)
{
C.ga = (float2)(float((denorm_c.b & 0x7Fu) | (denorm_c.a & 0x80u)));
C.rb = C.ga;
}
else
{
C.ga = C.rg;
C.rb = C.ga;
}
}
else if (PS_READ16_SRC)
{
C.rb = (float2)float((denorm_c.r >> 3) | (((denorm_c.g >> 3) & 0x7u) << 5));
if (denorm_c.a & 0x80u)
Expand Down
10 changes: 10 additions & 0 deletions bin/resources/shaders/opengl/tfx_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,15 @@ void ps_main()
#if PS_SHUFFLE
uvec4 denorm_c = uvec4(C);
uvec2 denorm_TA = uvec2(vec2(TA.xy) * 255.0f + 0.5f);
#if PS_SHUFFLE_SAME
lightningterror marked this conversation as resolved.
Show resolved Hide resolved
#if (PS_READ_BA)
C.ga = vec2(float((denorm_c.b & 0x7Fu) | (denorm_c.a & 0x80u)));
C.rb = C.ga;
#else
C.ga = C.rg;
C.rb = C.ga;
#endif
#else
#if PS_READ16_SRC
C.rb = vec2(float((denorm_c.r >> 3) | (((denorm_c.g >> 3) & 0x7u) << 5)));
if (bool(denorm_c.a & 0x80u))
Expand Down Expand Up @@ -995,6 +1004,7 @@ void ps_main()
#endif // PS_READ_BA

#endif // READ16_SRC
#endif // PS_SHUFFLE_SAME
#endif // PS_SHUFFLE

// Must be done before alpha correction
Expand Down
Loading