Skip to content

GS/HW: Floor depth writes to improve Z testing#13795

Merged
lightningterror merged 2 commits intomasterfrom
gs_depthfloor
Jan 11, 2026
Merged

GS/HW: Floor depth writes to improve Z testing#13795
lightningterror merged 2 commits intomasterfrom
gs_depthfloor

Conversation

@refractionpcsx2
Copy link
Copy Markdown
Member

@refractionpcsx2 refractionpcsx2 commented Jan 9, 2026

This is only a test for now, further changes may be required or may become optional.

Description of Changes

Floors the depth write values to improve Z fighting, closer/accurate to software in a lot of cases.

Rationale behind Changes

On the PS2 you only have integer depth available, where in hardware, when we interpolate, we get a sliding scale of decimal values, which can lead to depth tests failing when they shouldn't. This improves this a lot.

Suggested Testing Steps

Test a whole host of games, make sure the Z fighting is better/closer to SW, where it's not caused by limited depth range. Could be worth checking games in #3692

Did you use AI to help find, test, or implement this issue or feature?

No

Fixes a lot of the problems on #11048 for MotoGP games, along with the changes in #13794
Fixes #12670 Haunting Ground
Fixes #6101 Rayman 3 (as good as software)
Improves #3692

Most notable changes:

Avatar Last Airbender (eyes were bad):
Master:
image

PR:
image

God Hand:
Master:
image

PR:
image

Harry Potter:
Master:
image

PR:
image

Haunting Ground (look in the door at the back):
Master:
image

PR:
image

Midnight Club 3:
Master:
image

PR:
image

MotoGP 3:
Master:
image

PR:
image

Need For Speed Undercover:
Master:
image

PR:
image

Need for Speed Underground 2:
Master:
image

PR:
image

Okami:
Master:
image

PR:
image

Rayman 3:
Master:
image

PR:
image

Sonic Heroes:
Master:
image

PR:
image

Tony Hawk Pro Skater 3:
Master:
image

PR:
image

@MarioSonic2987
Copy link
Copy Markdown

It fixes z-fighting in the following games:

  • Dragon Ball Z: Budokai Tenkaichi 3
  • Kingdom Hearts II

@GitHub-Khi
Copy link
Copy Markdown

Can you also test these 5 Multi Frame GS-Dumps that i tried to upload here? This file is online for 7 days.

@CookiePLMonster
Copy link
Copy Markdown
Contributor

Fixes Z-fighting in NASCAR Heat 2002.

Master:
NASCAR Heat 2002_SLUS-20176_20260109185054

PR:
NASCAR Heat 2002_SLUS-20176_20260109185403

@AmandaRoseChaqueta
Copy link
Copy Markdown

Reduces heavily the Z-Fighting on MH2Dos

Master:
Screenshot_20260109_140257

PR:
Screenshot_20260109_140336

@mrrguest
Copy link
Copy Markdown

mrrguest commented Jan 9, 2026

Fatal Frame 3:
Master:
Fatal Frame III - The Tormented_SLUS-21244_20260109140336
PR:
Fatal Frame III - The Tormented_SLUS-21244_20260109140403
Onimusha 3:
Master:
Onimusha 3 - Demon Siege_SLUS-20694_20260109141819
PR:
Onimusha 3 - Demon Siege_SLUS-20694_20260109141831

@Dreadmoth
Copy link
Copy Markdown
Contributor

Improves distant terrain in Transformers:

Master:

pcsx2-transformers-z-master.mp4

PR:

pcsx2-transformers-z-pr13795.mp4

👍

@refractionpcsx2
Copy link
Copy Markdown
Member Author

refractionpcsx2 commented Jan 9, 2026

@GitHub-Khi I have checked your dumps, the GT4 and GTA SA ones look identical to HW when running in SW, which means the PS2 will have the same kind of fighting/shimmer. I have however gotten footage of GTA Vice City, Midnight Club and Shadow of the Colossus.

