Add a --max-fps command-line argument to set a FPS limit

This allows limiting framerate on any project, which is useful to
reduce power usage and latency with certain setups (such as VRR displays).

This is particularly useful in projects that do not expose a setting to change
the FPS limit. While external FPS limiters can be used, they can be cumbersome
to set up and result in increased input lag compared to a built-in FPS limiter.
This commit is contained in:
Hugo Locurcio
2023-06-08 19:33:10 +02:00
parent da81ca62a5
commit 4cab77094a
6 changed files with 25 additions and 2 deletions

View File

@@ -105,8 +105,11 @@ Show collisions shapes when running the scene.
\fB\-\-debug\-navigation\fR
Show navigation polygons when running the scene.
.TP
\fB\-\-max\-fps\fR <fps>
Set a maximum number of frames per second rendered (can be used to limit power usage). A value of 0 results in unlimited framerate.
.TP
\fB\-\-frame\-delay\fR <ms>
Simulate high CPU load (delay each frame by <ms> milliseconds).
Simulate high CPU load (delay each frame by <ms> milliseconds). Do not use as a FPS limiter; use --max-fps instead.
.TP
\fB\-\-time\-scale\fR <scale>
Force time scale (higher values are faster, 1.0 is normal speed).

View File

@@ -69,6 +69,7 @@ _arguments \
'--debug-collisions[show collision shapes when running the scene]' \
'--debug-navigation[show navigation polygons when running the scene]' \
'--debug-stringnames[print all StringName allocations to stdout when the engine quits]' \
'--frame-delay[set a maximum number of frames per second rendered (can be used to limit power usage), a value of 0 results in unlimited framerate]:maximum frames per seocnd' \
'--frame-delay[simulate high CPU load (delay each frame by the given number of milliseconds)]:number of milliseconds' \
'--time-scale[force time scale (higher values are faster, 1.0 is normal speed)]:time scale' \
'--disable-vsync[disable vertical synchronization even if enabled in the project settings]' \

View File

@@ -72,6 +72,7 @@ _complete_godot_options() {
--debug-collisions
--debug-navigation
--debug-stringnames
--max-fps
--frame-delay
--time-scale
--disable-vsync

View File

@@ -89,6 +89,7 @@ complete -c godot -l remote-debug -d "Enable remote debugging"
complete -c godot -l debug-collisions -d "Show collision shapes when running the scene"
complete -c godot -l debug-navigation -d "Show navigation polygons when running the scene"
complete -c godot -l debug-stringnames -d "Print all StringName allocations to stdout when the engine quits"
complete -c godot -l max-fps -d "Set a maximum number of frames per second rendered (can be used to limit power usage), a value of 0 results in unlimited framerate" -x
complete -c godot -l frame-delay -d "Simulate high CPU load (delay each frame by the given number of milliseconds)" -x
complete -c godot -l time-scale -d "Force time scale (higher values are faster, 1.0 is normal speed)" -x
complete -c godot -l disable-render-loop -d "Disable render loop so rendering only occurs when called explicitly from script"