Skip to content

Commit 3100233

Browse files
committed
Document relationship between refresh rate and V-Sync in DisplayServer
- Mention formula for optimal FPS capping when VRR and V-Sync are both enabled. This is the same formula as used in Reflex.
1 parent d413181 commit 3100233

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

doc/classes/DisplayServer.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,11 +1774,11 @@
17741774
[b]Note:[/b] One of the following constants can be used as [param screen]: [constant SCREEN_OF_MAIN_WINDOW], [constant SCREEN_PRIMARY], [constant SCREEN_WITH_MOUSE_FOCUS], or [constant SCREEN_WITH_KEYBOARD_FOCUS].
17751775
</description>
17761776
</method>
1777-
<method name="screen_get_refresh_rate" qualifiers="const">
1777+
<method name="screen_get_refresh_rate" qualifiers="const" keywords="vsync">
17781778
<return type="float" />
17791779
<param index="0" name="screen" type="int" default="-1" />
17801780
<description>
1781-
Returns the current refresh rate of the specified screen. Returns [code]-1.0[/code] if [param screen] is invalid or the [DisplayServer] fails to find the refresh rate for the specified screen.
1781+
Returns the current refresh rate of the specified screen. When V-Sync is enabled, this returns the maximum framerate the project can effectively attain. Returns [code]-1.0[/code] if [param screen] is invalid or the [DisplayServer] fails to find the refresh rate for the specified screen.
17821782
To fallback to a default refresh rate if the method fails, try:
17831783
[codeblock]
17841784
var refresh_rate = DisplayServer.screen_get_refresh_rate()

doc/classes/ProjectSettings.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@
394394
<member name="application/run/max_fps" type="int" setter="" getter="" default="0">
395395
Maximum number of frames per second allowed. A value of [code]0[/code] means "no limit". The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project logic and rendering.
396396
Limiting the FPS can be useful to reduce system power consumption, which reduces heat and noise emissions (and improves battery life on mobile devices).
397-
If [member display/window/vsync/vsync_mode] is set to [code]Enabled[/code] or [code]Adaptive[/code], it takes precedence and the forced FPS number cannot exceed the monitor's refresh rate.
398-
If [member display/window/vsync/vsync_mode] is [code]Enabled[/code], on monitors with variable refresh rate enabled (G-Sync/FreeSync), using an FPS limit a few frames lower than the monitor's refresh rate will [url=https://blurbusters.com/howto-low-lag-vsync-on/]reduce input lag while avoiding tearing[/url].
397+
If [member display/window/vsync/vsync_mode] is set to [code]Enabled[/code] or [code]Adaptive[/code], it takes precedence and the forced FPS number cannot exceed the monitor's refresh rate. See also [method DisplayServer.screen_get_refresh_rate], which will return the maximum framerate the project can effectively attain.
398+
If [member display/window/vsync/vsync_mode] is [code]Enabled[/code], on monitors with variable refresh rate enabled (G-Sync/FreeSync), using an FPS limit slightly lower than the monitor's refresh rate will [url=https://blurbusters.com/howto-low-lag-vsync-on/]reduce input lag while avoiding tearing[/url]. At higher refresh rates, the margin needs to be increased to account for timing inaccuracies and ensure the rendering remains within the VRR window. The optimal formula for this is [code]max_fps = r - (r * r) / 3600.0[/code] where [code]r[/code] is the monitor's refresh rate.
399399
If [member display/window/vsync/vsync_mode] is [code]Disabled[/code], limiting the FPS to a high value that can be consistently reached on the system can reduce input lag compared to an uncapped framerate. Since this works by ensuring the GPU load is lower than 100%, this latency reduction is only effective in GPU-bottlenecked scenarios, not CPU-bottlenecked scenarios.
400400
See also [member physics/common/physics_ticks_per_second].
401401
This setting can be overridden using the [code]--max-fps &lt;fps&gt;[/code] command line argument (including with a value of [code]0[/code] for unlimited framerate).

0 commit comments

Comments
 (0)