PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.71k stars 1.62k forks source link

[BUG]: Stutter/Frame pacing issues in multiple games #7485

Closed ANK-dev closed 1 year ago

ANK-dev commented 1 year ago

Describe the Bug

When playing pretty much any game I suffer from constant frame pacing issues.

System specs:


image


This issue is a lot more prominent when running in full screen (borderless) with the Vulkan renderer but can happen with any other (OGL, D3D12, D3D11). I've verified my findings using MSI Afterburner with RTSS.

Reproduction Steps

I've recorded footage from two games to show as an example.

https://user-images.githubusercontent.com/40664661/204108032-640762b1-6368-40fc-b018-d16a946e9916.mp4

The most consistent setup for this example was to go to the "Chamber o'Horrors" stage and go in and out of the first door. After some tries, the frametime graph begins to show spikes and the movement becomes choppy indicating a frame pacing issue. Toggling the software renderer with the \<F9> key on-and-off seems to clear the issue [1:40-1:50, 2:05-2:27, and many more].

At [6:00] I show that if I unlock my framerate cap when the frame pacing issue is occurring my max FPS is very low (~80 FPS). Soon after, I toggle the software renderer on-and-off, which clears the inconsistent frame pacing, followed by uncapping my framerate. This yields much better performance (~287 FPS).

https://user-images.githubusercontent.com/40664661/204108213-fc9e3a77-de74-4ab5-b351-b8fc8742c8d9.mp4

Booting the game and starting a training match is enough to result in plenty of stutter, as shown by the frametime graph [0:55]. Exiting full screen seems to clear the issue [1:28]. Toggling "Spin GPU During Readbacks" in the "Graphics" > "Rendering" section then going into full screen relieves the issue somewhat [1:35]. At [2:15] I show that toggling off "Spin GPU During Readbacks" and going back into full screen results in increased stutter. Soon after [2:25], I toggle the software renderer on-and-off which clears all issues, resulting in a perfectuly flat frametime graph and very smooth gameplay.


Sometimes when testing, simply toggling the software renderer on-and-off once might not be enough to result in smooth frame pacing. A combination of several toggles of the software renderer, framerate limiter and graphics settings might be needed to get the desired result. I have not found the cause for this or any way to consistently reproduce.

Expected Behavior

The games should run smoothly without any frame pacing issues given my system specs are much higher than the recommended ones.

PCSX2 Revision

v.1.7.3634

Operating System

Windows 11

If Linux - Specify Distro

No response

CPU

AMD Ryzen 7 5700G

GPU

AMD Radeon RX570 8GB

GS Settings

Graphics:

Emulation Settings

Emulation:

GS Window Screenshots

No response

Logs & Dumps

No response

MrCK1 commented 1 year ago

Based on the Klonoa video, you are bouncing over the framelimiter (59.94) which could be causing your uneven frame pacing. Can you try without Optimal Frame Pacing and Scale to Host Refresh Rate options?

Please post your settings from the Emulation and Graphics tabs as well image

ANK-dev commented 1 year ago

Sure. These are my settings as I had then in my original videos. image image image image image image


I've disabled the "Optimal Frame Pacing" and "Scale to Host Refresh Rate" as asked and recorded a new video.

https://user-images.githubusercontent.com/40664661/204110141-bdcc0b20-6ddd-4ca5-a723-40d6647c4e65.mp4

As you can see the problem is still present and appears quite nondeterministic in nature, only triggering after several tries [2:44].

ghost commented 1 year ago

I Can confirm this issue.

KawaiiDinosaur commented 1 year ago

Same on Linux

Screenshot_20221127_185646

mirh commented 1 year ago

Shouldn't you disable vsync and use the way lighter native resolution to test all these things?

ANK-dev commented 1 year ago

Still happens at native resolution and vsync off. Screenshot (44)

ps1freak26 commented 1 year ago

@ANK-dev Try disabling the speed limiter and setting 60 framerate limit in rivatuner with vsync on.

ANK-dev commented 1 year ago

Did the rivatuner thing; as usual it follows the same pattern: weird frame pacing -> turn on software renderer -> turn off software renderer -> frame pacing is fixed.

Funny enough, in attempting to record footage of this with OBS, as soon as I hit the record hotkey, the frame pacing issue gets fixed. Don't know if this could be a GPU power saving mode issue or what else.

https://user-images.githubusercontent.com/40664661/207480475-8e7ecf97-d26b-4bf8-a800-9815c8e50e6a.mp4

