Improve logging and benchmarking in Main
This commit is contained in:
parent
fc3f40f37d
commit
d7cca8162d
156
main/main.cpp
156
main/main.cpp
|
@ -766,6 +766,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
// Benchmark tracking must be done after `OS::get_singleton()->initialize()` as on some
|
||||
// platforms, it's used to set up the time utilities.
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Total");
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Setup");
|
||||
|
||||
engine = memnew(Engine);
|
||||
|
||||
|
@ -2185,6 +2186,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||
return setup2();
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Setup");
|
||||
return OK;
|
||||
|
||||
error:
|
||||
|
@ -2239,6 +2241,7 @@ error:
|
|||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Core");
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Setup");
|
||||
|
||||
OS::get_singleton()->finalize_core();
|
||||
locale = String();
|
||||
|
@ -2272,25 +2275,10 @@ Error Main::setup2() {
|
|||
// Print engine name and version
|
||||
print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE));
|
||||
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Servers");
|
||||
|
||||
tsman = memnew(TextServerManager);
|
||||
|
||||
if (tsman) {
|
||||
Ref<TextServerDummy> ts;
|
||||
ts.instantiate();
|
||||
tsman->add_interface(ts);
|
||||
}
|
||||
|
||||
physics_server_3d_manager = memnew(PhysicsServer3DManager);
|
||||
physics_server_2d_manager = memnew(PhysicsServer2DManager);
|
||||
|
||||
register_server_types();
|
||||
initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
|
||||
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (editor || project_manager || cmdline_tool) {
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Initialize Early Settings");
|
||||
|
||||
EditorPaths::create();
|
||||
|
||||
// Editor setting class is not available, load config directly.
|
||||
|
@ -2352,16 +2340,49 @@ Error Main::setup2() {
|
|||
return FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Initialize Early Settings");
|
||||
}
|
||||
#endif
|
||||
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Servers");
|
||||
|
||||
tsman = memnew(TextServerManager);
|
||||
if (tsman) {
|
||||
Ref<TextServerDummy> ts;
|
||||
ts.instantiate();
|
||||
tsman->add_interface(ts);
|
||||
}
|
||||
|
||||
physics_server_3d_manager = memnew(PhysicsServer3DManager);
|
||||
physics_server_2d_manager = memnew(PhysicsServer2DManager);
|
||||
|
||||
register_server_types();
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "Modules and Extensions");
|
||||
|
||||
initialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
|
||||
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS);
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "Modules and Extensions");
|
||||
}
|
||||
|
||||
/* Initialize Input */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "Input");
|
||||
|
||||
input = memnew(Input);
|
||||
OS::get_singleton()->initialize_joypads();
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "Input");
|
||||
}
|
||||
|
||||
/* Initialize Display Server */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "Display");
|
||||
|
||||
String display_driver = DisplayServer::get_create_function_name(display_driver_idx);
|
||||
|
||||
Vector2i *window_position = nullptr;
|
||||
|
@ -2395,12 +2416,14 @@ Error Main::setup2() {
|
|||
ERR_PRINT("Unable to create DisplayServer, all display drivers failed.");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
if (display_server->has_feature(DisplayServer::FEATURE_ORIENTATION)) {
|
||||
display_server->screen_set_orientation(window_orientation);
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "Display");
|
||||
}
|
||||
|
||||
if (GLOBAL_GET("debug/settings/stdout/print_fps") || print_fps) {
|
||||
// Print requested V-Sync mode at startup to diagnose the printed FPS not going above the monitor refresh rate.
|
||||
switch (window_vsync_mode) {
|
||||
|
@ -2426,9 +2449,10 @@ Error Main::setup2() {
|
|||
/* Initialize Pen Tablet Driver */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "Tablet Driver");
|
||||
|
||||
GLOBAL_DEF_RST_NOVAL("input_devices/pen_tablet/driver", "");
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "input_devices/pen_tablet/driver.windows", PROPERTY_HINT_ENUM, "wintab,winink"), "");
|
||||
}
|
||||
|
||||
if (tablet_driver.is_empty()) { // specified in project.godot
|
||||
tablet_driver = GLOBAL_GET("input_devices/pen_tablet/driver");
|
||||
|
@ -2450,8 +2474,14 @@ Error Main::setup2() {
|
|||
|
||||
print_verbose("Using \"" + tablet_driver + "\" pen tablet driver...");
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "Tablet Driver");
|
||||
}
|
||||
|
||||
/* Initialize Rendering Server */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "Rendering");
|
||||
|
||||
rendering_server = memnew(RenderingServerDefault(OS::get_singleton()->get_render_thread_mode() == OS::RENDER_SEPARATE_THREAD));
|
||||
|
||||
rendering_server->init();
|
||||
|
@ -2470,6 +2500,9 @@ Error Main::setup2() {
|
|||
}
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "Rendering");
|
||||
}
|
||||
|
||||
#ifdef UNIX_ENABLED
|
||||
// Print warning after initializing the renderer but before initializing audio.
|
||||
if (OS::get_singleton()->get_environment("USER") == "root" && !OS::get_singleton()->has_environment("GODOT_SILENCE_ROOT_WARNING")) {
|
||||
|
@ -2477,24 +2510,41 @@ Error Main::setup2() {
|
|||
}
|
||||
#endif
|
||||
|
||||
OS::get_singleton()->initialize_joypads();
|
||||
|
||||
/* Initialize Audio Driver */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "Audio");
|
||||
|
||||
AudioDriverManager::initialize(audio_driver_idx);
|
||||
|
||||
print_line(" "); //add a blank line for readability
|
||||
|
||||
// right moment to create and initialize the audio server
|
||||
print_line(" "); // Add a blank line for readability.
|
||||
|
||||
// Right moment to create and initialize the audio server.
|
||||
audio_server = memnew(AudioServer);
|
||||
audio_server->init();
|
||||
|
||||
// also init our xr_server from here
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "Audio");
|
||||
}
|
||||
|
||||
/* Initialize XR Server */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Servers", "XR");
|
||||
|
||||
xr_server = memnew(XRServer);
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Servers", "XR");
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Servers");
|
||||
|
||||
register_core_singletons();
|
||||
|
||||
/* Initialize the main window and boot screen */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Setup Window and Boot");
|
||||
|
||||
MAIN_PRINT("Main: Setup Logo");
|
||||
|
||||
#if !defined(TOOLS_ENABLED) && (defined(WEB_ENABLED) || defined(ANDROID_ENABLED))
|
||||
|
@ -2577,9 +2627,9 @@ Error Main::setup2() {
|
|||
#endif
|
||||
}
|
||||
|
||||
DisplayServer::set_early_window_clear_color_override(false);
|
||||
MAIN_PRINT("Main: Clear Color");
|
||||
|
||||
MAIN_PRINT("Main: DCC");
|
||||
DisplayServer::set_early_window_clear_color_override(false);
|
||||
RenderingServer::get_singleton()->set_default_clear_color(
|
||||
GLOBAL_GET("rendering/environment/defaults/default_clear_color"));
|
||||
|
||||
|
@ -2587,6 +2637,8 @@ Error Main::setup2() {
|
|||
GLOBAL_DEF(PropertyInfo(Variant::STRING, "application/config/macos_native_icon", PROPERTY_HINT_FILE, "*.icns"), String());
|
||||
GLOBAL_DEF(PropertyInfo(Variant::STRING, "application/config/windows_native_icon", PROPERTY_HINT_FILE, "*.ico"), String());
|
||||
|
||||
MAIN_PRINT("Main: Touch Input");
|
||||
|
||||
Input *id = Input::get_singleton();
|
||||
if (id) {
|
||||
agile_input_event_flushing = GLOBAL_DEF("input_devices/buffering/agile_event_flushing", false);
|
||||
|
@ -2605,8 +2657,16 @@ Error Main::setup2() {
|
|||
GLOBAL_DEF_BASIC("input_devices/pointing/android/enable_long_press_as_right_click", false);
|
||||
GLOBAL_DEF_BASIC("input_devices/pointing/android/enable_pan_and_scale_gestures", false);
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Setup Window and Boot");
|
||||
}
|
||||
|
||||
MAIN_PRINT("Main: Load Translations and Remaps");
|
||||
|
||||
/* Setup translations and remaps */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Translations and Remaps");
|
||||
|
||||
translation_server->setup(); //register translations, load them, etc.
|
||||
if (!locale.is_empty()) {
|
||||
translation_server->set_locale(locale);
|
||||
|
@ -2616,8 +2676,16 @@ Error Main::setup2() {
|
|||
|
||||
ResourceLoader::load_path_remaps();
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Translations and Remaps");
|
||||
}
|
||||
|
||||
MAIN_PRINT("Main: Load TextServer");
|
||||
|
||||
/* Setup Text Server */
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Text Server");
|
||||
|
||||
/* Enum text drivers */
|
||||
GLOBAL_DEF_RST("internationalization/rendering/text_driver", "");
|
||||
String text_driver_options;
|
||||
|
@ -2676,7 +2744,8 @@ Error Main::setup2() {
|
|||
ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface.");
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Servers");
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Text Server");
|
||||
}
|
||||
|
||||
MAIN_PRINT("Main: Load Scene Types");
|
||||
|
||||
|
@ -2691,23 +2760,42 @@ Error Main::setup2() {
|
|||
|
||||
register_scene_singletons();
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Scene", "Modules and Extensions");
|
||||
|
||||
initialize_modules(MODULE_INITIALIZATION_LEVEL_SCENE);
|
||||
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_SCENE);
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Scene", "Modules and Extensions");
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Scene");
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
ClassDB::set_current_api(ClassDB::API_EDITOR);
|
||||
register_editor_types();
|
||||
|
||||
{
|
||||
OS::get_singleton()->benchmark_begin_measure("Editor", "Modules and Extensions");
|
||||
|
||||
initialize_modules(MODULE_INITIALIZATION_LEVEL_EDITOR);
|
||||
GDExtensionManager::get_singleton()->initialize_extensions(GDExtension::INITIALIZATION_LEVEL_EDITOR);
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Editor", "Modules and Extensions");
|
||||
}
|
||||
|
||||
ClassDB::set_current_api(ClassDB::API_CORE);
|
||||
|
||||
#endif
|
||||
|
||||
MAIN_PRINT("Main: Load Modules");
|
||||
MAIN_PRINT("Main: Load Platforms");
|
||||
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Platforms");
|
||||
|
||||
register_platform_apis();
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Platforms");
|
||||
|
||||
GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/mouse_cursor/custom_image", PROPERTY_HINT_FILE, "*.png,*.webp"), String());
|
||||
GLOBAL_DEF_BASIC("display/mouse_cursor/custom_image_hotspot", Vector2());
|
||||
GLOBAL_DEF_BASIC("display/mouse_cursor/tooltip_position_offset", Point2(10, 10));
|
||||
|
@ -2721,12 +2809,18 @@ Error Main::setup2() {
|
|||
}
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_begin_measure("Startup", "Finalize Setup");
|
||||
|
||||
camera_server = CameraServer::create();
|
||||
|
||||
MAIN_PRINT("Main: Load Physics");
|
||||
|
||||
initialize_physics();
|
||||
|
||||
MAIN_PRINT("Main: Load Navigation");
|
||||
|
||||
initialize_navigation_server();
|
||||
|
||||
register_server_singletons();
|
||||
|
||||
// This loads global classes, so it must happen before custom loaders and savers are registered
|
||||
|
@ -2758,6 +2852,8 @@ Error Main::setup2() {
|
|||
rendering_server->global_shader_parameters_load_settings(!editor);
|
||||
}
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Finalize Setup");
|
||||
|
||||
_start_success = true;
|
||||
|
||||
ClassDB::set_current_api(ClassDB::API_NONE); //no more APIs are registered at this point
|
||||
|
@ -2766,7 +2862,7 @@ Error Main::setup2() {
|
|||
print_verbose("EDITOR API HASH: " + uitos(ClassDB::get_api_hash(ClassDB::API_EDITOR)));
|
||||
MAIN_PRINT("Main: Done");
|
||||
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Scene");
|
||||
OS::get_singleton()->benchmark_end_measure("Startup", "Setup");
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue