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

[Vulkan] Weird shader bug (Z-fighting?) #11583

Closed
Leopard20 opened this issue Nov 24, 2018 · 50 comments · Fixed by #11620
Closed

[Vulkan] Weird shader bug (Z-fighting?) #11583

Leopard20 opened this issue Nov 24, 2018 · 50 comments · Fixed by #11620

Comments

@Leopard20
Copy link
Contributor

Leopard20 commented Nov 24, 2018

In certain games, you can see a bunch of weird lines on some surfaces (particularly those that have some sort of "reflection" or "shining" effect)
Here are some examples:
Ace Combat Joint Assault -> Aircraft and missiles
screenshot_2018-11-24-21-52-23-157_org ppsspp ppsspp
screenshot_2018-11-24-21-53-13-392_org ppsspp ppsspp

NFS Underground -> Windows
screenshot_2018-11-24-21-53-33-723_org ppsspp ppsspp
screenshot_2018-11-24-21-53-45-144_org ppsspp ppsspp

Silent Hill Shattered Memories -> Walls
screenshot_2018-11-24-21-55-17-176_org ppsspp ppsspp

OGL works fine in all above games.

Device: Mi 5s Plus, Snapdragon 821
OS: Android 8.0

@unknownbrackets
Copy link
Collaborator

Can you try creating GE frame dumps for any of these scenes?

I'd guess something with render-to-texture or depal.

-[Unknown]

@Leopard20
Copy link
Contributor Author

Leopard20 commented Nov 24, 2018

For some reason, the debugger keeps saying "waiting for a game to start...", even though, according to the page title, the game is recognized (ULUSxxxx....) . Any idea what's wrong? (Android, firewall disabled, website access on)

@unknownbrackets
Copy link
Collaborator

Hm... if it detects the game id, are you in the pause menu? Try pausing and resuming perhaps?

-[Unknown]

@Leopard20
Copy link
Contributor Author

Doesn't help. Already done that.
I'll dump one on my PC later! 😉😂

@Leopard20
Copy link
Contributor Author

Wait. I got it! The game shouldn't be paused. Derp.

@hrydgard
Copy link
Owner

Looks somewhat like Z fighting.. on the PSP, doing both base texture and environment map requires two passes. If the GPU somehow optimized the two shaders differently this kind of thing could happen... Usually I think drivers take special care to compute accurate vertex coords though. Dunno...

@Leopard20
Copy link
Contributor Author

@hrydgard
Yeah I think it's my driver acting up. I don't recall having these problems before.

@unknownbrackets
Here you go:
Download.zip
This should be more than enough! Although I couldn't get a dump from Silent Hill. The game would just freeze completely.

@unknownbrackets
Copy link
Collaborator

Does using software transform (not software rendering, just unchecked hardware transform) help? Does software skinning affect it?

This seems to use weights + environment mapping + an unusual < ff alpha test, at least in Ace Combat.

-[Unknown]

@Leopard20
Copy link
Contributor Author

No. Neither software transform nor software skinning affect any of those games (in terms of this issue of course)

@Leopard20
Copy link
Contributor Author

@unknownbrackets

This seems to use weights + environment mapping + an unusual < ff alpha test, at least in Ace Combat.

Could it be a driver bug? If so maybe I could test on PC to be sure.

@unknownbrackets
Copy link
Collaborator

It doesn't look funny when I run the dump. If you run that dump on your phone (just open as a game), does it look funny still?

-[Unknown]

@Leopard20
Copy link
Contributor Author

Yes. Does it mean it's a driver bug?

@Leopard20
Copy link
Contributor Author

Leopard20 commented Nov 29, 2018

Funny thing: When I use upscaling, the game looks fine for like a second then gets weird again! LoL
Might be because it's still loading though.

@Leopard20
Copy link
Contributor Author

@unknownbrackets I just updated my Vulkan API to the latest version available for my OS (1.0.66) but the issue still persists.
Can you test it on your phone too please?

@unknownbrackets
Copy link
Collaborator

Yes, seems like a driver bug.

-[Unknown]

@Leopard20
Copy link
Contributor Author

