godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.7k stars 20.12k forks source link

Vsync-Disabled only works when application is out of focus. #75108

Open CoreTaxxe opened 1 year ago

CoreTaxxe commented 1 year ago

Godot version

4.0 stable

System information

Windows 11, Vulkan, RTX 3070

Issue description

Setting VSync-mode to disabled only takes effect when the application has no focus. When regaining focus vsync is "enabled" again. The engine still thinks vsync is set to "disabled" never the less. Changing Vsync from Editor or code makes no difference.

Further things I've noticed;

How it should work: Vsync should not change based on window focus but instead respect the value set.

https://user-images.githubusercontent.com/47256718/226190274-ae29c45f-f3c8-4f76-83b8-94fc0e4da39d.mp4

Steps to reproduce

  1. Try to disable vsync.

Minimal reproduction project

VsyncTest.zip

Edit: Setting Vsync : On has an opposite effect. When focus is lost FPS drop to low values (~60fps) but ONLY if focus is still in any window in the same monitor as the game

CoreTaxxe commented 1 year ago

Also Disabling Vsync In the project settings no longer prompts a note to restart the editor. Not sure if that is intended or worthy of ann issue/proposal itself thus added it here.

Calinou commented 1 year ago

I can't reproduce this on 4.0.stable (Linux, GeForce RTX 4090 with NVIDIA 525.89.02).

Also, your video didn't upload as you clicked outside the field before it was done uploading.

CoreTaxxe commented 1 year ago
  1. 144hz, 60 hz, 60hz
  2. Enabled in monitor (adaptive sync), disabled in nvidia.
  3. No its not overridden. (Set to highest available. However setting it to application controlled doesn't change anything)

EDIT; MY setup remained the same since godot 3.2 and Vsync:off always worked with Adaptive Sync. Also Im not sure why adaptive sync would "limit" the refresh rate if the game has focus but doesn't when not but also doesn't limit the focus if another monitor has a window open that is not maximized.

That being said that should not mean I know what I am talking about and I defo will test Adaptive sync off with all the cases named before

Edit 2: I've tested it with Adaptive Sync off - didn't change anything at first - then restarted my PC and now it works as intended. This doesn't explain however the things mentioned before.

Also another thing I've noticed (adaptive on); The monitor OSD reports 144hz however the "game" is only running at 141.

Calinou commented 1 year ago

Also another thing I've noticed (adaptive on); The monitor OSD reports 144hz however the "game" is only running at 141.

It sounds like your graphics card is aware that the monitor has VRR enabled, since it's using a VRR-optimized framerate cap. This is likely because you have Low-Latency Mode set to On or Ultra in the NVIDIA Control Panel.

CoreTaxxe commented 1 year ago

Low latency mode is set to OFF, and Gsync is on if that has any relevance.

LeggoTM commented 1 year ago

I'm having the exact same issue in Godot 4.1.1, RTX 3070Ti I just recently started learning a bit on Game Development and was exploring Godot when I stumbled upon this issue. My monitor is set to 120Hz and the FPS counter in Godot shows 117 or 118 when focused. But when not in focus it skyrockets to 3000+.

Calinou commented 1 year ago

My monitor is set to 120Hz and the FPS counter in Godot shows 117 or 118 when focused. But when not in focus it skyrockets to 3000+.

Which FPS counter are you looking at? The View Frame Time panel in the editor displays estimated FPS based on CPU/GPU time, not actual FPS.

LeggoTM commented 1 year ago

My monitor is set to 120Hz and the FPS counter in Godot shows 117 or 118 when focused. But when not in focus it skyrockets to 3000+.

Which FPS counter are you looking at? The View Frame Time panel in the editor displays estimated FPS based on CPU/GPU time, not actual FPS.

I'm just printing the FPS to the console using:

func _process(delta):
    print(Engine.get_frames_per_second())
WrobotGames commented 3 months ago

Hi, I tested this today and this only seems to be an issue when using GSYNC with "enable for windowed and full screen mode" in the nvidia configuration panel. (Not the default setting) The issue occurs on all windows-modes except 'exclusive fullscreen'.\

GSYNC windowed doesn't work well in a lot of other programs, making them flicker when doing nothing or stutter when Alt-tabbing.