hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.03k stars 2.15k forks source link

(OpenGL) Certain Games Crashes With ADRENO GPU 3xx and 5xx series #16015

Open ghost opened 2 years ago

ghost commented 2 years ago

Game or games this happens in

Naruto Shippuden Ultimate Ninja Impact Kingdom Hearts Birth By Sleep Monster Hunter 3rd HD Portable Persona 3 Portable

What area of the game / PPSSPP

The following games crashes using opengl backend on adreno 3xx/5xx series.

Naruto Shippuden Ultimate Ninja Impact #12847

Kingdom Hearts Birth By Sleep #11029

Monster Hunter 3rd HD Portable #11410

Persona 3 Portable #11355

Workaround is by adding those games id to pixeldepthrounding could also fix graphics glitches for both opengl and vulkan 👇 https://github.com/hrydgard/ppsspp/issues/11583

What should happen

Not crashing and no graphic glitches

Logs

None

Platform

Android

Mobile phone model or graphics card

OPPO s3s Snapdragon 450 Adreno 506

PPSSPP version affected

All

Last working version

None

Graphics backend (3D API)

OpenGL / GLES

Checklist

IrfanH495 commented 2 years ago

@Gamemulatorer try this game too Ikki Tousen: Xross Impact & Corpse Party

ghost commented 2 years ago

@Gamemulatorer try this game too Ikki Tousen: Xross Impact & Corpse Party

Why?

unknownbrackets commented 2 years ago

I wonder if we simply need to activate the NO_DEPTH_CANNOT_DISCARD_STENCIL workaround, but in GL. It sounds similar based on another issue, especially if pixel depth rounding fixes it.

-[Unknown]

unknownbrackets commented 2 years ago

If anyone can compile and test, you can basically try adding:

if (caps_.vendor == GPUVendor::VENDOR_QUALCOMM) {
    bugs_.Infest(Bugs::NO_DEPTH_CANNOT_DISCARD_STENCIL);
}

Around here: https://github.com/hrydgard/ppsspp/blob/f3c097680edf9322461f342983226e18a549dd3e/Common/GPU/OpenGL/thin3d_gl.cpp#L635

If that prevents the crash, it might need some small tweaks and could use conservative depth potentially (?) but it would only take this slow path in potentially necessary cases, unlike forcing pixel depth rounding always.

-[Unknown]

ghost commented 2 years ago

Sorry to say I don't know how to compile apk :(

IrfanH495 commented 2 years ago

@Gamemulatorer try this game too Ikki Tousen: Xross Impact & Corpse Party

Why?

looks like the game also has a driver bug issue for adreno

ghost commented 2 years ago

@Gamemulatorer try this game too Ikki Tousen: Xross Impact & Corpse Party

Why?

looks like the game also has a driver bug issue for adreno

Can you define what is the issue of those games on adreno gpu 3xx/5xx series? Screenshots?

IrfanH495 commented 2 years ago

@Gamemulatorer try this game too Ikki Tousen: Xross Impact & Corpse Party

Why?

looks like the game also has a driver bug issue for adreno

Can you define what is the issue of those games on adreno gpu 3xx/5xx series? Screenshots?

bolt fc

ghost commented 2 years ago

bolt fc

If you add those games id to PixelDepthRounding what happen? Still force close?

IrfanH495 commented 2 years ago

bolt fc

If you add those games id to PixelDepthRounding what happen? Still force close?

not fc Screenshot_20220913-195817_QuickEdit+

Saramagrean commented 2 years ago

Sorry to say I don't know how to compile apk :(

Try. :) https://drive.google.com/file/d/10kAUg8051i7YJJNlAo0nVYXDKvkONrM5/view?usp=drivesdk

ghost commented 2 years ago

Still crashing :( ULUS10582.ppdmp.zip

BTW thanks Saramagrean for the apk.

unknownbrackets commented 1 year ago

Since only certain games crash in this case, there should be some detectable case, even if it's different than the Vulkan issue. I just checked Persona 3, though, and it never seem to hit this condition: stest_on.flag && ztest_on.flag && !zwrite_off.flag. In fact, it doesn't even hit stest_on.flag.

It also does draws before the crash with zwrite_off && ztest_on, as well as !ztest_on. It never enables ctest_on either. I thought maybe atest, but it hits atest_on.flag && ztest_on.flag && zwrite_off.flag even before the crash, and ztest/ztest are used together and not used together before that.

-[Unknown]

ghost commented 1 year ago

GE dump before it crash. ULUS10582.ppdmp.zip

ghost commented 1 year ago

Another list of games that crashes using opengl backend.

Hack/Link Midnight Club L.A Remix ModNation Racers

ghost commented 1 year ago

I can also reproduce this on my vivo y11 snapdragon 439 adreno 505 android 11.

IrfanH495 commented 1 year ago

sorry I use the latest build but almost all the games I have after loading the game, always fc Samsung M20 exynos Vulkan

IrfanH495 commented 1 year ago

sorry I use the latest build but almost all the games I have after loading the game, always fc Samsung M20 exynos Vulkan

[v1.13.2-1726-gba32ef5ea] [v1.13.2-1723-g1d97e7d03] above version that I tried. but it's the same both fc for vulkan. is this a driver bug?

ghost commented 1 year ago

sorry I use the latest build but almost all the games I have after loading the game, always fc Samsung M20 exynos Vulkan

[v1.13.2-1726-gba32ef5ea] [v1.13.2-1723-g1d97e7d03] above version that I tried. but it's the same both fc for vulkan. is this a driver bug?

Maybe 🤔? Vulkan work normal on my phone.

IrfanH495 commented 1 year ago

sorry @Gamemulatorer can you try it on mediatek.

ghost commented 1 year ago

sorry @Gamemulatorer can you try it on mediatek.

Sadly I don't have any mediatek phone with vulkan supported.

IrfanH495 commented 1 year ago

Samsung M20 Exynos 7904 Mali-G71 Android 10 all game fc all use the default settings. this is the screen recording. https://youtu.be/0Nilq1a2tCo is this also an issue?

ghost commented 1 year ago

Samsung M20 Exynos 7904 Mali-G71 Android 10 all game fc all use the default settings. this is the screen recording. https://youtu.be/0Nilq1a2tCo is this also an issue?

This is an adreno 3xx/5xx series gpu issue using opengl :)

IrfanH495 commented 1 year ago

Samsung M20 Exynos 7904 Mali-G71 Android 10 all game fc all use the default settings. this is the screen recording. https://youtu.be/0Nilq1a2tCo is this also an issue?

This is an adreno 3xx/5xx series gpu issue using opengl :) Yes, I know. I'm just confused whether to make a new issue or not.

unknownbrackets commented 1 year ago

If all games are force closing with non-Adreno, it's probably best to create a new issue. It'd really help to know if it's new and if so, since which commit.

-[Unknown]

unknownbrackets commented 1 year ago

Calling glFlush(); after every draw, or before every glBindTexture() makes Persona 3 run just fine. Calling it only at the end of PerformRenderPass() or trying after init does not help and it still locks up. glUseProgram() is also not often enough.

I tried counting commands and flushing after a chunk of them, which didn't help.

Here's a branch that runs Persona 3 past the crash on a Pixel: https://github.com/hrydgard/ppsspp/compare/master...unknownbrackets:ppsspp:adreno-deadlock

It's probably not a good change as I suspect it may have pretty terrible performance impacts on 3D games with large scenes. I didn't find anything obvious interacting with depth here...

-[Unknown]

ghost commented 1 year ago

https://github.com/hrydgard/ppsspp/commit/a8537576e57713720b60baa50e0c90dfc7ca216c still crashing.

hrydgard commented 1 year ago

For the release, I think I'm just gonna make a special compat flag that enables pixeldepthrounding for these four games on Adreno. Not sure what else I can do :/

unknownbrackets commented 1 year ago

Just to note: this crash is not at all new, at least Persona 3 has been crashing for quite a while on affected devices. The crashes only seem to affect specific scenes, and in Persona 3 for example, you can work around it simply by having a save file afaik.

Might be good to make sure the vendor bug checks setting applies in case someone who could play before (with workarounds like not starting a new game on an affected device) can no longer get playable performance with early z checks forced off.

-[Unknown]

hrydgard commented 1 year ago

I added a "vendor bug checks" check, added the missing games and merged. Please test to see that the workaround has been applied correctly.

ghost commented 1 year ago

Yes the workaround is applied correctly but the performance decrease by 5-10fps. Screenshot_20221124_203347_2f85358b2198d26f8aca533d68bee793 Screenshot_20221124_203336_2f85358b2198d26f8aca533d68bee793

hrydgard commented 1 year ago

That's better than crashing, at least. Don't know what else we can do here for now, moving further work to later versions.

ghost commented 1 year ago

Adreno 306 still suffer freezing on certain games :(

hrydgard commented 1 year ago

These games, or other games?

ghost commented 1 year ago

These games, or other games?

Naruto Shippuden Ultimate Ninja Impact and Phantasy Star Portable 2.

ghost commented 1 year ago

Naruto Shippuden Ultimate Ninja Impact.

If OldAdrenoPixelDepthRoundingGL is ON the game is freeze.

https://user-images.githubusercontent.com/37603562/204127021-3d5ec61c-55f4-462f-a3d1-6690d3fc40d5.mp4

If OFF the game works normally 🤔

hrydgard commented 1 year ago

uh what, I thought we added it because it fixed freezes in the game? :)

So we should just remove it again from the compat.ini?

ghost commented 1 year ago

uh what, I thought we added it because it fixed freezes in the game? :)

So we should just remove it again from the compat.ini?

I don't know why this is only happen in my vivo y51a adreno 306, but not in my vivo y11 adreno 505 works correctly with OldAdrenoPixelDepthRoundingGL enable.

ghost commented 1 year ago

Might be good if you guys increase the android version to android 8.0+ adreno 3xx/5xx series? as mention here https://github.com/hrydgard/ppsspp/issues/11355#issuecomment-419609455 driver bug start in that android version 🤔

My vivo y51a is android 5.1 only.

hrydgard commented 1 year ago

Hm, ok, yeah, I'll give that a try.

XD89k commented 3 weeks ago

Hello, the option to change drivers does not appear in Adreno 308 Version 1.17.1

hrydgard commented 3 weeks ago

The option to change drivers is only applicable to Vulkan, with newer Adreno GPU editions, unfortunately.

XD89k commented 3 weeks ago

Thank you, and the option is not available in Adreno 508 either?

hrydgard commented 3 weeks ago

The criteria are:

If your device doesn't pass this it's not possible to load drivers at runtime, sorry