All footage is Master HW, Master SW, PR HW. Looks like it fixes all of them (match sw/real machine) :)

GTAVC.mp4
MC3.mp4
SotC.mp4

@GitHub-Khi
Copy link
Copy Markdown

Many thanks for these very quick tests and the response! I could have tested it myself, but i will leave that to the professionals. Keep up the good work! ^-^

@Heit0fff
Copy link
Copy Markdown
Contributor

Heit0fff commented Jan 9, 2026

Fixes both Rayman 2 and Jackie Chan Adventures

@lightningterror lightningterror added this to the Release 2.8 milestone Jan 9, 2026
@GitHub-Khi
Copy link
Copy Markdown

Here are 5 more Multi Frame GS-Dumps for you and for another 7 days. Have fun testing them. :D

@refractionpcsx2
Copy link
Copy Markdown
Member Author

I'm going to introduce you to xz compression, I swear :D I'll be back in a year with the results lol

@refractionpcsx2
Copy link
Copy Markdown
Member Author

@GitHub-Khi same deal as before. Knight Rider seems to be fighty in HW and SW so is likely just like that on real HW too, so I didn't record that one.

RuleOfRose.mp4
Tek4.mp4
PowerPuff.mp4
Wipeout.mp4

@GitHub-Khi
Copy link
Copy Markdown

GitHub-Khi commented Jan 9, 2026

Do not worry, i will not be reviewing any more games, as i do not want to go through every single one. I think that hundreds of games that no one tests or overlooks will be automatically fixed. I hope that all further reports will be accompanied by a self-test + results. Why did you create such fantastic PR that affects so many games? Now here you are with all this stress. Congratulations! xD

And thanks again for the quick tests! :)

@refractionpcsx2
Copy link
Copy Markdown
Member Author

It was really an accident, I only wanted to make MotoGP3 menu not suck. lol

@DonelBueno
Copy link
Copy Markdown

Fixes Burnout 2:

Hardware Master:
1- Hardware Master

Hardware PR:
2- Hardware PR

Software
3- Software

@5d-0
Copy link
Copy Markdown

5d-0 commented Jan 10, 2026

Partially fixes Z-fighting in GTA III and Manhunt (there is still a little flicker just like in SW)

Master:
master
PR:
pr

Master:
master
PR:
pr

@refractionpcsx2
Copy link
Copy Markdown
Member Author

Partially fixes Z-fighting in GTA III and Manhunt (there is still a little flicker just like in SW)

if it matches software, it's hardware accurate, and that's all I wanted :) So yes some games will still have z fighting, but what was expected to be there.

@refractionpcsx2 refractionpcsx2 changed the title GS/HW: Floor depth writes to improve Z testing (TEST ONLY for now) GS/HW: Floor depth writes to improve Z testing Jan 10, 2026
@refractionpcsx2 refractionpcsx2 marked this pull request as ready for review January 10, 2026 13:27
@refractionpcsx2
Copy link
Copy Markdown
Member Author

I've taken it of draft/test only, it's gone extremely better than expected :)

@AmandaRoseChaqueta
Copy link
Copy Markdown

I've taken it of draft/test only, it's gone extremely better than expected :)

PCSX2 2.8 is gonna be insane. Users are gonna lose their marbles when they see how much is about to come lmao

@kamfretoz
Copy link
Copy Markdown
Contributor

PCSX2 2.8 is gonna be insane. Users are gonna lose their marbles when they see how much is about to come lmao

PCSX2 2.8 is shaping up into a great release 😄

@5d-0
Copy link
Copy Markdown

5d-0 commented Jan 10, 2026

Partially fixes Z-fighting in GTA III and Manhunt (there is still a little flicker just like in SW)

if it matches software, it's hardware accurate, and that's all I wanted :) So yes some games will still have z fighting, but what was expected to be there.

This is a huge milestone nonetheless, I always thought fixing Z-fighting for HW is nearly impossible and yet here we are.
unknown

