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

VSync issue in windowed mode #12614

Closed
JetSetter1984 opened this issue Feb 4, 2020 · 13 comments
Closed

VSync issue in windowed mode #12614

JetSetter1984 opened this issue Feb 4, 2020 · 13 comments

Comments

@JetSetter1984
Copy link

What happens?

I have discovered an issue which is present in every backend except for Direct3D 9. When running in windowed mode, the game will stutter badly at regular intervals. Audio not stuttering and game speed is 100%, constant 60fps. Have tried a few titles all exhibiting the same behaviour. A great game to witness the issue on is Ridge Racer 2. Fullscreen is fine, so I believe this has something to do with the difference in vsync implementation between backends and the interaction with windows. Any further information or a solution to the issue would be greatly appreciated, thank you.

What should happen?

Game should run smoothly with all backends in windowed mode as it does in D3D9.

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

AMD Ryzen 3600X, ROG Strix GTX 1080Ti, 16GB DDR4 3600MHz, Windows 10 Pro, PPSSPP 1.9.3 any version, same behaviour.

@LunaMoo
Copy link
Collaborator

LunaMoo commented Feb 4, 2020

Check if you have any driver hacks enforcing things to application or some third party apps, especially overlays as you're probably the only person with such issue, first one for sure.

@JetSetter1984
Copy link
Author

Thanks for the reply LunaMoo. I have ensured no overlays or 3rd party apps are running and have closed all but the necessary windows applications and tried again. I have even tried old nvidia drivers as far back as 2015. The issue definitely still persists. D3D9 is perfect windowed or fullscreen. With other backends it is only in windowed mode, going full screen is fine. I will add that I am using vsync and a 60hz refresh rate.

@JetSetter1984
Copy link
Author

JetSetter1984 commented Feb 6, 2020

OK, so I have tried absolutely everything I can think of and at this point it seems there is no solution. It has also become apparent that using vulkan and DX11 in fullscreen will also stutter badly at regular intervals for anything between 1 second and 3 seconds. This seems to be directly related to the vsync implementation on these backends as DX9 is perfect windowed or fullscreen, and opengl is fine ONLY in fullscreen.

@hrydgard
Copy link
Owner

hrydgard commented Feb 6, 2020

I don't know how we could fix that since I've never seen anything like that on my hardware. Regular interval stutters for 1-3 seconds? Just bizarre. I think there's some issue with your machine or software that's unrelated to PPSSPP.

@JetSetter1984
Copy link
Author

Thank you for the response, I have to thank you and the other contributors for your amazing work on PPSSPP and Dolphin, I feel honoured to get a reply from the man himself! Honestly Henrik, a pleasure to receive a response from yourself, thank you. Do you use a 60hz monitor with vsync because it may only be an issue with these. It is also strange that DX9 works perfectly, and opengl only exhibits the problem in windowed mode. My system is pretty powerful and I have no problem with any other games using vsync at 60hz in windowed mode, other than GTA V which runs at 63fps in windowed mode for some bizarre reason. I believe it is to do with the synchronization of the display being tied to the game engine speed, as when troubleshooting I tried to run 50hz to see if this would show up anything but then the game run at around 80 percent speed. I believe if the emulator could synchronize with the display independently of the game engine itself this would completely solve the problem. I am not a programmer, so I do not know if this is possible or how hard it would be to implement. What are your thoughts on this? Thank you once again.

@ghost
Copy link

ghost commented Feb 8, 2020

I am not the only one who gets it.
I also got the issue when running backends besides Vulkan (which also got a different issue related to tearing).
Didn't try DX9 yet though.
I think there is some sort of frame pacing issue here - I was running Shin Budokai 2 and it reports 60 fps but for some intervals it will appear stuttery and than return to being normal.
I have a 60 hz monitor and its not a VRR one so maybe thats why others are not noticing it.
EDIT: I tried DX9 and could confirm there are either less or non exisiting frame pacing issues with it.
BTW Dolphin had a similar issue but with 30 fps games instead of 60 fps and they fixed it by using the "skip presenting duplicate frames" option.
Here is their blog post about it from this month : https://dolphin-emu.org/blog/2020/02/07/dolphin-progress-report-dec-2019-and-jan-2020/.

@JetSetter1984
Copy link
Author

