godot icon indicating copy to clipboard operation
godot copied to clipboard

FPS is not limited by the monitor refresh rate even if the v-sync is enabled

Open tokengamedev opened this issue 1 year ago • 4 comments

Tested versions

  • 4.3 stable

System information

Windows 11, Dual Monitor (120hz and 60hz) 1920 X 1080 both displays

Issue description

When there are two monitors with different refresh rates. like 120hz and 60hz and 120hz monitor being primary. If you run any game on 2nd monitor the fps still limits at 120 rather than 60.

This is an issue as per the documentation of the max_fps

If ProjectSettings.display/window/vsync/vsync_mode is Enabled or Adaptive, the setting takes precedence and the max FPS number cannot exceed the monitor's refresh rate.

Note: vsync is enabled

This may be a root cause of another issue where if you move the character a very mild jitter happens when both monitor frequency as well as Physics TPS are same at 60, with Physics interpolation Enabled or Disabled (both cases) Also with jitter fix value set between 0.0 to 0.5 (all combinations) Only case it works: Monitor frequency at 120hz, TPS =60 Jitter value = 0.0, Physics Interpolation = enabled

Steps to reproduce

Prerequisite:

  • 2 monitors with different frequency

Steps:

  • Create a project and a scene and save it.
  • Enable the print fps
  • Run the project in the second monitor and observe the fps output
  • it will be dictated by the primary monitor.

Works fine in 3.5.3

Minimal reproduction project (MRP)

if required I have a project but it is not applicable

tokengamedev avatar Aug 17 '24 17:08 tokengamedev

For some reason with me when I enable the v-sync it limits the fps only inside launched games but not 2/3d preview in the editor, but I have only one monitor.

vavakado avatar Aug 17 '24 19:08 vavakado

I think this is a Windows issue. Does it occur in other games in windowed or borderless fullscreen mode (not exclusive fullscreen)?

but not 2/3d preview in the editor, but I have only one monitor.

This is because the FPS displayed in the editor is an estimation, not the actual rendered FPS. Therefore, it can display a FPS estimation higher than the monitor refresh rate when V-Sync is enabled, but the actual rendering FPS is still capped.

Calinou avatar Aug 17 '24 19:08 Calinou

I have not tested in borderless and full screen mode, I will test and get back on it soon. one more thing to add if you change the monitor frequency from 120 to 60 or 75 in NVIDIA settings, the FPS is corrected accordingly. when running the game in both the monitors, it will show 60 or 75 accordingly and max FPS could be set to maximum of the primary monitor settings.

This is because the FPS displayed in the editor is an estimation, not the actual rendered FPS. Therefore, it can display a FPS estimation higher than the monitor refresh rate when V-Sync is enabled, but the actual rendering FPS is still capped.

It also felt like that, but numbers shows things different. I will create a small project and test it out

The only thing left for me is to correct minor jitter when all three (FPS, TPS, and Monitor refresh rate) are same without pushing move_and_slide() to _process

tokengamedev avatar Aug 17 '24 20:08 tokengamedev

The only thing left for me is to correct minor jitter when all three (FPS, TPS, and Monitor refresh rate) are same without pushing move_and_slide() to _process

To correct jitter in all situations (including temporary framerate drops), you need to enable physics interpolation in the project settings. It's available in 2D in 4.3, and in 2D and 3D in master.

Calinou avatar Aug 17 '24 23:08 Calinou

The problem is physics interpolation seems to not work when the refresh rate is same as TPS and FPS. I am testing it, I hope I am wrong.

tokengamedev avatar Aug 18 '24 09:08 tokengamedev

Tested a bit more in all the scenarios as asked like borderless, full screen, 3.x, It seems it is valid bug.

Enabling Vsync limits FPS based on the refresh rate of the primary screen rather than what screen the game runs on.

Also verified it impacts the delta values in _physics_process and _process methods, ultimately it will impact the movement of characters using _physics_process

In 3.5.3, it is not reproducible as FPS and delta values automatically adjust based on the screen.

I agree and I think it is correct that the max FPS should be limited to monitor refresh rates, but by the screen on which the game is running. I will leave up to you to decide to fix or not fix it. Let me know if I can help in any way.

Finally, regarding the jitter for my basic character movement and fix by the physics Interpolation, it is not the scope of this issue, I may create a separate Issue for it with MRP, but as of now I am working on it, and it is not fixed. The only option I think is directly manipulate the delta values by reverse engineering Physics Interpolataion (just for testing it works).

tokengamedev avatar Aug 18 '24 15:08 tokengamedev

I had a similar issue here as well. I'm new to this and doing the "Your first 3D game" on the Godot doc, so it's a very simple game. Whenever I'd run the project to test, my GPU usage would spike to around 50% and cause some kind of coil whine even with the fps capped with v-sync on in the editor.

I had to limit the fps through the NVIDIA control panel to fix it. Now my laptop doesn't produce a screeching sound and GPU usage is around 11%. And this was happening without any secondary monitor. Once again, I'm new to this so maybe I was just doing something wrong?

Retsoo avatar Aug 30 '24 18:08 Retsoo

It is a limitation in Godot so closing it.

tokengamedev avatar Oct 02 '24 09:10 tokengamedev