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.01k stars 2.15k forks source link

Micro Stuttering/Frame Pacing issue #9736

Open BParks21 opened 7 years ago

BParks21 commented 7 years ago

NOTE: If you are experiencing this issue, it may have multiple causes. See this comment: https://github.com/hrydgard/ppsspp/issues/9736#issuecomment-509018634


Using any API there is in every game a micro stutter or frame pacing issue that occurs randomly. This may be exclusive to windows. I've tested windows 7-10 and many different systems with the same results. It is more prevalent using a monitor at 60hz. The issue is almost gone using a 120hz display. Currently that is the only way to resolve the issue in all my testing. The easiest way to test this is to play a game with complete 360 camera control stand in place and slowly spin the camera around. You will see random stutters or inconsistent frame pacing. This occurs with games running at full speed at all times, vsync on, and frame skipping off. I believe ppsspp is suffering from the same issue the PCSX2 team is trying to resolve here. https://github.com/PCSX2/pcsx2/issues/1437

It would be worth looking into. This is my biggest issue with ppsspp and is very noticeable and unpleasant imo. I've been trying to find a solution to this for years and it is driving me mad. I think the pcsx2 team has pinned it down though. Thanks for your time i really hope you guys look into this and hope it is resolved. I love ppsspp except for this :)

System Specs: Operating System: Windows 10 Pro 64-bit MOBO: Asus Maximus IX Code Processor/CPU: Intel(R) Core(TM) i7-7700k @5Ghz Video Card/GPU: MSI GTX 980 Memory/RAM: 32GB DDR4 @3000Mhz

JetSetter1984 commented 4 years ago

I took the shot around 2 seconds after the stuttering finished, not sure how to interpret that on the graph.

JetSetter1984 commented 4 years ago

OK so I found that the graph is not correlated with the stutter. This is so strange as DX9 doesn't stutter at all, Open GL does in windowed mode, and DX11 and Vulkan do stutter in both windowed and full screen. Why does the retroarch core not experience this in DX11? I have a feeling it is to do with PPSSPP's vsync implementation as retroarch has its own vsync, which is probably why it never stutters.

BParks21 commented 4 years ago

Idk i just tested the latest ppsspp core in RA and i definitely see stutter in both opengl and DX11. Only the Dolphin core and ppsspp stutter out of all my cores. The Dolphin team literally just implemented the duplicate frames feature in the latest dev builds. It fixed all the the stutter in 30 fps games. They even wrote a big section about it in their most recent progress report article for December and January. I'm confident if the feature was carried over to the libretro port it would solve this stutter too. So even if you're not seeing stutter and such a feature gets implemented for ppsspp i would still hope it gets carried over to the libretro port. I know the mupen64 plus next core that libretro has been working hard on has a duplicate frames feature as well as the beetle psx core. Although for beetle psx it's enabled by default and cannot be easily disabled.

JetSetter1984 commented 4 years ago

Are you using vsync with a 60hz monitor?

BParks21 commented 4 years ago

Yes

JetSetter1984 commented 4 years ago

Ok that is wierd, because the retroarch core is perfect for me. I haven't updated it in about a week, have you? Maybe the newest one is broken too.

BParks21 commented 4 years ago

Yes just updated today but I've been plagued by the stutter with the libretro core for over a year now, probably 2. It's never been smooth with 30fps games for me. 60 fps run smoothly.

JetSetter1984 commented 4 years ago

Ahh ok, I was talking about 60fps sorry. Can you confirm that 60fps games are stuttering on the standalone build but smooth in retroarch? As far as 30fps goes, I think duplicate frames needs to be implemented, but in the meantime I suppose messing around with the sync settings in retroarch or nvidia control panel is your best bet. Either way it will be choppy, 30 fps just is. Duplicate frames seems buggy in Dolphin but works great in the beetle psx core. Hopefully the implementation is on a par with beetle psx when it does arrive.

BParks21 commented 4 years ago

60fps is smooth in standalone build and libretro. 30fps stutters in both. Also Dolphins duplicate frames mode shouldn't be buggy as long as dual core mode is disabled.

JetSetter1984 commented 4 years ago

Ok I'll have to try disabling that dual core, thanks. I don't understand how my standalone build is stuttering in D3D 11 and vulkan, windowed or fullscreen and in opengl windowed. Opengl fullscreen is fine as is D3D9 windowed or fullscreen. Retroarch is fine in anything except vulkan will not load. The only thing I can think of is that Retroarch has it's own vsync implementation in the video setting section.

ghost commented 4 years ago

