godotengine / godot

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

VSync behaves strangely on linux with nvidia GPU #95024

Open DaniilAlpha opened 2 months ago

DaniilAlpha commented 2 months ago

Tested versions

System information

Fedora 40 (6.9.12-200.fc40.x86_64) - any renderer - Nvidia RTX 3060 Ti, proprietary driver 555.58.02

Issue description

After starting a game (either build, debug and release, on from editor) fps shows to be 60, just to drop to 30 after a few seconds (based on profiler data). When forcing fps to be 60, profiler shows 60 all the time, but visually it's obvious that that behaves the same way. Though when disabling vsync AND setting max fps to 0, framerate does not drop. Some additional info to help identify the issue:

Steps to reproduce

  1. Create an empty project, make sure VSync is enabled and max FPS set to 0
  2. Run the project
  3. Watch the profiler fps, it will look like this image
  4. Resize the window. There will be a small peak, showing that 60 fps was back for a couple of seconds

Minimal reproduction project (MRP)

Default empty project.

Calinou commented 2 months ago

Do you have a multi-monitor setup (if so, which refresh rates do the monitors have)? Also, are you on a X11 or Wayland session? Use echo $XDG_SESSION_TYPE in a terminal to know.

DaniilAlpha commented 2 months ago

No, a single monitor. I am on a wayland session.

DaniilAlpha commented 2 months ago

I was exploring godot demo projects for 4.2 version, and noticed one strange thing: this king of lag is not present of some of the 3d demoes even when vsync is enabled (notably, voxel demo) and some of 3d and 2d demoes (e.g. platformer, both 3d and 2d) has it only when playing on small window (though it drops to 37-40 fps instead of 30). When I maximize window, it runs smoothly on 60 fps. I have a single 3440x1440 monitor with the 21:9 aspect ratio, so i think it has to do something with it, considering how it works for most of the people, and also depends on window size, but it is just speculation.

Calinou commented 2 months ago

Do you have variable refresh rate (G-Sync Compatible) enabled in nvidia-settings?

DaniilAlpha commented 2 months ago

I am not sure, but seems that this option is not available on kde + wayland (at least i cannot see it). The arch wiki says that "kwin should automatically enable VRR for full screen applications".