Oh, damn. :(

@Metalwario64
Copy link

Metalwario64 commented Nov 30, 2018

@Leopard20 I don't have the issue with the lines in the therapy session room like you do:
silent hill - shattered memories-181130-135908

But, I do have a similar issue:

In Silent Hill: Shattered Memories there are lines that appear to be cast shadows from the flashlight being rendered incorrectly. Since it scrolls like the shadows, and their shape seems off, I don't think it is z-fighting in that instance at least. I can't speak for the other games.

Here's how it looks on a PSP (from a Youtube video I found, as I have no means of capturing from a PSP directly, so apologies for the quick and dirty picture quality):
sm hw

Here's how it looks in PPSSPP:
sm emu

Since I'm not sure if my issue is the same as the one @Leopard20 is experiencing, should I open a new issue for it? The other issues I've searched for seem to be a bit different as well.

@Leopard20
Copy link
Contributor Author

Leopard20 commented Nov 30, 2018

@Metalwario64 That one looks different. But again this game has always had lots of graphical glitches. Perhaps you should take a look at the old issues, see if there's any similar ones.

@unknownbrackets I bisected the issue. And it's very interesting. Once again it's caused by this: 06340bf
Remember this? #11227

The driver bug causes it to draw incorrectly, which can in some cases draw faster.

Which one looks "correct"? The one with those lines?! Trust me when I tell you there's no discard bug! Perhaps there was a bug on old drivers but not anymore (I'm using the latest driver, at least for my OS)

Can you please revert that commit? Or at least find a better "workaround"?

@hrydgard
Copy link
Owner

hrydgard commented Dec 1, 2018

@Metalwario64 This game is using some extremely advanced tricks to implement real depth shadow mapping on the PSP's hardware, which doesn't really support it. If you take a few GE dumps it will make it more convenient to figure out what's going wrong - can you do that (https://github.com/hrydgard/ppsspp/wiki/How-to-create-a-frame-dump)? I think we had some issue already, but if you don't find a good one please create a new one.

@Leopard20
Copy link
Contributor Author

Leopard20 commented Dec 3, 2018

@unknownbrackets The issue doesn't seem to have been fixed completely. In Ace Combat, everything looks fine in the menu:
screenshot_2018-12-03-15-04-37-720_org ppsspp ppsspp
However, the issue is still present in missions:
screenshot_2018-12-03-15-04-47-320_org ppsspp ppsspp

There are no issues in Silent Hill or NFS though.

@Leopard20
Copy link
Contributor Author

So....what about this one? Don't you guys want to reopen?

@hrydgard hrydgard reopened this Dec 4, 2018
@unknownbrackets
Copy link
Collaborator

Just don't use Vulkan, the driver is broken either way. I'm not going to play a game of "break this game, fix this game" and I'm not going to create an intricate list of thousands of game ids with a "maybe preferrable version of the Adreno driver bugs."

Use GLES for now and wait for Adreno to release a better driver.

-[Unknown]

@Leopard20
Copy link
Contributor Author

@unknownbrackets Jeez. Simmer down dude.

@unknownbrackets
Copy link
Collaborator

It's still a bug, so we should keep it open. But like I said: it's probably only fixable by Adreno.

-[Unknown]

@Leopard20
Copy link
Contributor Author

Leopard20 commented Dec 27, 2018

@unknownbrackets So far the impact seems to be positive! The issue is gone!

I'll check more thoroughly later!

@Leopard20
Copy link
Contributor Author

Leopard20 commented Dec 27, 2018

All games I tested (including Project Diva) work fine.
I'm not sure about the Narutu game though. I don't have it to test.

I think it's safe to say it's fixed completely.

@weihuoya
Copy link
Contributor

weihuoya commented Dec 27, 2018

Naruto still have this issue. adreno 530, vulkan 1.0.61. ppsspp 1.7.5-332.

@weihuoya
Copy link
Contributor

adreno driver really do evil things. naruto work fine on android 7.0. after update to android 8.0, opengl 3.2 v@269, this game get stuck on opengl backend, and get display issue on vulkan backend.

@hrydgard
Copy link
Owner

@weihuoya
Copy link
Contributor

ok, wait a few days, I don't have a pc to dump.

@hrydgard
Copy link
Owner

There is now a way to get frame dumps even on Android, as described in my link. Though maybe tricky to upload the dump to GitHub...

@weihuoya
Copy link
Contributor

awesome job. it works.
recording.zip

