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

Add support for adaptive V-Sync #1283

Closed
Calinou opened this issue Jul 31, 2020 · 6 comments · Fixed by godotengine/godot#48622
Closed

Add support for adaptive V-Sync #1283

Calinou opened this issue Jul 31, 2020 · 6 comments · Fixed by godotengine/godot#48622
Milestone

Comments

@Calinou
Copy link
Member

Calinou commented Jul 31, 2020

Describe the project you are working on:

The Godot editor 🙂

Describe the problem or limitation you are having in your project:

Traditional V-Sync is able to eliminate tearing, but will introduce stuttering if the device can't keep up with the monitor's refresh rate. For instance, with a 60 Hz monitor, getting 50 FPS will display 40 frames at full speed, but 10 frames in that second will be displayed for twice as long. This makes the game look like it's effectively running at 30 FPS during those stuttering periods. The default V-Sync behavior can also lead to confusion.

Variable refresh rate monitors can solve this issue. While they've been on the rise lately, not everyone has access to such a monitor, especially in laptops where the display typically can't be upgraded.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Note that adaptive V-Sync can be used on any monitor and has no relation to G-Sync or FreeSync. This video from Digital Foundry should be helpful to clear confusion about the various V-Sync modes available out there.

Compared to variable refresh rate monitors, adaptive V-Sync is a slightly older technique, being popularized in the early 2010s. It works by automatically disabling V-Sync if the FPS goes below the monitor refresh rate. This introduces tearing, but avoids stuttering and decreases input lag in periods where the game doesn't run as smoothly. This is usually a better compromise in those situations.

V-Sync will enable itself again automatically once the FPS goes back above the monitor refresh rate.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

The V-Sync project setting and associated RenderingServer property should be converted from a boolean to an enum with the following values: "Disabled", "Enabled (Traditional)", "Enabled (Adaptive)".

We should also evaluate making adaptive V-Sync the default as it can significantly improve the player's experience. Likewise, it should also make the editor feel smoother and more reactive in heavier scenes.

See also this pull request: godotengine/godot#36862

If this enhancement will not be used often, can it be worked around with a few lines of script?:

No, as implementing adaptive V-Sync requires changes to the core rendering code. The user may be able to force adaptive V-Sync in their graphics driver control panel, but this relies on OS- and hardware-specific features not always available on macOS or Linux.

Is there a reason why this should be core and not an add-on in the asset library?:

Implementing adaptive V-Sync requires changes to the core rendering code.

@jonbonazza
Copy link

Is there a surefire way to get the monitor refresh rate on all platforms? What do you do about mobile?

@jonbonazza
Copy link

Im primarily concerned about linux. I dont think this would be something in the kernel, so there could be any number of ways to do this depending on what modile6s window manager, etc... that the user is running.

@Calinou
Copy link
Member Author

Calinou commented Jul 31, 2020

@jonbonazza I addressed that precise concern in #1284 😉

I need to look at how other engines implement adaptive V-Sync.

@jonbonazza
Copy link

Thats all well and good, but the linux situation still concerns me. From what i can tell from some very quick research, this is specific to the windows manager. Does godot support anything other than X11 currently?

@Calinou
Copy link
Member Author

Calinou commented Jul 31, 2020

I've seen many applications successfully get the monitor refresh rate using SDL2. For instance, Red Eclipse limits the FPS to the monitor's refresh rate by default (/maxfps -1).

Does godot support anything other than X11 currently?

Not yet, but Wayland support is planned for 4.0.

@aaronfranke
Copy link
Member

As long as it's still possible to have traditional V-Sync (which I prefer), sounds good to me.

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

Successfully merging a pull request may close this issue.

3 participants