picture of me playing Shin Budokai 2 on the DX11 renderer and force clock sync enabled and vsync enabled: image Without force clock sync : image Oמ DX9 renderer with force real clock sync on: image On OpenGL renderer with force real clock sync on: image All tests were done with vsync on. Something I noticed is that this mostly affects laptops on Windows seeing as they handle hybrid graphics a little bit different than normal PCs and that affects other stuff as well.

unknownbrackets commented 4 years ago

Any green lines spiking above the average (3 of your screenshots have this) indicate emulation can't keep up. These directly indicate dropped frames, even if the average FPS still looks okay (i.e. even if it's 59.99 or 60.00.)

Your first screenshot seems to have a large spike. This may be caused by texture scaling, rewind, or other settings (see https://github.com/hrydgard/ppsspp/issues/9736#issuecomment-509018634.) It can also be caused by other apps running on your PC taking up resources (such as an autoupdater, backup program, desktop background image rotation, etc.)

The Direct3D 9 screenshot seems to be shortly after something was loading, as the game looks to have internally dropped a frame or two. If that's happening outside loading scenes, and you're not seeing stutter/dropped frames, I'm not sure how or what to tell you.

It's obvious from these screenshots that Direct3D 9 performs the worst (by far) on your system. We can see Direct3D 11 spends ~20% of its time doing work, and OpenGL spends closer to 15%. But Direct3D 9 is spending more than 50% of the time working hard (the darker green part is working time.)

If Direct3D 9 is more stable, it could be a factor of the system clocking up (because usage is so high) or thermal throttling making things more consistent on your laptop. On Android, I've joked that adding a bitcoin miner to PPSSPP would improve performance (it's probably true, though.) If you're getting more stable performance in Direct3D 9, this may be true on your laptop as well.

Your final screenshot has some spikes as well - again, check settings and make sure this wasn't during loading scenes (in case the game is dropping frames itself.) That said, outside the spikes, I personally find your frame times with OpenGL most consistent. Does it seem to have the same degree of stutter?

-[Unknown]

ghost commented 4 years ago

Any green lines spiking above the average (3 of your screenshots have this) indicate emulation can't keep up. These directly indicate dropped frames, even if the average FPS still looks okay (i.e. even if it's 59.99 or 60.00.)

Your first screenshot seems to have a large spike. This may be caused by texture scaling, rewind, or other settings (see #9736 (comment).) It can also be caused by other apps running on your PC taking up resources (such as an autoupdater, backup program, desktop background image rotation, etc.)

The Direct3D 9 screenshot seems to be shortly after something was loading, as the game looks to have internally dropped a frame or two. If that's happening outside loading scenes, and you're not seeing stutter/dropped frames, I'm not sure how or what to tell you.

It's obvious from these screenshots that Direct3D 9 performs the worst (by far) on your system. We can see Direct3D 11 spends ~20% of its time doing work, and OpenGL spends closer to 15%. But Direct3D 9 is spending more than 50% of the time working hard (the darker green part is working time.)

If Direct3D 9 is more stable, it could be a factor of the system clocking up (because usage is so high) or thermal throttling making things more consistent on your laptop. On Android, I've joked that adding a bitcoin miner to PPSSPP would improve performance (it's probably true, though.) If you're getting more stable performance in Direct3D 9, this may be true on your laptop as well.

Your final screenshot has some spikes as well - again, check settings and make sure this wasn't during loading scenes (in case the game is dropping frames itself.) That said, outside the spikes, I personally find your frame times with OpenGL most consistent. Does it seem to have the same degree of stutter?

-[Unknown]

You know its funny the OpenGL one does works the best despite me using an AMD GPU... But for other games the OpenGL renderer will work worse and give me FPS issues so I dont wanna use it primarly. The other renderers give me microstutters/stutters no matter what setting I use and it simply hurts. I think i took a bad image of the DX11 renderer tho. My laptop is rather a strong one it got a dedicated GPU and an Intel i7 CPU...

ghost commented 4 years ago

BTW I was not on any loading screen when I took the screenshots.

JetSetter1984 commented 4 years ago

Thought I'd just chip in and say that I have no idea why this is happening, especially using a 1080Ti and a 3600X. On any backend even at 10x resolution I'm at most using around 10% GPU. I have some free time most days so is there anything I could do on my part to pinpoint where the problem is. I have no such issues with any PC games I play and outside of games which just do not run well, no other emulator gives me this problem either.

ghost commented 4 years ago

You know what while I am it i will compare the CPU/GPU usage on different renderers. On OpenGL renderer (the best one - no stutters ) : image image On DX9: image image On DX11: image image On Vulkan: image image Remainder that Vulkan on Linux works without stutters while on Windows there are.

ghost commented 4 years ago

Another video that shows frame pacing issues in the game (notice he gets 60/61 FPS all the way): https://www.youtube.com/watch?v=X7EYFpmGsKU&feature=youtu.be&t=158s The guy uses a vega gpu and he recorded the video with relive. It could be the recording software but i cant be sure.

LunaMoo commented 4 years ago

Might be a shader compilation this can vary a lot between drivers/api's which could at least explain your situation @MojoJojoDojo ~ PPSSPP does not have ubershaders like dolphin as of now.

~ related issue: #10106

ghost commented 4 years ago

Maybe it is A shader compilation I actually had a feeling it might be that but I was not sure. This explains the stutters.

JetSetter1984 commented 4 years ago

If it is shader compilation, doesn't it save the shaders? I can go through the same parts of a game several times and experience stutter each time. Shouldn't having the shaders compiled cure this? Also why does my retroarch core not stutter?

unknownbrackets commented 4 years ago

Correct, shader compilation stutter should only occur when new graphics are shown that have not been shown during the same game session before. If you're getting recurring stutter in the same area, it's probably not shaders.

Also, which shaders were needed are saved to a file and preloaded at startup, so even if you saw them a previous play session, it still should not cause stutter again and again.

They would show as spikes in that graph as well, if they were happening.

-[Unknown]

JetSetter1984 commented 4 years ago

Thanks for clearing that up pal. Well I'm completely stumped as to why I get the stutters in PPSSPP but retroarch core is smooth as butter.

LunaMoo commented 4 years ago

Weren't shaders only cached for ogl? Or that was long ago:p. The problem with that dbz game seems to not happen specifically in ogl and happens when effects are showing not at some intervals.

unknownbrackets commented 4 years ago

All backends cache shaders during a play session, but only Vulkan and OpenGL preload previously used shaders from other sessions.

-[Unknown]

ghost commented 4 years ago

This is getting confusing :S I hope that the source for the stutters will come clear.

JetSetter1984 commented 4 years ago

Just tried PPSSPP on Android, Huawei Mate 20 Pro. Perfect with no stuttering whatsoever, and vulkan is surprisingly efficient. Much better performance than OpenGL, allowing me to max out everything on the phone and still perfect gameplay. 60hz display on the phone. Yet a 1080Ti on windows and it consistently stutters? And can anybody answer why RA core is perfect for me? Thank you.

ghost commented 4 years ago

The problem with using the OpenGL renderer is that you replace the frame pacing issues with input lag issues instead. There is really no best renderer currently for use (The DX9 renderer comes close tho).

JetSetter1984 commented 4 years ago

To be honest I really can't tell any input lag difference, vsync alone is probably causing the most lag. Unless I am playing competitively, why play on my small 28 inch monitor with gsync to have less input lag when I can play on my 50 inch 4k tv with an almost unnoticeable bit of lag, especially when TV is in game mode. Much more immersive experience. No brainer for me. I'll stick with retroarch core and my tv until the standalone emulator is fixed.

On Thu, 27 Feb 2020, 12:52 MojoJojoDojo, notifications@github.com wrote:

The problem with using the OpenGL renderer is that you replace the frame pacing issues with input lag issues instead. There is really no best renderer currently for use.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hrydgard/ppsspp/issues/9736?email_source=notifications&email_token=AOO2VJQ4US34R763TO6ZAX3RE6ZPZA5CNFSM4DND3BWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENEIG6Y#issuecomment-591954811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOO2VJWCA6CJOV543WXHRHLRE6ZPZANCNFSM4DND3BWA .

hrydgard commented 4 years ago

For the VK backend, I'm gonna try to make VK_PRESENTMODEFIFO_KHR an option on Windows as well, we currently use MAILBOX in order to be able to present faster in case of unthrottling. Maybe that will help, most apps use FIFO or FIFO_RELAXED so driver swap paths might be more tuned for that.

JetSetter1984 commented 4 years ago

In regards to the standalone PPSSPP. DX9 working perfectly and other backends causing stutters other than OpenGL fullscreen. Is this not simply a matter of looking at the synchronization process, and specifically how DX9 remains consistent yet others stutter?

LunaMoo commented 4 years ago

@JetSetter1984 in your "X works perfectly, let's compare it to Y" logic you seem to completely ignore the facts that:

JetSetter1984 commented 4 years ago

I understand, however many people are just not sensitive to the stuttering at all or are using variable refresh rates, or just do not bother to get in touch with the PPSSPP team because they don't know how, or can't be bothered. The fact that it only happens on any version of standalone PPSSPP, not any other emulator or game and that the retroarch core runs perfectly for me does point to a problem with the emulators synchronisation.

Edit : The only other similar problem I had was on Dolphin until I disabled dual core which was suggested by BParks21, thank you.

JetSetter1984 commented 4 years ago

I just discovered something interesting. This is regarding OpenGl windowed, D3D11 and Vulkan. It seems that having vsync on or off has literally no effect. Even with it off, there is no screen tearing. The stutters happen at exactly the same places too. Other than a tick in a box, it has no function whatsoever. It is definitely a synchronisation problem, as retroarch syncs independently of the emulator and has no such issues. It may be because the emulator is forced to sync at the exact content framerate, with no deviation from core requested timing. This is good if you have freesync/gsync but terrible for any fixed refresh rate monitor/screen. It could also be that the cpu and gpu are being hard-synced, which slightly reduces latency, but hurts performance and causes stutters. These two options can cause this exact problem with any emulator in retroarch, and are disabled by default in retroarch.

mirh commented 4 years ago

This is regarding ... windowed... It seems that having vsync on or off has literally no effect.

That's called compositing and it has been the default case in Windows since Vista.

JetSetter1984 commented 4 years ago

Hey mirh, I know what desktop composition is and yes it used to be called Aero, I'll try explain a little better. I meant only OpenGL windowed suffers as OpenGL fullscreen is fine and runs smoothly... Fullscreen or windowed for vulkan and D3D11 are both as I said, with vsync doing nothing at all.

ghost commented 4 years ago

The latest vsync changes finally fixed my issues on the DX11 & Vulkan renderers. BTW now this emulator is the only one I dont get tearing issues on Vulkan as well on Windows (for all other emulators i do like Cemu and Dolphin). Thanks guys.

orbea commented 4 years ago

@unknownbrackets What happened to the vsync option? I can't find it in the settings. The only thing that seems to help for me is disabling Audio sync (resampling), but it still occurs then. I also remember this not being a problem with libretro, but that is completely broken with both GL and vulkan now...

unknownbrackets commented 4 years ago

The VSync option has only ever shown on Windows, but it still shows there under Settings -> Graphics -> Performance. On other platforms (Linux, macOS, Android, etc.), we always use vsync.

-[Unknown]

orbea commented 4 years ago

Can it be made to be user customizable on linux? It might help my setup and I usually get the best results without vsync on other emulators (PCSX2, dolphin, etc).

unknownbrackets commented 4 years ago

Probably possible. It might be as simple as changing SDL_GL_SetSwapInterval(1); to SDL_GL_SetSwapInterval(0);.

-[Unknown]

orbea commented 4 years ago

I tried that, but I'm not sure if it was either not enough or if its unrelated to the problem I am experiencing with numerous minor audio popping sounds in Lunar Silver Star Harmony.

BParks21 commented 4 years ago

So the duplicate frames option is available in the dev builds already?

ghost commented 4 years ago

I saw that you did some Vulkan changes. With the latest commits I get tearing again on Vulkan even with Vsync on... Also i get the Vulkan error when I close down PPSSPP it got fixed before but now it's not. Version 1.9.3-373 worked so good.

BParks21 commented 4 years ago

@hrydgard How is this frame duplication supposed to behave in ppsspp? It doesn't appear to be working for me. Or at least I'm getting the same reported fps and frame time behavior i would get if it were off using rivatuner and msi afterburner. I know when duplicate frames is enabled in dolphin msi after burner with report the output frames as 60 for 30fps games, and dolphins built in frame counter will report the internal fps of a 30fps game as 30.

unknownbrackets commented 4 years ago

Looks like it currently accidentally still requires you to enable some post shader.

-[Unknown]

BParks21 commented 4 years ago

Ahhhhh yes it is working correctly now with a post shader enabled! Shader on vs shader off. I can confirm that i have tested three 30fps games with duplication enabled and the frame pacing related stutter is completely gone! Thank you!

hrydgard commented 4 years ago

Cool. I'll fix it soon: #12720

pitrako commented 4 years ago

When "Render duplicate frames to 60hz" and "Vsync" are enabled in the emulator If I enter Fullscreen with alt+enter or F11 the game keeps running but keyboard/mouse doesn't respond.

unknownbrackets commented 4 years ago

Does alt-enter work to exit out of it, or are you stuck at that point? What graphics card are you using, and do you have the latest drivers?

I don't experience this on NVIDIA. That said, I have a multi-monitor setup (the only way to live), which sometimes makes fullscreen behave differently.

-[Unknown]

pitrako commented 4 years ago

Stuck in fullscreen, RTX 2080, Nvidia Drivers 442.74, PPSSPP v1.9.3-554-gc6948561f

Edit: I changed to drivers 445.75 and It's still the same.