@James-F2
Copy link
Copy Markdown

James-F2 commented Jan 10, 2026

Fixed Tony Hawk's Pro Skater 3, now matching SW.
What kind of sorcery is this?

Vulkan vs SW before this PR:

THPS3.Jumpy.Textures.mp4

@refractionpcsx2
Copy link
Copy Markdown
Member Author

That's probably from the
Voodoo.enable = true;

:D

@matitone71
Copy link
Copy Markdown

Fixes Z-Fighting in Pro Evolution Soccer/Winning Eleven games

Master:
Pro Evolution Soccer 5_SLES-53545_20260110224130

PR:
Pro Evolution Soccer 5_SLES-53545_20260110224248

@lightningterror lightningterror merged commit 06307ab into master Jan 11, 2026
23 checks passed
@lightningterror lightningterror deleted the gs_depthfloor branch January 11, 2026 01:37
@AmandaRoseChaqueta
Copy link
Copy Markdown

PR so good that it went from draft to merged in two days. Amazing work :D

Hancock33 added a commit to Hancock33/batocera.piboy that referenced this pull request Jan 11, 2026
------------------------------------------------------------------------------------------
rocknix-abl.mk 64fb3fca6af9bc097f024464747dd51aaca201b5 # Version: Commits on Jan 11, 2026
------------------------------------------------------------------------------------------
Update ABL, fix system stats calculations,

-------------------------------------------------------------------------------------
azahar.mk 7d2735b118470a9e6e381a363d7cd009a34cadac # Version: Commits on Jan 10, 2026
-------------------------------------------------------------------------------------
Updated translations via Transifex,

