summaryrefslogtreecommitdiff
path: root/core/config/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/config/engine.cpp')
-rw-r--r--core/config/engine.cpp96
1 files changed, 90 insertions, 6 deletions
diff --git a/core/config/engine.cpp b/core/config/engine.cpp
index ff8a8d283f..cf9697be07 100644
--- a/core/config/engine.cpp
+++ b/core/config/engine.cpp
@@ -33,7 +33,10 @@
#include "core/authors.gen.h"
#include "core/config/project_settings.h"
#include "core/donors.gen.h"
+#include "core/io/json.h"
#include "core/license.gen.h"
+#include "core/os/os.h"
+#include "core/variant/typed_array.h"
#include "core/version.h"
void Engine::set_physics_ticks_per_second(int p_ips) {
@@ -134,8 +137,8 @@ Dictionary Engine::get_author_info() const {
return dict;
}
-Array Engine::get_copyright_info() const {
- Array components;
+TypedArray<Dictionary> Engine::get_copyright_info() const {
+ TypedArray<Dictionary> components;
for (int component_index = 0; component_index < COPYRIGHT_INFO_COUNT; component_index++) {
const ComponentCopyright &cp_info = COPYRIGHT_INFO[component_index];
Dictionary component_dict;
@@ -181,6 +184,42 @@ String Engine::get_license_text() const {
return String(GODOT_LICENSE_TEXT);
}
+String Engine::get_architecture_name() const {
+#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64)
+ return "x86_64";
+
+#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
+ return "x86_32";
+
+#elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
+ return "arm64";
+
+#elif defined(__arm__) || defined(_M_ARM)
+ return "arm32";
+
+#elif defined(__riscv)
+#if __riscv_xlen == 8
+ return "rv64";
+#else
+ return "riscv";
+#endif
+
+#elif defined(__powerpc__)
+#if defined(__powerpc64__)
+ return "ppc64";
+#else
+ return "ppc";
+#endif
+
+#elif defined(__wasm__)
+#if defined(__wasm64__)
+ return "wasm64";
+#elif defined(__wasm32__)
+ return "wasm32";
+#endif
+#endif
+}
+
bool Engine::is_abort_on_gpu_errors_enabled() const {
return abort_on_gpu_errors;
}
@@ -194,11 +233,11 @@ bool Engine::is_validation_layers_enabled() const {
}
void Engine::set_print_error_messages(bool p_enabled) {
- _print_error_enabled = p_enabled;
+ CoreGlobals::print_error_enabled = p_enabled;
}
bool Engine::is_printing_error_messages() const {
- return _print_error_enabled;
+ return CoreGlobals::print_error_enabled;
}
void Engine::add_singleton(const Singleton &p_singleton) {
@@ -208,9 +247,9 @@ void Engine::add_singleton(const Singleton &p_singleton) {
}
Object *Engine::get_singleton_object(const StringName &p_name) const {
- const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
+ HashMap<StringName, Object *>::ConstIterator E = singleton_ptrs.find(p_name);
ERR_FAIL_COND_V_MSG(!E, nullptr, "Failed to retrieve non-existent singleton '" + String(p_name) + "'.");
- return E->get();
+ return E->value;
}
bool Engine::is_singleton_user_created(const StringName &p_name) const {
@@ -246,6 +285,14 @@ void Engine::get_singletons(List<Singleton> *p_singletons) {
}
}
+String Engine::get_write_movie_path() const {
+ return write_movie_path;
+}
+
+void Engine::set_write_movie_path(const String &p_path) {
+ write_movie_path = p_path;
+}
+
void Engine::set_shader_cache_path(const String &p_path) {
shader_cache_path = p_path;
}
@@ -263,6 +310,43 @@ Engine::Engine() {
singleton = this;
}
+void Engine::startup_begin() {
+ startup_benchmark_total_from = OS::get_singleton()->get_ticks_usec();
+}
+
+void Engine::startup_benchmark_begin_measure(const String &p_what) {
+ startup_benchmark_section = p_what;
+ startup_benchmark_from = OS::get_singleton()->get_ticks_usec();
+}
+void Engine::startup_benchmark_end_measure() {
+ uint64_t total = OS::get_singleton()->get_ticks_usec() - startup_benchmark_from;
+ double total_f = double(total) / double(1000000);
+
+ startup_benchmark_json[startup_benchmark_section] = total_f;
+}
+
+void Engine::startup_dump(const String &p_to_file) {
+ uint64_t total = OS::get_singleton()->get_ticks_usec() - startup_benchmark_total_from;
+ double total_f = double(total) / double(1000000);
+ startup_benchmark_json["total_time"] = total_f;
+
+ if (!p_to_file.is_empty()) {
+ Ref<FileAccess> f = FileAccess::open(p_to_file, FileAccess::WRITE);
+ if (f.is_valid()) {
+ Ref<JSON> json;
+ json.instantiate();
+ f->store_string(json->stringify(startup_benchmark_json, "\t", false, true));
+ }
+ } else {
+ List<Variant> keys;
+ startup_benchmark_json.get_key_list(&keys);
+ print_line("STARTUP BENCHMARK:");
+ for (const Variant &K : keys) {
+ print_line("\t-", K, ": ", startup_benchmark_json[K], +" sec.");
+ }
+ }
+}
+
Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr, const StringName &p_class_name) :
name(p_name),
ptr(p_ptr),