Happens right at the start of the video. This is with the speed limiter disabled and rivatuner set to 60fps

mirh commented 1 year ago

Try a diagnostic boot from msconfig (please take note it's gonna disrupt your windows password settings) Try the high performance power plan And I guess you could try to disable your dGPU and just run on the integrated for the lulz

ANK-dev commented 1 year ago

Two findings:

image image

https://user-images.githubusercontent.com/40664661/207988329-97ff9b0a-2b74-41a0-b658-cfcf76fd4002.mp4


Also, incorrect frame pacing seems to occur in the software renderer occasionally, maybe it's related to the CPU frequency?

ps1freak26 commented 1 year ago

I don't have frame pacing issues with opengl and vulkan on wx there should be a qt banner. I have wait for vsync on refresh disabled and EnableVsyncWindowFlag enabled on the pcsx2_ui.ini file. Gsync is enabled and qt doesn't like my monitor reporting 60hz it always reports 75hz on qt with opengl and vulkan in the monitor information section which makes games stutter alot.

ANK-dev commented 1 year ago

@ps1freak26 wxWidgets is going away soon. Do you have problems on the latest build of Qt?

ps1freak26 commented 1 year ago

Yes I still have frame pacing issues with PCSX2 QT. I use WX if I need to use the vulkan render. I use QT if I need to use software and dx12 hardware. I tested dolphin with qt6 and it didn't have any of the issues expect vulkan borderless working with gsync but opengl exclusive and borderless have perfect frame pacing and gsync compatibility. Vulkan with exclusive mode has perfect frame pacing and gsync compatibility.

Context6016 commented 1 year ago

I think I managed to fix the issue by adding pcsx2 to nvidia CP and changing "vulkan/openGL present method" to "prefer layered on DXGI swapchain" no idea what the AMD equivalent option is though.

ps1freak26 commented 1 year ago

DXGI swapchain on is smooth when the frame limiter is off and it's stuck at 75 instead of 150 (250% fast forward speed) but when I turn it on the frame limiter still stutters alot. It gets unstuck when it's minimized or the window is not in focus. Rivatuner capped at 60 still stutters.

Context6016 commented 1 year ago

@ps1freak26 I'm not using a VRR display so I can't comment on that, but on my end I run PCSX2 in windowed mode with speed limiter and vsync enabled (no RTSS). From an hour or so gameplay testing with vulkan renderer I haven't had any issues with frame pacing anymore after I changed that setting.

refractionpcsx2 commented 1 year ago

I was just looking in to this with Dragonball Z BT 3 and I do kinda see some frame jitter, but not as bad as described in this thread, and disabling hardware readbacks got rid of it almost completely.

If that is your issue, then there's not a lot we can do about it, you can adjust that setting in the per game graphics->advanced settings.

refractionpcsx2 commented 1 year ago

Can you also try setting your renderer to OpenGL to see if that helps in the other games? DBZ I'm pretty confident is mostly a GS Download problem, but the others don't suffer from that, iirc.

Context6016 commented 1 year ago

I'm 99% positive it's either a windows or driver issue, because it also happened to me on RPCS3 with vulkan renderer. Changing the setting I mentioned above also fixed it for RPCS3.

JordanTheToaster commented 1 year ago

It's fine for me even with VK at 8x with high blending and readbacks going.

image

refractionpcsx2 commented 1 year ago

This is only since recent changes merged, this hasn't always been the case.

Edit: The changes have been in there for a while, but nobody really knew about it, and it wasn't on :P But It was improved and made default on recently.

ps1freak26 commented 1 year ago

7807 Fixed the frame pacing in vulkan and setting power management mode in the nvidia graphics control panel to prefer maximum performance fixes Gsync with Vulkan. When fast forward is set to 250% I still can't get 150 fps at 75hz it's locked to 73-75 with vulkan.

ANK-dev commented 1 year ago

Closing this issue. It seems like the #7807 + manually setting the GPU and VRAM clock speed (to fix AMD's buggy Vulkan drivers) have solved the problem.

ps1freak26 commented 1 year ago

Clean install of the Nvidia drivers fixed frame rate locked at the refresh rate when fast forward is on.

mirh commented 1 year ago

I wonder if it couldn't be that you had windowed G-sync enabled...

ps1freak26 commented 1 year ago

I had enabled for windowed and full screen mode selected.

mirh commented 1 year ago

Then you being limited is pretty much to be expected... Ironically enough, if the game window loses active focus, it would get unlocked.