-----------------------------------------------------------------------------------
eden.mk 1cb8bcf531f6ad1b0afcc3b2179a136535760984 # Version: Commits on Jan 11, 2026
-----------------------------------------------------------------------------------
[dynarmic] disable extra verbose debugging on release builds (#3293)

-------------------------------------------------------------------------------------
hatari.mk 8484905c9f29bf0f21e9d69533576ff46e9a7c09 # Version: Commits on Jan 11, 2026
-------------------------------------------------------------------------------------
Move the swapping of the frame buffer pointers from screen.c to conv_st.c

This code should belong to the conv code, not to the SDL-related screen

code.,

---------------------------------------------------
pcsx2.mk v2.7.19 # Version: Commits on Jan 11, 2026
---------------------------------------------------
- [GS/HW: Floor depth writes to improve Z testing](PCSX2/pcsx2#13795)

,

------------------------------------------------------------------------------------
rpcs3.mk cd6dfc82a27844860d3596f5e031214ef354d849 # Version: Commits on Jan 10, 2026
------------------------------------------------------------------------------------
cellVdec: also use ctx->framerate to calculate the timestamps

ffmpeg 7 doesn't seem to guess the time_base parameter anymore,

-------------------------------------------------------------------------------------
snes9x.mk 4b51d103b909e0c1ac566b6865b9f6229a7b59e4 # Version: Commits on Jan 10, 2026
-------------------------------------------------------------------------------------
GTK: configuration option for on-screen messages (#1009)

* GTK: config file option for on-screen messages

For the GTK port, a configuration file entry to set the timeout length for the on-screen messages (such as when a state file is loaded) has been added.,

-------------------------------------------------------------------------------------
vita3k.mk 74276ce7ae21838deba378fd9d424b8d526aa6fe # Version: Commits on Jan 11, 2026
-------------------------------------------------------------------------------------
ci: Add macOS ARM64 build

- Optimize Linux build & update.

- Rename artifacts for store repo.,

-------------------------------------------------------------------------------------------
xenia-canary.mk 81656a97299c6fd01ea44e45e11af309c9f99b95 # Version: Commits on Jan 08, 2026
-------------------------------------------------------------------------------------------
[XAM] Fixed issue with error code being returned for local session,

-------------------------------------------------------------------------------------------
xenia-native.mk 81656a97299c6fd01ea44e45e11af309c9f99b95 # Version: Commits on Jan 08, 2026
-------------------------------------------------------------------------------------------
[XAM] Fixed issue with error code being returned for local session,

-----------------------------------------------------------------------------------
ymir.mk 12ca5ef56d731f67bd5bdacd9f3e63ad14e76d27 # Version: Commits on Jan 10, 2026
-----------------------------------------------------------------------------------
build: Try vcpkg tag 2025.10.17 to fix windows-a64 CI build,

-------------------------------------------------------------------------------------
ikemen.mk 92fa10f449d1105cc06fd1fecb60a90e31445662 # Version: Commits on Jan 10, 2026
-------------------------------------------------------------------------------------
style: fix code style issues with gofmt,

-------------------------------------------------------------------------------------------
moonlight-qt.mk 2549efc8b3623f1e2c6b43abad301a1adf4df898 # Version: Commits on Jan 11, 2026
-------------------------------------------------------------------------------------------
Fix pthread_attr leak,

---------------------------------------------------------------
ruffle.mk nightly-2026-01-11 # Version: Commits on Jan 11, 2026
---------------------------------------------------------------
## What's Changed

* tests: Add test for breaking words by @kjarosh in ruffle-rs/ruffle#22701

* desktop: Add GUI for opening a directory by @kjarosh in ruffle-rs/ruffle#22621

* chore: Update translations from Crowdin by @kjarosh in ruffle-rs/ruffle#22733

**Full Changelog**: ruffle-rs/ruffle@nightly-2026-01-09...nightly-2026-01-11,

--------------------------------------------------------------------------------------
scummvm.mk 29574ed22fc181d60ceff1de3d9f37213986f6e5 # Version: Commits on Jan 10, 2026
--------------------------------------------------------------------------------------
M4: RIDDLE: Fix Ripley giving marks to wolf forever the second time he pays for an information,

---------------------------------------------------------------------------------------
thextech.mk 078a20f5f4dc7e11b4d6504145a9fb673a3d62f8 # Version: Commits on Jan 10, 2026
---------------------------------------------------------------------------------------
Wii: dereference profile on deletion (#1082),

------------------------------------------------------------------------------------
box64.mk 3717266c3a26e97b96febfb7043c84a6271fb87f # Version: Commits on Jan 10, 2026
------------------------------------------------------------------------------------
[LA64_DYNAREC] Removed LASX from hard dependencies (#3350),

-----------------------------------------------------------------------------------------
catacombgl.mk c21a1c6ae7973eae24266c8414857bef0ec872e4 # Version: Commits on Jan 11, 2026
-----------------------------------------------------------------------------------------
Introduce Uint16Utility and Uint32Utility,

------------------------------------------------------------------------------------
cdogs.mk cb176456c33a1387b04140309cd4ec9ad57c36ae # Version: Commits on Jan 11, 2026
------------------------------------------------------------------------------------
basic kanga run #712,

----------------------------------------------------------------------------------------
supertux2.mk fdf00aa91f3ddcc7fa840158a8fc85b5b1aa831c # Version: Commits on Jan 06, 2026
----------------------------------------------------------------------------------------
Fix crash when activating 'Show collision rects' in debug menu

When activating 'Show collision rects' from the debug menu while Editor

is not active, the game crashed with a nullptr access. This is fixed by

separating the check for Editor active and the show collision rects flag

from the debug menu.,

----------------------------------------------------------------------------------------------------
sdl2-gamecontrollerdb.mk c42c9093fb9976b6acade29e396de33e757ac39b # Version: Commits on Jan 10, 2026
----------------------------------------------------------------------------------------------------
Add ShanWan Q36

thanks @LastLifeLeft,

----------------------------------------------------------------------------------------
retroarch.mk 63931092dd306b9b4e8c66fa55464bb287456cbb # Version: Commits on Jan 10, 2026
----------------------------------------------------------------------------------------
apple: small cleanups to the metal video driver. don't use it.

fixes #8655 #8983 #15747 #17860 #18442 #18408,

----------------------------------------------------------------------------------------
doomretro.mk c2edac1cfd0a1c6c9810589bfbe080a82ac4d5c8 # Version: Commits on Jan 11, 2026
----------------------------------------------------------------------------------------
More minor tweaks,

--------------------------------------------------------------------------------------
vkquake.mk bd15df1ecd4e6442702ef1097f4dbb70a5e83cf3 # Version: Commits on Jan 10, 2026
--------------------------------------------------------------------------------------
Removed con_warnings of not-loop LIST WAV chunks,

-----------------------------------------------------------------------------------------
sonic3-air.mk e072af26128cbcecc1ca1733ddc4de271e79f248 # Version: Commits on Jan 11, 2026
-----------------------------------------------------------------------------------------
Fix web build,

----------------------------------------------------------------------------------
trx.mk e85cdfe58a710b59ad53af8b7aaad05bbf0fbc4f # Version: Commits on Jan 10, 2026
----------------------------------------------------------------------------------
camera/los_camera: combine Lara state checks

This combines the state checks for Lara for both look and regular

movement.,

----------------------------------------------------------------------------------------------
libretro-fake08.mk a9bb61f483ac8aac921a97b96254144abc995774 # Version: Commits on Jan 10, 2026
----------------------------------------------------------------------------------------------
Update z8lua with support for ~ as bxor operator,

--------------------------------------------------------------------------------------------------------------
libretro-genesisplusgx-expanded.mk 83c2daff0f26620fec51a29820b85f8409bd5840 # Version: Commits on Jan 11, 2026
--------------------------------------------------------------------------------------------------------------
Additional System that adds 2.5GB SWAP,

------------------------------------------------------------------------------------------------
libretro-nestopia.mk 473d3072be67fa2542ca833c274ef6682cf0f0bc # Version: Commits on Jan 10, 2026
------------------------------------------------------------------------------------------------
libretro: Fix up VS. System palette,

-----------------------------------------------------------------------------------------------
libretro-scummvm.mk 29574ed22fc181d60ceff1de3d9f37213986f6e5 # Version: Commits on Jan 10, 2026
-----------------------------------------------------------------------------------------------
M4: RIDDLE: Fix Ripley giving marks to wolf forever the second time he pays for an information,

---------------------------------------------------------------------------------------------
libretro-vba-m.mk 4ca32c23fff58ddaa33b7b81f31eb811f217d6ca # Version: Commits on Jan 10, 2026
---------------------------------------------------------------------------------------------
translations: transifex pull

Signed-off-by: Rafael Kitover <rkitover@gmail.com>,
@socialenigma-og
Copy link
Copy Markdown

Unfortunately, it did not fix Ape Escape/Saru! Get You!: Million Monkeys, although I'm not sure if this PR would even tackle the more agressive vertex explosions going on with that game...

@refractionpcsx2
Copy link
Copy Markdown
Member Author

refractionpcsx2 commented Jan 14, 2026

is there a point you can find in footage of a real PS2 you can compare to PCSX2 that still looks wrong? There's a very non-zero chance that the z fighting is there on the console also, and the goal was towards console accuracy, not improving upon (probably impossible with hardware lol)

@mrrguest mrrguest mentioned this pull request Jan 14, 2026
32 tasks
@Darkcranio95
Copy link
Copy Markdown

BT2 and BT3 isn't fully solved but the most apparent Z fighting is gone. I'll test it later on real PS2.

@refractionpcsx2
Copy link
Copy Markdown
Member Author

BT2 and BT3 isn't fully solved but the most apparent Z fighting is gone. I'll test it later on real PS2.

Thanks, I would love to see pictures, because I suspect it will still be there :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Small graphical glitch in Haunting Ground [BUG]: Texture flickering in background in Rayman 3 Hoodlum Havoc