You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-25 15:37:42 +00:00
Add frame delta smoothing option (4.x)
Frame deltas are currently measured by querying the OS timer each frame. This is subject to random error. Frame delta smoothing instead filters the delta read from the OS by replacing it with the refresh rate delta wherever possible. This PR also contains code to estimate the refresh rate based on the input deltas, without reading the refresh rate from the host OS. The delta_smooth_enabled setting can also be modified at runtime through OS::, and there is also now a command line setting to override the project setting.
This commit is contained in:
@@ -468,6 +468,7 @@ void Main::print_help(const char *p_binary) {
|
||||
OS::get_singleton()->print(" --disable-render-loop Disable render loop so rendering only occurs when called explicitly from script.\n");
|
||||
OS::get_singleton()->print(" --disable-crash-handler Disable crash handler when supported by the platform code.\n");
|
||||
OS::get_singleton()->print(" --fixed-fps <fps> Force a fixed number of frames per second. This setting disables real-time synchronization.\n");
|
||||
OS::get_singleton()->print(" --delta-smoothing <enable> Enable or disable frame delta smoothing ['enable', 'disable'].\n");
|
||||
OS::get_singleton()->print(" --print-fps Print the frames per second to the stdout.\n");
|
||||
OS::get_singleton()->print("\n");
|
||||
|
||||
@@ -791,6 +792,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
Vector<String> breakpoints;
|
||||
bool use_custom_res = true;
|
||||
bool force_res = false;
|
||||
bool delta_smoothing_override = false;
|
||||
|
||||
String default_renderer = "";
|
||||
String default_renderer_mobile = "";
|
||||
@@ -1000,6 +1002,29 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->print("Missing tablet driver argument, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
} else if (I->get() == "--delta-smoothing") {
|
||||
if (I->next()) {
|
||||
String string = I->next()->get();
|
||||
bool recognised = false;
|
||||
if (string == "enable") {
|
||||
OS::get_singleton()->set_delta_smoothing(true);
|
||||
delta_smoothing_override = true;
|
||||
recognised = true;
|
||||
}
|
||||
if (string == "disable") {
|
||||
OS::get_singleton()->set_delta_smoothing(false);
|
||||
delta_smoothing_override = false;
|
||||
recognised = true;
|
||||
}
|
||||
if (!recognised) {
|
||||
OS::get_singleton()->print("Delta-smoothing argument not recognised, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
N = I->next()->next();
|
||||
} else {
|
||||
OS::get_singleton()->print("Missing delta-smoothing argument, aborting.\n");
|
||||
goto error;
|
||||
}
|
||||
} else if (I->get() == "--single-window") { // force single window
|
||||
|
||||
single_window = true;
|
||||
@@ -1908,6 +1933,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(
|
||||
GLOBAL_DEF(PropertyInfo(Variant::INT, "application/run/low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "0,33200,1,or_greater"), 6900)); // Roughly 144 FPS
|
||||
|
||||
GLOBAL_DEF("application/run/delta_smoothing", true);
|
||||
if (!delta_smoothing_override) {
|
||||
OS::get_singleton()->set_delta_smoothing(GLOBAL_GET("application/run/delta_smoothing"));
|
||||
}
|
||||
|
||||
GLOBAL_DEF("display/window/ios/allow_high_refresh_rate", true);
|
||||
GLOBAL_DEF("display/window/ios/hide_home_indicator", true);
|
||||
GLOBAL_DEF("display/window/ios/hide_status_bar", true);
|
||||
|
||||
Reference in New Issue
Block a user