Hi Mojo thank you for chipping in here. The issue you describe is exactly what I experience, however, my vulkan backend is no good fullscreen or windowed. I am getting 60fps consistently but it all falls out of sync every so often and returns to normal. As previously mentioned I believe it is due to the emulator not syncing to the display independently of the game. This can be seen as running a game with your monitor @50Hz will cause the game itself to slow down. You have AMD or NVidia GPU?

@LunaMoo
Copy link
Collaborator

LunaMoo commented Feb 9, 2020

Oh I see, so this is just a duplicate of #9736

To sum it up:

  • only few users with Nvidia gpu's has that problem,
  • only experienced on budget hardware(old/bad fixed sync displays),
  • we already have a workaround for that which currently is somewhat bothersome as it requires to use a post process shader with 60fps flag, you can use my empty shader from 30FPS frame pacing issues #12460 (comment) if you want a clear, unmodified image with that workaround,
  • in the possibly near future we will have an option to improve it, but currently we have a different issue which ruins displaying frames even more and for everyone when certain conditions happen(frameskipping+post process effect) which has to be solved first.

About Dolphin as read in their blog "skip presenting duplicate frames" is NOT a fix for that issue, but an option which restores original behaviour, if selecting it helps you, this might be some completely different issue after all.

Closing as we don't need to have multiply issues about same thing..

@LunaMoo LunaMoo closed this as completed Feb 9, 2020
@JetSetter1984
Copy link
Author

Thank you LunaMoo, but it is for Android. Could you post me one for windows please? Thanks again.

@LunaMoo
Copy link
Collaborator

LunaMoo commented Feb 9, 2020

It's not "for android", it's an empty post process shader with a flag that forces frame duplication and will work on any system. For some reason Henrik wanted to keep the android issue open separately from the big one that included the same thing and for some reason when I prepared that shader as a test whenever it will help I added android in the name, but it will do same thing on any other affected platform.

Just extract the files from inside into "..ppsspp/assets/shaders" folder.
The same flag is used by default in "CRT Scanlines" shader if you want to quickly test whenever it helps, but that effect might be distracting/ugly for many, it also can be added to any other post process shader by editing it's ini file(defaultshaders.ini for default shaders) and adding 60fps=True under the desired effect.

@JetSetter1984
Copy link
Author

Tried it and made no difference, but thank you anyway. Unless playing competitive games, I use my 4k HDR Panasonic TV @60Hz and no syncing issues in anything else. Just confused as to why DX9 completely eliminates the issue and OpenGL fullscreen is fine too... Strange. Is there any possibility of looking at how DX9 syncs as opposed to the other backends? Maybe using the DX9 method of syncing would help. Thanks again.

@unknownbrackets
Copy link
Collaborator

Personally, I do not use vsync (PSP games double buffer anyway.)

PSP games produce 59.94 frames per second, and I tend to prefer my monitor at 75 Hz (or higher.) I do not want the PSP frames aligned to monitor refreshes, because the numbers are fairly different and the math works out poorly between those two numbers.

Note that the OpenGL and Vulkan backends do (for efficiency reasons) disconnect the game's rendering commands (which PSP games assume will be timed at the proper 59.94) with the OS driver rendering, which may lessen the impact of 50 Hz or 75 Hz on them. It's unlikely anyone is going to undertake the fairly significant effort required to rebuild the Direct3D 9 backend to do this.

Just to make sure it's clear: PPSSPP is not a project to rebuild PSP game engines from scratch. PSP games generally produce 59.94 or 29.97 frames each second. There's no way to tell them to produce 50 or 75 each second (this would just speed up/slow down games), at best we can take those 59.94 frames and decide which 9.94 of them to discard. Even at 60 Hz, this problem happens.

That's why, again, I personally don't use vsync. My drivers are able to work out just fine (and efficiently) which of those 59.94 frames should be used, and when. Whatever latency improvements vsync might bring seem pointless in comparison to the timing impact it will have.

-[Unknown]

@JetSetter1984
Copy link
Author

Thanks for the response and this is exactly what I'm saying... To not have the PSP frames synced to the monitor, but have the display synced at 60hz seperately. I wasn't saying to rebuild DX9 again, because DX9 has no issues whatsoever whilst other backends do produce this stutter. My display is 59.994hz or 60hz in windows, tried both, yet the game still stutters using any other backend, vsync on or off, yet the game is running at a constant 100% speed as my system has no trouble at all with PSP titles. If a difference could be seen in how DX9 syncs as opposed to other backends, it might eliminate stutter for everybody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants