flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.41k stars 170 forks source link

Phantasy Star Online Ver. 2 graphic issue #1684

Open mfigueirido opened 1 week ago

mfigueirido commented 1 week ago

Platform / OS / Hardware: Windows 11 x64

Flycast version: v2.3.2-221-g4d73cc8e1

Hardware: AMD Ryzen 2600, Radeon RX 570, 16GB RAM

Description of the Issue

Part of the ground shows visual corruption when looked at certain angles.

I'm not expecting this to be fixed as it looks like an edge case related to Z-fighting, specific to my drivers or hardware, but thought it would be good to have it documented.

Save state: Phantasy Star Online Ver. 2 (USA) (En,Ja,Fr,De,Es).state.zip

Debugging Steps Tested

Screenshots

Phantasy Star Online Ver  2 (USA) (En,Ja,Fr,De,Es)-241010-225203

flyinghead commented 1 week ago

It is indeed z-fighting and I can reproduce similar issues in this scene with a Nvidia GTX 1080. Unfortunately there's no easy fix. Related to #1141.

mfigueirido commented 1 week ago

I see. Thanks for checking it out!

Wunkolo commented 1 week ago

Just curious: Does this happen with OpenGL at all too?

flyinghead commented 1 week ago

Yes, same glitch with OpenGL and Vulkan for me.

mfigueirido commented 1 week ago

Yes, this is OpenGL: imaxe

Wunkolo commented 1 week ago

Some more Vulkan data-points

Result on my Intel UHD Graphics 750: image

Result on my RTX 3090: image

All the GPUs mentioned in this thread support D32_SFLOAT_S8_UINT for DEPTH_STENCIL_ATTACHMENT just fine too.

Might have to do with the driver compiling shaders with varying levels of precision for different shaders similar to these issues: https://github.com/grimdoomer/NvidiaPrecisionLossPoc https://icode4.coffee/?p=566

mfigueirido commented 1 week ago

Interesting read... so maybe there's a chance for a fix?

From the second link: "If I could force the optimizer to choose one of the two paths consistently then that should mitigate the issue. Now the solution became clear, instead of calculating the dot product the long way I would use the dp3 intrinsic and a single add. This should optimize the dph function to the point where the shader optimizer wouldn’t be able to perform any further optimizations on it."

flyinghead commented 1 week ago

Not the exact same glitch but I do have intermittent z-fighting on this tex. image

mfigueirido commented 1 week ago

Same behaviour: imaxe