@unknownbrackets
Copy link
Collaborator

Can we call this issue fixed now?

-[Unknown]

@Leopard20
Copy link
Contributor Author

@unknownbrackets No. The problem still exists in Naruto:
Screenshot_2019-09-08-13-55-31-980_org ppsspp ppsspp
recording (2).zip

@ghost
Copy link

ghost commented Apr 14, 2022

@unknownbrackets No. The problem still exists in Naruto: Screenshot_2019-09-08-13-55-31-980_org ppsspp ppsspp recording (2).zip

If you add Naruto Shippuden to PixelDepthRounding compat.ini does it help?

@unknownbrackets
Copy link
Collaborator

Just for context on the bug: Naruto is drawing the dirt over the grass using a >= depth test and depth write disable, plus writing stencil (FF on 5551.) There's no actual stencil test, though (it's ALWAYS.), and stencil is only written (REPLACE) on all pass.

So that's the scenario of the driver bug - it might incorrectly write stencil otherwise. A bit unclear if that'd be worse, it seems to stencil out the sky for some reason (everything but the sky has stencil set.) Might just miss some sunflare effects, but might also be used for special attacks.

If this is happening on newer Adreno devices or drivers (i.e. not with this workaround), then I'd guess it could be an issue with exactness, but the gaps seem too wide for that.

-[Unknown]

@ghost
Copy link

ghost commented Sep 9, 2022

@unknownbrackets No. The problem still exists in Naruto: Screenshot_2019-09-08-13-55-31-980_org ppsspp ppsspp recording (2).zip

If you add Naruto Shippuden to PixelDepthRounding compat.ini does it help?

PixelDepthRounding fixes this but the performance penalty is huge.

@hrydgard
Copy link
Owner

hrydgard commented Sep 9, 2022

VertexDepthRounding doesn't do the trick I guess?

@ghost
Copy link

ghost commented Sep 9, 2022

Doesn't help

@ghost
Copy link

ghost commented Sep 9, 2022

Maybe create like AdrenoDepthStencilBugWorkaround just like in Mali GPU?

@hrydgard
Copy link
Owner

hrydgard commented Sep 9, 2022

None of my Mali phones (S8, S20) reproduce this running the .ppdmp, but there's one more thing I want to try before we force PixelDepthRounding - position invariance, see https://www.khronos.org/opengl/wiki/Type_Qualifier_(GLSL)#Invariance_qualifiers . I'll commit a quick attempt soon.

hrydgard added a commit that referenced this issue Sep 9, 2022
The code that computes shader outputs declared as invariant gets certain
optimizations disabled that could change the value - it makes it more
likely that different ways to do the same calculations end up with the same value.

This can help some types of Z fighting problems and similar.

Generally not a big deal for performance, plus, we're rarely vshader-bottlenecked...
@hrydgard
Copy link
Owner

hrydgard commented Sep 9, 2022

Don't really have high hopes that it will help, won't be surprised if we end up enabling pixeldepthrounding. We should indeed probably make a Mali-specific version of that in that case.

@ghost
Copy link

ghost commented Sep 10, 2022

e56e594 doesn't help.

@ghost
Copy link

ghost commented Sep 19, 2022

#16043 doesn't help for vulkan.

@ghost
Copy link

ghost commented Oct 25, 2022

Can no longer reproduce this issue using the recently build.
Screenshot_20221025_203501_2f85358b2198d26f8aca533d68bee793

Vivo Y11 Snapdragon 439

@hrydgard
Copy link
Owner

That's interesting! Wonder what might have fixed it?

@ghost
Copy link

ghost commented Oct 25, 2022

Or maybe because the driver version of vivo y11 snapdragon 439 adreno 505 is better?
Screenshot_20221026_004648_2f85358b2198d26f8aca533d68bee793

@ghost
Copy link

ghost commented Nov 13, 2022

This issue is safe to close now.

@unknownbrackets
Copy link
Collaborator

Maybe also the equal checks using draws instead of clears helped normalize some differences? Or a benefit of using invariant on the position?

I'll close this then as worked around (for drivers we can) and fixed where we can. Good if it's not happening on Adreno 5xx. Definitely possible Adreno fixed it.

-[Unknown]

@unknownbrackets unknownbrackets closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants