summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp68
-rw-r--r--main/main.h4
-rw-r--r--main/main_timer_sync.cpp76
-rw-r--r--main/main_timer_sync.h22
-rw-r--r--main/performance.cpp4
-rw-r--r--main/performance.h4
6 files changed, 88 insertions, 90 deletions
diff --git a/main/main.cpp b/main/main.cpp
index c492cfaad7..58782fa9c1 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -256,8 +256,8 @@ void finalize_navigation_server() {
void Main::print_help(const char *p_binary) {
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
OS::get_singleton()->print("Free and open source software under the terms of the MIT license.\n");
- OS::get_singleton()->print("(c) 2007-2020 Juan Linietsky, Ariel Manzur.\n");
- OS::get_singleton()->print("(c) 2014-2020 Godot Engine contributors.\n");
+ OS::get_singleton()->print("(c) 2007-2021 Juan Linietsky, Ariel Manzur.\n");
+ OS::get_singleton()->print("(c) 2014-2021 Godot Engine contributors.\n");
OS::get_singleton()->print("\n");
OS::get_singleton()->print("Usage: %s [options] [path to scene or 'project.godot' file]\n", p_binary);
OS::get_singleton()->print("\n");
@@ -528,6 +528,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
ClassDB::register_class<Performance>();
engine->add_singleton(Engine::Singleton("Performance", performance));
+ // Only flush stdout in debug builds by default, as spamming `print()` will
+ // decrease performance if this is enabled.
+ GLOBAL_DEF("application/run/flush_stdout_on_print", false);
+ GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true);
+
GLOBAL_DEF("debug/settings/crash_handler/message",
String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues"));
@@ -1121,11 +1126,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
#endif
- // Only flush stdout in debug builds by default, as spamming `print()` will
- // decrease performance if this is enabled.
- GLOBAL_DEF("application/run/flush_stdout_on_print", false);
- GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true);
-
GLOBAL_DEF("logging/file_logging/enable_file_logging", false);
// Only file logging by default on desktop platforms as logs can't be
// accessed easily on mobile/Web platforms (if at all).
@@ -2007,7 +2007,7 @@ bool Main::start() {
script));
}
- script_loop->set_init_script(script_res);
+ script_loop->set_initialize_script(script_res);
main_loop = script_loop;
} else {
return false;
@@ -2026,7 +2026,7 @@ bool Main::start() {
DisplayServer::get_singleton()->alert("Error: Invalid MainLoop script base type: " + script_base);
ERR_FAIL_V_MSG(false, vformat("The global class %s does not inherit from SceneTree or MainLoop.", main_loop_type));
}
- script_loop->set_init_script(script_res);
+ script_loop->set_initialize_script(script_res);
main_loop = script_loop;
}
}
@@ -2422,7 +2422,7 @@ bool Main::is_iterating() {
// For performance metrics.
static uint64_t physics_process_max = 0;
-static uint64_t idle_process_max = 0;
+static uint64_t process_max = 0;
bool Main::iteration() {
//for now do not error on this
@@ -2438,19 +2438,19 @@ bool Main::iteration() {
uint64_t ticks_elapsed = ticks - last_ticks;
int physics_fps = Engine::get_singleton()->get_iterations_per_second();
- float frame_slice = 1.0 / physics_fps;
+ float physics_step = 1.0 / physics_fps;
float time_scale = Engine::get_singleton()->get_time_scale();
- MainFrameTime advance = main_timer_sync.advance(frame_slice, physics_fps);
- double step = advance.idle_step;
- double scaled_step = step * time_scale;
+ MainFrameTime advance = main_timer_sync.advance(physics_step, physics_fps);
+ double process_step = advance.process_step;
+ double scaled_step = process_step * time_scale;
- Engine::get_singleton()->_frame_step = step;
+ Engine::get_singleton()->_process_step = process_step;
Engine::get_singleton()->_physics_interpolation_fraction = advance.interpolation_fraction;
uint64_t physics_process_ticks = 0;
- uint64_t idle_process_ticks = 0;
+ uint64_t process_ticks = 0;
frame += ticks_elapsed;
@@ -2458,7 +2458,7 @@ bool Main::iteration() {
static const int max_physics_steps = 8;
if (fixed_fps == -1 && advance.physics_steps > max_physics_steps) {
- step -= (advance.physics_steps - max_physics_steps) * frame_slice;
+ process_step -= (advance.physics_steps - max_physics_steps) * physics_step;
advance.physics_steps = max_physics_steps;
}
@@ -2474,33 +2474,32 @@ bool Main::iteration() {
PhysicsServer2D::get_singleton()->sync();
PhysicsServer2D::get_singleton()->flush_queries();
- if (OS::get_singleton()->get_main_loop()->iteration(frame_slice * time_scale)) {
+ if (OS::get_singleton()->get_main_loop()->physics_process(physics_step * time_scale)) {
exit = true;
break;
}
- NavigationServer3D::get_singleton_mut()->process(frame_slice * time_scale);
+ NavigationServer3D::get_singleton_mut()->process(physics_step * time_scale);
message_queue->flush();
- PhysicsServer3D::get_singleton()->step(frame_slice * time_scale);
+ PhysicsServer3D::get_singleton()->step(physics_step * time_scale);
PhysicsServer2D::get_singleton()->end_sync();
- PhysicsServer2D::get_singleton()->step(frame_slice * time_scale);
+ PhysicsServer2D::get_singleton()->step(physics_step * time_scale);
message_queue->flush();
- physics_process_ticks = MAX(physics_process_ticks, OS::get_singleton()->get_ticks_usec() -
- physics_begin); // keep the largest one for reference
+ physics_process_ticks = MAX(physics_process_ticks, OS::get_singleton()->get_ticks_usec() - physics_begin); // keep the largest one for reference
physics_process_max = MAX(OS::get_singleton()->get_ticks_usec() - physics_begin, physics_process_max);
Engine::get_singleton()->_physics_frames++;
}
Engine::get_singleton()->_in_physics = false;
- uint64_t idle_begin = OS::get_singleton()->get_ticks_usec();
+ uint64_t process_begin = OS::get_singleton()->get_ticks_usec();
- if (OS::get_singleton()->get_main_loop()->idle(step * time_scale)) {
+ if (OS::get_singleton()->get_main_loop()->process(process_step * time_scale)) {
exit = true;
}
message_queue->flush();
@@ -2521,8 +2520,8 @@ bool Main::iteration() {
}
}
- idle_process_ticks = OS::get_singleton()->get_ticks_usec() - idle_begin;
- idle_process_max = MAX(idle_process_ticks, idle_process_max);
+ process_ticks = OS::get_singleton()->get_ticks_usec() - process_begin;
+ process_max = MAX(process_ticks, process_max);
uint64_t frame_time = OS::get_singleton()->get_ticks_usec() - ticks;
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
@@ -2532,11 +2531,11 @@ bool Main::iteration() {
AudioServer::get_singleton()->update();
if (EngineDebugger::is_active()) {
- EngineDebugger::get_singleton()->iteration(frame_time, idle_process_ticks, physics_process_ticks, frame_slice);
+ EngineDebugger::get_singleton()->iteration(frame_time, process_ticks, physics_process_ticks, physics_step);
}
frames++;
- Engine::get_singleton()->_idle_frames++;
+ Engine::get_singleton()->_process_frames++;
if (frame > 1000000) {
if (editor || project_manager) {
@@ -2548,9 +2547,9 @@ bool Main::iteration() {
}
Engine::get_singleton()->_fps = frames;
- performance->set_process_time(USEC_TO_SEC(idle_process_max));
+ performance->set_process_time(USEC_TO_SEC(process_max));
performance->set_physics_process_time(USEC_TO_SEC(physics_process_max));
- idle_process_max = 0;
+ process_max = 0;
physics_process_max = 0;
frame %= 1000000;
@@ -2687,8 +2686,7 @@ void Main::cleanup() {
//attempt to restart with arguments
String exec = OS::get_singleton()->get_executable_path();
List<String> args = OS::get_singleton()->get_restart_on_exit_arguments();
- OS::ProcessID pid = 0;
- OS::get_singleton()->execute(exec, args, false, &pid);
+ OS::get_singleton()->create_process(exec, args);
OS::get_singleton()->set_restart_on_exit(false, List<String>()); //clear list (uses memory)
}
diff --git a/main/main.h b/main/main.h
index 168b2e5e86..9e606c188d 100644
--- a/main/main.h
+++ b/main/main.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp
index 5252ea005b..93448d0904 100644
--- a/main/main_timer_sync.cpp
+++ b/main/main_timer_sync.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -30,17 +30,17 @@
#include "main_timer_sync.h"
-void MainFrameTime::clamp_idle(float min_idle_step, float max_idle_step) {
- if (idle_step < min_idle_step) {
- idle_step = min_idle_step;
- } else if (idle_step > max_idle_step) {
- idle_step = max_idle_step;
+void MainFrameTime::clamp_process_step(float min_process_step, float max_process_step) {
+ if (process_step < min_process_step) {
+ process_step = min_process_step;
+ } else if (process_step > max_process_step) {
+ process_step = max_process_step;
}
}
/////////////////////////////////
-// returns the fraction of p_frame_slice required for the timer to overshoot
+// returns the fraction of p_physics_step required for the timer to overshoot
// before advance_core considers changing the physics_steps return from
// the typical values as defined by typical_physics_steps
float MainTimerSync::get_physics_jitter_fix() {
@@ -72,15 +72,15 @@ int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) {
return CONTROL_STEPS;
}
-// advance physics clock by p_idle_step, return appropriate number of steps to simulate
-MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_per_second, float p_idle_step) {
+// advance physics clock by p_process_step, return appropriate number of steps to simulate
+MainFrameTime MainTimerSync::advance_core(float p_physics_step, int p_physics_fps, float p_process_step) {
MainFrameTime ret;
- ret.idle_step = p_idle_step;
+ ret.process_step = p_process_step;
// simple determination of number of physics iteration
- time_accum += ret.idle_step;
- ret.physics_steps = floor(time_accum * p_iterations_per_second);
+ time_accum += ret.process_step;
+ ret.physics_steps = floor(time_accum * p_physics_fps);
int min_typical_steps = typical_physics_steps[0];
int max_typical_steps = min_typical_steps + 1;
@@ -107,7 +107,7 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
// try to keep it consistent with previous iterations
if (ret.physics_steps < min_typical_steps) {
- const int max_possible_steps = floor((time_accum)*p_iterations_per_second + get_physics_jitter_fix());
+ const int max_possible_steps = floor((time_accum)*p_physics_fps + get_physics_jitter_fix());
if (max_possible_steps < min_typical_steps) {
ret.physics_steps = max_possible_steps;
update_typical = true;
@@ -115,7 +115,7 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
ret.physics_steps = min_typical_steps;
}
} else if (ret.physics_steps > max_typical_steps) {
- const int min_possible_steps = floor((time_accum)*p_iterations_per_second - get_physics_jitter_fix());
+ const int min_possible_steps = floor((time_accum)*p_physics_fps - get_physics_jitter_fix());
if (min_possible_steps > max_typical_steps) {
ret.physics_steps = min_possible_steps;
update_typical = true;
@@ -124,7 +124,7 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
}
}
- time_accum -= ret.physics_steps * p_frame_slice;
+ time_accum -= ret.physics_steps * p_physics_step;
// keep track of accumulated step counts
for (int i = CONTROL_STEPS - 2; i >= 0; --i) {
@@ -146,52 +146,52 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
}
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
-MainFrameTime MainTimerSync::advance_checked(float p_frame_slice, int p_iterations_per_second, float p_idle_step) {
+MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics_fps, float p_process_step) {
if (fixed_fps != -1) {
- p_idle_step = 1.0 / fixed_fps;
+ p_process_step = 1.0 / fixed_fps;
}
// compensate for last deficit
- p_idle_step += time_deficit;
+ p_process_step += time_deficit;
- MainFrameTime ret = advance_core(p_frame_slice, p_iterations_per_second, p_idle_step);
+ MainFrameTime ret = advance_core(p_physics_step, p_physics_fps, p_process_step);
- // we will do some clamping on ret.idle_step and need to sync those changes to time_accum,
+ // we will do some clamping on ret.process_step and need to sync those changes to time_accum,
// that's easiest if we just remember their fixed difference now
- const double idle_minus_accum = ret.idle_step - time_accum;
+ const double process_minus_accum = ret.process_step - time_accum;
- // first, least important clamping: keep ret.idle_step consistent with typical_physics_steps.
- // this smoothes out the idle steps and culls small but quick variations.
+ // first, least important clamping: keep ret.process_step consistent with typical_physics_steps.
+ // this smoothes out the process steps and culls small but quick variations.
{
float min_average_physics_steps, max_average_physics_steps;
int consistent_steps = get_average_physics_steps(min_average_physics_steps, max_average_physics_steps);
if (consistent_steps > 3) {
- ret.clamp_idle(min_average_physics_steps * p_frame_slice, max_average_physics_steps * p_frame_slice);
+ ret.clamp_process_step(min_average_physics_steps * p_physics_step, max_average_physics_steps * p_physics_step);
}
}
// second clamping: keep abs(time_deficit) < jitter_fix * frame_slise
- float max_clock_deviation = get_physics_jitter_fix() * p_frame_slice;
- ret.clamp_idle(p_idle_step - max_clock_deviation, p_idle_step + max_clock_deviation);
+ float max_clock_deviation = get_physics_jitter_fix() * p_physics_step;
+ ret.clamp_process_step(p_process_step - max_clock_deviation, p_process_step + max_clock_deviation);
- // last clamping: make sure time_accum is between 0 and p_frame_slice for consistency between physics and idle
- ret.clamp_idle(idle_minus_accum, idle_minus_accum + p_frame_slice);
+ // last clamping: make sure time_accum is between 0 and p_physics_step for consistency between physics and process
+ ret.clamp_process_step(process_minus_accum, process_minus_accum + p_physics_step);
// restore time_accum
- time_accum = ret.idle_step - idle_minus_accum;
+ time_accum = ret.process_step - process_minus_accum;
// track deficit
- time_deficit = p_idle_step - ret.idle_step;
+ time_deficit = p_process_step - ret.process_step;
- // p_frame_slice is 1.0 / iterations_per_sec
+ // p_physics_step is 1.0 / iterations_per_sec
// i.e. the time in seconds taken by a physics tick
- ret.interpolation_fraction = time_accum / p_frame_slice;
+ ret.interpolation_fraction = time_accum / p_physics_step;
return ret;
}
// determine wall clock step since last iteration
-float MainTimerSync::get_cpu_idle_step() {
+float MainTimerSync::get_cpu_process_step() {
uint64_t cpu_ticks_elapsed = current_cpu_ticks_usec - last_cpu_ticks_usec;
last_cpu_ticks_usec = current_cpu_ticks_usec;
@@ -219,9 +219,9 @@ void MainTimerSync::set_fixed_fps(int p_fixed_fps) {
fixed_fps = p_fixed_fps;
}
-// advance one frame, return timesteps to take
-MainFrameTime MainTimerSync::advance(float p_frame_slice, int p_iterations_per_second) {
- float cpu_idle_step = get_cpu_idle_step();
+// advance one physics frame, return timesteps to take
+MainFrameTime MainTimerSync::advance(float p_physics_step, int p_physics_fps) {
+ float cpu_process_step = get_cpu_process_step();
- return advance_checked(p_frame_slice, p_iterations_per_second, cpu_idle_step);
+ return advance_checked(p_physics_step, p_physics_fps, cpu_process_step);
}
diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h
index f8497140cd..884978bf96 100644
--- a/main/main_timer_sync.h
+++ b/main/main_timer_sync.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,11 +34,11 @@
#include "core/config/engine.h"
struct MainFrameTime {
- float idle_step; // time to advance idles for (argument to process())
+ float process_step; // delta time to advance during process()
int physics_steps; // number of times to iterate the physics engine
float interpolation_fraction; // fraction through the current physics tick
- void clamp_idle(float min_idle_step, float max_idle_step);
+ void clamp_process_step(float min_process_step, float max_process_step);
};
class MainTimerSync {
@@ -49,7 +49,7 @@ class MainTimerSync {
// logical game time since last physics timestep
float time_accum = 0;
- // current difference between wall clock time and reported sum of idle_steps
+ // current difference between wall clock time and reported sum of process_steps
float time_deficit = 0;
// number of frames back for keeping accumulated physics steps roughly constant.
@@ -67,7 +67,7 @@ class MainTimerSync {
int fixed_fps = 0;
protected:
- // returns the fraction of p_frame_slice required for the timer to overshoot
+ // returns the fraction of p_physics_step required for the timer to overshoot
// before advance_core considers changing the physics_steps return from
// the typical values as defined by typical_physics_steps
float get_physics_jitter_fix();
@@ -76,14 +76,14 @@ protected:
// return value: number of frames back this data is consistent
int get_average_physics_steps(float &p_min, float &p_max);
- // advance physics clock by p_idle_step, return appropriate number of steps to simulate
- MainFrameTime advance_core(float p_frame_slice, int p_iterations_per_second, float p_idle_step);
+ // advance physics clock by p_process_step, return appropriate number of steps to simulate
+ MainFrameTime advance_core(float p_physics_step, int p_physics_fps, float p_process_step);
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
- MainFrameTime advance_checked(float p_frame_slice, int p_iterations_per_second, float p_idle_step);
+ MainFrameTime advance_checked(float p_physics_step, int p_physics_fps, float p_process_step);
// determine wall clock step since last iteration
- float get_cpu_idle_step();
+ float get_cpu_process_step();
public:
MainTimerSync();
@@ -96,7 +96,7 @@ public:
void set_fixed_fps(int p_fixed_fps);
// advance one frame, return timesteps to take
- MainFrameTime advance(float p_frame_slice, int p_iterations_per_second);
+ MainFrameTime advance(float p_physics_step, int p_physics_fps);
};
#endif // MAIN_TIMER_SYNC_H
diff --git a/main/performance.cpp b/main/performance.cpp
index 9de269ba5f..1a422dc499 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/main/performance.h b/main/performance.h
index 40f1d5cb05..122e5a4f9a 100644
--- a/main/performance.h
+++ b/main/performance.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */