diff options
224 files changed, 2149 insertions, 774 deletions
diff --git a/.clang-format b/.clang-format index eda00dd8dd..338ce6b7f3 100644 --- a/.clang-format +++ b/.clang-format @@ -183,7 +183,7 @@ PackConstructorInitializers: NextLine # ReflowComments: true # RemoveBracesLLVM: false # RemoveParentheses: Leave -# RemoveSemicolon: false +RemoveSemicolon: true # RequiresClausePosition: OwnLine # RequiresExpressionIndentation: OuterScope # SeparateDefinitionBlocks: Leave @@ -231,7 +231,7 @@ SpacesInLineCommentPrefix: # InEmptyParentheses: false # Other: false # SpacesInSquareBrackets: false -Standard: c++17 +Standard: c++20 # StatementAttributeLikeMacros: # - Q_EMIT # StatementMacros: diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 1c78dde7a4..df5fd1beed 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -57,3 +57,6 @@ df61dc4b2bd54a5a40c515493c76f5a458e5b541 # Style: Apply new `clang-format` fixes b37fc1014abf7adda70dc30b0822d775b3a4433f + +# Set clang-format `RemoveSemicolon` rule to `true` +0d350e71086fffce0553811739aae9f6ad66136c diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 7ff5502137..d516c37d16 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -24,19 +24,19 @@ jobs: cache-name: android-editor target: editor tests: false - sconsflags: arch=arm64 production=yes + sconsflags: arch=arm64 production=yes swappy=yes - name: Template arm32 (target=template_release, arch=arm32) cache-name: android-template-arm32 target: template_release tests: false - sconsflags: arch=arm32 + sconsflags: arch=arm32 swappy=yes - name: Template arm64 (target=template_release, arch=arm64) cache-name: android-template-arm64 target: template_release tests: false - sconsflags: arch=arm64 + sconsflags: arch=arm64 swappy=yes steps: - name: Checkout @@ -59,6 +59,17 @@ jobs: - name: Setup Python and SCons uses: ./.github/actions/godot-deps + - name: Download pre-built Android Swappy Frame Pacing Library + uses: dsaltares/fetch-gh-release-asset@1.1.2 + with: + repo: darksylinc/godot-swappy + version: tags/v2023.3.0.0 + file: godot-swappy.7z + target: swappy/godot-swappy.7z + + - name: Extract pre-built Android Swappy Frame Pacing Library + run: 7za x -y swappy/godot-swappy.7z -o${{github.workspace}}/thirdparty/swappy-frame-pacing + - name: Compilation uses: ./.github/actions/godot-build with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 572eaf6791..29263f07ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,17 @@ repos: rev: v19.1.0 hooks: - id: clang-format - files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java|glsl)$ + files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx|m|mm|inc|java)$ + types_or: [text] + exclude: | + (?x)^( + tests/python_build/.*| + platform/android/java/editor/src/main/java/com/android/.*| + platform/android/java/lib/src/com/.* + ) + - id: clang-format + name: clang-format-glsl + files: \.(glsl)$ types_or: [text] exclude: | (?x)^( @@ -20,6 +30,7 @@ repos: platform/android/java/editor/src/main/java/com/android/.*| platform/android/java/lib/src/com/.* ) + args: ["-style=file:misc/utility/.clang-format-glsl"] - repo: https://github.com/pocc/pre-commit-hooks rev: v1.3.5 diff --git a/SConstruct b/SConstruct index 785cc0b1a3..49278070ae 100644 --- a/SConstruct +++ b/SConstruct @@ -149,13 +149,11 @@ env.PrependENVPath("PKG_CONFIG_PATH", os.getenv("PKG_CONFIG_PATH")) if "TERM" in os.environ: # Used for colored output. env["ENV"]["TERM"] = os.environ["TERM"] -env.disabled_modules = [] +env.disabled_modules = set() env.module_version_string = "" env.msvc = False env.scons_version = env._get_major_minor_revision(scons_raw_version) -env.__class__.disable_module = methods.disable_module - env.__class__.add_module_version_string = methods.add_module_version_string env.__class__.add_source_files = methods.add_source_files @@ -229,6 +227,7 @@ opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loade opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True)) opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "") opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True)) +opts.Add(BoolVariable("swappy", "Use Swappy Frame Pacing Library in Android builds.", False)) # Advanced options opts.Add( @@ -611,6 +610,8 @@ if env["dev_mode"]: if env["production"]: env["use_static_cpp"] = methods.get_cmdline_bool("use_static_cpp", True) env["debug_symbols"] = methods.get_cmdline_bool("debug_symbols", False) + if platform_arg == "android": + env["swappy"] = methods.get_cmdline_bool("swappy", True) # LTO "auto" means we handle the preferred option in each platform detect.py. env["lto"] = ARGUMENTS.get("lto", "auto") diff --git a/core/config/engine.cpp b/core/config/engine.cpp index 9db2e6fbe9..12ada98d43 100644 --- a/core/config/engine.cpp +++ b/core/config/engine.cpp @@ -36,6 +36,7 @@ #include "core/license.gen.h" #include "core/variant/typed_array.h" #include "core/version.h" +#include "servers/rendering/rendering_device.h" void Engine::set_physics_ticks_per_second(int p_ips) { ERR_FAIL_COND_MSG(p_ips <= 0, "Engine iterations per second must be greater than 0."); @@ -68,6 +69,11 @@ double Engine::get_physics_jitter_fix() const { void Engine::set_max_fps(int p_fps) { _max_fps = p_fps > 0 ? p_fps : 0; + + RenderingDevice *rd = RenderingDevice::get_singleton(); + if (rd) { + rd->_set_max_fps(_max_fps); + } } int Engine::get_max_fps() const { diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index b389e5a58e..64af836d4d 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1503,6 +1503,10 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("display/window/subwindows/embed_subwindows", true); // Keep the enum values in sync with the `DisplayServer::VSyncMode` enum. custom_prop_info["display/window/vsync/vsync_mode"] = PropertyInfo(Variant::INT, "display/window/vsync/vsync_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Adaptive,Mailbox"); + + GLOBAL_DEF("display/window/frame_pacing/android/enable_frame_pacing", true); + GLOBAL_DEF(PropertyInfo(Variant::INT, "display/window/frame_pacing/android/swappy_mode", PROPERTY_HINT_ENUM, "pipeline_forced_on,auto_fps_pipeline_forced_on,auto_fps_auto_pipeline"), 2); + custom_prop_info["rendering/driver/threads/thread_model"] = PropertyInfo(Variant::INT, "rendering/driver/threads/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded"); GLOBAL_DEF("physics/2d/run_on_separate_thread", false); GLOBAL_DEF("physics/3d/run_on_separate_thread", false); diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 095c6c44dd..9349aafd1a 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -468,11 +468,11 @@ Error OS::set_thread_name(const String &p_name) { ::Thread::ID OS::get_thread_caller_id() const { return ::Thread::get_caller_id(); -}; +} ::Thread::ID OS::get_main_thread_id() const { return ::Thread::get_main_id(); -}; +} bool OS::has_feature(const String &p_feature) const { const bool *value_ptr = feature_cache.getptr(p_feature); diff --git a/core/debugger/engine_debugger.h b/core/debugger/engine_debugger.h index 16050778aa..3c4ac87408 100644 --- a/core/debugger/engine_debugger.h +++ b/core/debugger/engine_debugger.h @@ -106,7 +106,7 @@ public: _FORCE_INLINE_ static EngineDebugger *get_singleton() { return singleton; } _FORCE_INLINE_ static bool is_active() { return singleton != nullptr && script_debugger != nullptr; } - _FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; }; + _FORCE_INLINE_ static ScriptDebugger *get_script_debugger() { return script_debugger; } static void initialize(const String &p_uri, bool p_skip_breakpoints, const Vector<String> &p_breakpoints, void (*p_allow_focus_steal_fn)()); static void deinitialize(); diff --git a/core/io/dir_access.h b/core/io/dir_access.h index e9c864c56b..54e5ddf729 100644 --- a/core/io/dir_access.h +++ b/core/io/dir_access.h @@ -96,8 +96,8 @@ public: virtual bool file_exists(String p_file) = 0; virtual bool dir_exists(String p_dir) = 0; - virtual bool is_readable(String p_dir) { return true; }; - virtual bool is_writable(String p_dir) { return true; }; + virtual bool is_readable(String p_dir) { return true; } + virtual bool is_writable(String p_dir) { return true; } static bool exists(const String &p_dir); virtual uint64_t get_space_left() = 0; diff --git a/core/io/file_access.h b/core/io/file_access.h index 2f4d1a8604..7f5687fe03 100644 --- a/core/io/file_access.h +++ b/core/io/file_access.h @@ -215,8 +215,8 @@ public: static bool get_read_only_attribute(const String &p_file); static Error set_read_only_attribute(const String &p_file, bool p_ro); - static void set_backup_save(bool p_enable) { backup_save = p_enable; }; - static bool is_backup_save_enabled() { return backup_save; }; + static void set_backup_save(bool p_enable) { backup_save = p_enable; } + static bool is_backup_save_enabled() { return backup_save; } static String get_md5(const String &p_file); static String get_sha256(const String &p_file); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 38c71b19fa..aa71ad04d0 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -51,7 +51,7 @@ struct _IP_ResolverPrivate { response.clear(); type = IP::TYPE_NONE; hostname = ""; - }; + } QueueItem() { clear(); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index caaf9f8f45..0d802ed1f4 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -222,7 +222,7 @@ public: static ThreadLoadStatus load_threaded_get_status(const String &p_path, float *r_progress = nullptr); static Ref<Resource> load_threaded_get(const String &p_path, Error *r_error = nullptr); - static bool is_within_load() { return load_nesting > 0; }; + static bool is_within_load() { return load_nesting > 0; } static void resource_changed_connect(Resource *p_source, const Callable &p_callable, uint32_t p_flags); static void resource_changed_disconnect(Resource *p_source, const Callable &p_callable); diff --git a/core/math/basis.h b/core/math/basis.h index 236d666103..2d4994de19 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -223,7 +223,7 @@ struct [[nodiscard]] Basis { static Basis looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false); - Basis(const Quaternion &p_quaternion) { set_quaternion(p_quaternion); }; + Basis(const Quaternion &p_quaternion) { set_quaternion(p_quaternion); } Basis(const Quaternion &p_quaternion, const Vector3 &p_scale) { set_quaternion_scale(p_quaternion, p_scale); } Basis(const Vector3 &p_axis, real_t p_angle) { set_axis_angle(p_axis, p_angle); } diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index a49826958a..376d5d0b43 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -76,7 +76,7 @@ struct _AtlasWorkRect { Size2i s; Point2i p; int idx = 0; - _FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; }; + _FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; } }; struct _AtlasWorkRectResult { diff --git a/core/math/plane.h b/core/math/plane.h index 6529fea60a..65783ff4cf 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -40,7 +40,7 @@ struct [[nodiscard]] Plane { real_t d = 0; void set_normal(const Vector3 &p_normal); - _FORCE_INLINE_ Vector3 get_normal() const { return normal; }; + _FORCE_INLINE_ Vector3 get_normal() const { return normal; } void normalize(); Plane normalized() const; diff --git a/core/object/method_bind.h b/core/object/method_bind.h index 2f9a2d1679..e06eb1f8fa 100644 --- a/core/object/method_bind.h +++ b/core/object/method_bind.h @@ -109,7 +109,7 @@ public: _FORCE_INLINE_ StringName get_instance_class() const { return instance_class; } _FORCE_INLINE_ void set_instance_class(const StringName &p_class) { instance_class = p_class; } - _FORCE_INLINE_ int get_argument_count() const { return argument_count; }; + _FORCE_INLINE_ int get_argument_count() const { return argument_count; } #ifdef TOOLS_ENABLED virtual bool is_valid() const { return true; } diff --git a/core/object/object.h b/core/object/object.h index 110d2790c5..8f93b75bd8 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -685,22 +685,22 @@ protected: _ALWAYS_INLINE_ const ObjectGDExtension *_get_extension() const { return _extension; } _ALWAYS_INLINE_ GDExtensionClassInstancePtr _get_extension_instance() const { return _extension_instance; } virtual void _initialize_classv() { initialize_class(); } - virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; }; - virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; }; - virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {}; - virtual void _validate_propertyv(PropertyInfo &p_property) const {}; - virtual bool _property_can_revertv(const StringName &p_name) const { return false; }; - virtual bool _property_get_revertv(const StringName &p_name, Variant &r_property) const { return false; }; + virtual bool _setv(const StringName &p_name, const Variant &p_property) { return false; } + virtual bool _getv(const StringName &p_name, Variant &r_property) const { return false; } + virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const {} + virtual void _validate_propertyv(PropertyInfo &p_property) const {} + virtual bool _property_can_revertv(const StringName &p_name) const { return false; } + virtual bool _property_get_revertv(const StringName &p_name, Variant &r_property) const { return false; } virtual void _notificationv(int p_notification, bool p_reversed) {} static void _bind_methods(); static void _bind_compatibility_methods() {} - bool _set(const StringName &p_name, const Variant &p_property) { return false; }; - bool _get(const StringName &p_name, Variant &r_property) const { return false; }; - void _get_property_list(List<PropertyInfo> *p_list) const {}; - void _validate_property(PropertyInfo &p_property) const {}; - bool _property_can_revert(const StringName &p_name) const { return false; }; - bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; }; + bool _set(const StringName &p_name, const Variant &p_property) { return false; } + bool _get(const StringName &p_name, Variant &r_property) const { return false; } + void _get_property_list(List<PropertyInfo> *p_list) const {} + void _validate_property(PropertyInfo &p_property) const {} + bool _property_can_revert(const StringName &p_name) const { return false; } + bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; } void _notification(int p_notification) {} _FORCE_INLINE_ static void (*_get_bind_methods())() { diff --git a/core/object/script_language.h b/core/object/script_language.h index 3ddfbb3e7d..31d6638e58 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -446,8 +446,8 @@ public: virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const override; virtual void validate_property(PropertyInfo &p_property) const override {} - virtual bool property_can_revert(const StringName &p_name) const override { return false; }; - virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { return false; }; + virtual bool property_can_revert(const StringName &p_name) const override { return false; } + virtual bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { return false; } virtual void get_method_list(List<MethodInfo> *p_list) const override; virtual bool has_method(const StringName &p_method) const override; diff --git a/core/os/os.h b/core/os/os.h index c42a39e0a4..4bb177eb77 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -176,14 +176,14 @@ public: void set_delta_smoothing(bool p_enabled); bool is_delta_smoothing_enabled() const; - virtual Vector<String> get_system_fonts() const { return Vector<String>(); }; - virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return String(); }; - virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return Vector<String>(); }; + virtual Vector<String> get_system_fonts() const { return Vector<String>(); } + virtual String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return String(); } + virtual Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const { return Vector<String>(); } virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) = 0; virtual Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments, bool p_blocking = true) { return Dictionary(); } virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) = 0; - virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) { return create_process(get_executable_path(), p_arguments, r_child_id); }; + virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) { return create_process(get_executable_path(), p_arguments, r_child_id); } virtual Error kill(const ProcessID &p_pid) = 0; virtual int get_process_id() const; virtual bool is_process_running(const ProcessID &p_pid) const = 0; diff --git a/core/string/translation_domain.cpp b/core/string/translation_domain.cpp index 53b9ce8379..cf6689efff 100644 --- a/core/string/translation_domain.cpp +++ b/core/string/translation_domain.cpp @@ -123,7 +123,7 @@ String TranslationDomain::_double_vowels(const String &p_message) const { } } return res; -}; +} String TranslationDomain::_replace_with_accented_string(const String &p_message) const { String res; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 4e9eb922f6..28319fc643 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -33,6 +33,7 @@ #include "core/crypto/crypto_core.h" #include "core/math/color.h" #include "core/math/math_funcs.h" +#include "core/object/object.h" #include "core/os/memory.h" #include "core/string/print_string.h" #include "core/string/string_name.h" @@ -4064,8 +4065,18 @@ String String::format(const Variant &values, const String &placeholder) const { for (const Variant &key : keys) { new_string = new_string.replace(placeholder.replace("_", key), d[key]); } + } else if (values.get_type() == Variant::OBJECT) { + Object *obj = values.get_validated_object(); + ERR_FAIL_NULL_V(obj, new_string); + + List<PropertyInfo> props; + obj->get_property_list(&props); + + for (const PropertyInfo &E : props) { + new_string = new_string.replace(placeholder.replace("_", E.name), obj->get(E.name)); + } } else { - ERR_PRINT(String("Invalid type: use Array or Dictionary.").ascii().get_data()); + ERR_PRINT(String("Invalid type: use Array, Dictionary or Object.").ascii().get_data()); } return new_string; diff --git a/core/string/ustring.h b/core/string/ustring.h index aa62c9cb18..11c0f74062 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -118,7 +118,7 @@ public: Char16String &operator+=(char16_t p_char); int length() const { return size() ? size() - 1 : 0; } const char16_t *get_data() const; - operator const char16_t *() const { return get_data(); }; + operator const char16_t *() const { return get_data(); } protected: void copy_from(const char16_t *p_cstr); @@ -160,7 +160,7 @@ public: CharString &operator+=(char p_char); int length() const { return size() ? size() - 1 : 0; } const char *get_data() const; - operator const char *() const { return get_data(); }; + operator const char *() const { return get_data(); } protected: void copy_from(const char *p_cstr); diff --git a/core/templates/cowdata.h b/core/templates/cowdata.h index fedcfaec3b..5f260ee870 100644 --- a/core/templates/cowdata.h +++ b/core/templates/cowdata.h @@ -241,7 +241,7 @@ public: _FORCE_INLINE_ CowData() {} _FORCE_INLINE_ ~CowData(); - _FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); }; + _FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); } }; template <typename T> diff --git a/core/templates/lru.h b/core/templates/lru.h index 919c5605aa..3ae4cecef3 100644 --- a/core/templates/lru.h +++ b/core/templates/lru.h @@ -89,7 +89,7 @@ public: CRASH_COND(!e); _list.move_to_front(*e); return (*e)->get().data; - }; + } const TData *getptr(const TKey &p_key) { Element *e = _map.getptr(p_key); diff --git a/core/templates/rb_set.h b/core/templates/rb_set.h index ac7a8df36a..1b69f2f0c2 100644 --- a/core/templates/rb_set.h +++ b/core/templates/rb_set.h @@ -76,7 +76,7 @@ public: } const T &get() const { return value; - }; + } Element() {} }; diff --git a/core/typedefs.h b/core/typedefs.h index 35c4668581..85d62df96b 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -315,4 +315,6 @@ struct BuildIndexSequence<0, Is...> : IndexSequence<Is...> {}; #define ___gd_is_defined(val) ____gd_is_defined(__GDARG_PLACEHOLDER_##val) #define GD_IS_DEFINED(x) ___gd_is_defined(x) +#define FORCE_SEMICOLON ; + #endif // TYPEDEFS_H diff --git a/doc/classes/AudioServer.xml b/doc/classes/AudioServer.xml index 4a20736164..5def0e7baf 100644 --- a/doc/classes/AudioServer.xml +++ b/doc/classes/AudioServer.xml @@ -123,6 +123,12 @@ [b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings. </description> </method> + <method name="get_input_mix_rate" qualifiers="const"> + <return type="float" /> + <description> + Returns the sample rate at the input of the [AudioServer]. + </description> + </method> <method name="get_mix_rate" qualifiers="const"> <return type="float" /> <description> diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index 45e802519e..f6ff6da0c3 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -105,7 +105,7 @@ <param index="3" name="callback" type="Callable" /> <description> Shows a text input dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [String] parameter which contains the text field's contents. - [b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_INPUT] feature. Supported platforms include macOS and Windows. + [b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_INPUT] feature. Supported platforms include macOS, Windows, and Android. </description> </method> <method name="dialog_show"> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 4d41d2e94a..a4b5a0b867 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -818,6 +818,17 @@ <member name="display/window/energy_saving/keep_screen_on" type="bool" setter="" getter="" default="true"> If [code]true[/code], keeps the screen on (even in case of inactivity), so the screensaver does not take over. Works on desktop and mobile platforms. </member> + <member name="display/window/frame_pacing/android/enable_frame_pacing" type="bool" setter="" getter="" default="true"> + Enable Swappy for stable frame pacing on Android. Highly recommended. + [b]Note:[/b] This option will be forced off when using OpenXR. + </member> + <member name="display/window/frame_pacing/android/swappy_mode" type="int" setter="" getter="" default="2"> + Swappy mode to use. The options are: + - pipeline_forced_on: Try to honor [member Engine.max_fps]. Pipelining is always on. This is the same behavior as Desktop PC. + - auto_fps_pipeline_forced_on: Autocalculate max fps. Actual max_fps will be between 0 and [member Engine.max_fps]. While this sounds convenient, beware that Swappy will often downgrade max fps until it finds something that can be met and sustained. That means if your game runs between 40fps and 60fps on a 60hz screen, after some time Swappy will downgrade max fps so that the game renders at perfect 30fps. + - auto_fps_auto_pipeline: Same as auto_fps_pipeline_forced_on, but if Swappy detects that rendering is very fast (e.g. it takes < 8ms to render on a 60hz screen) Swappy will disable pipelining to minimize input latency. This is the default. + [b]Note:[/b] If [member Engine.max_fps] is 0, actual max_fps will considered as to be the screen's refresh rate (often 60hz, 90hz or 120hz depending on device model and OS settings). + </member> <member name="display/window/handheld/orientation" type="int" setter="" getter="" default="0"> The default screen orientation to use on mobile devices. See [enum DisplayServer.ScreenOrientation] for possible values. [b]Note:[/b] When set to a portrait orientation, this project setting does not flip the project resolution's width and height automatically. Instead, you have to set [member display/window/size/viewport_width] and [member display/window/size/viewport_height] accordingly. diff --git a/doc/classes/Shortcut.xml b/doc/classes/Shortcut.xml index b1e931aef8..c0ff3ebdb5 100644 --- a/doc/classes/Shortcut.xml +++ b/doc/classes/Shortcut.xml @@ -5,7 +5,7 @@ </brief_description> <description> Shortcuts are commonly used for interacting with a [Control] element from an [InputEvent] (also known as hotkeys). - One shortcut can contain multiple [InputEvent]'s, allowing the possibility of triggering one action with multiple different inputs. + One shortcut can contain multiple [InputEvent]s, allowing the possibility of triggering one action with multiple different inputs. </description> <tutorials> </tutorials> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 588d0c73f9..44795af473 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -248,7 +248,7 @@ <param index="1" name="placeholder" type="String" default=""{_}"" /> <description> Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values]. - [param values] can be a [Dictionary] or an [Array]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys. + [param values] can be a [Dictionary], an [Array] or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys. [codeblock] # Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it." var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it." @@ -263,6 +263,12 @@ print("User {} is {}.".format([42, "Godot"], "{}")) print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]])) [/codeblock] + When passing an [Object], the property names from [method Object.get_property_list] are used as keys. + [codeblock] + # Prints: Visible true, position (0, 0). + var node = Node2D.new() + print("Visible {visible}, position {position}".format(node)) + [/codeblock] See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial. [b]Note:[/b] The replacement of placeholders is not done all at once, instead each placeholder is replaced in the order they are passed, this means that if one of the replacement strings contains a key it will also be replaced. This can be very powerful, but can also cause unexpected results if you are not careful. If you do not need to perform replacement in the replacement strings, make sure your replacements do not contain placeholders to ensure reliable results. [codeblock] diff --git a/drivers/SCsub b/drivers/SCsub index e0bfa138f5..03ad70649b 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -14,7 +14,8 @@ SConscript("windows/SCsub") # Sounds drivers SConscript("alsa/SCsub") -SConscript("coreaudio/SCsub") +if env["platform"] == "ios" or env["platform"] == "macos": + SConscript("coreaudio/SCsub") SConscript("pulseaudio/SCsub") if env["platform"] == "windows": SConscript("wasapi/SCsub") diff --git a/drivers/coreaudio/SCsub b/drivers/coreaudio/SCsub index 69d667c57b..83ac27f4b6 100644 --- a/drivers/coreaudio/SCsub +++ b/drivers/coreaudio/SCsub @@ -4,4 +4,4 @@ from misc.utility.scons_hints import * Import("env") # Driver source files -env.add_source_files(env.drivers_sources, "*.cpp") +env.add_source_files(env.drivers_sources, "*.mm") diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h index 67ff3f3efc..54e02514ec 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.h +++ b/drivers/coreaudio/audio_driver_coreaudio.h @@ -38,6 +38,8 @@ #import <AudioUnit/AudioUnit.h> #ifdef MACOS_ENABLED #import <CoreAudio/AudioHardware.h> +#else +#import <AVFoundation/AVFoundation.h> #endif class AudioDriverCoreAudio : public AudioDriver { @@ -51,9 +53,11 @@ class AudioDriverCoreAudio : public AudioDriver { String input_device_name = "Default"; int mix_rate = 0; + int capture_mix_rate = 0; unsigned int channels = 2; unsigned int capture_channels = 2; unsigned int buffer_frames = 0; + unsigned int capture_buffer_frames = 0; Vector<int32_t> samples_in; Vector<int16_t> input_buf; @@ -89,11 +93,12 @@ class AudioDriverCoreAudio : public AudioDriver { public: virtual const char *get_name() const override { return "CoreAudio"; - }; + } virtual Error init() override; virtual void start() override; virtual int get_mix_rate() const override; + virtual int get_input_mix_rate() const override; virtual SpeakerMode get_speaker_mode() const override; virtual void lock() override; diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.mm index 433bbfb3f5..4e6ff2edb3 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.mm @@ -1,5 +1,5 @@ /**************************************************************************/ -/* audio_driver_coreaudio.cpp */ +/* audio_driver_coreaudio.mm */ /**************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -121,7 +121,24 @@ Error AudioDriverCoreAudio::init() { break; } - mix_rate = _get_configured_mix_rate(); +#ifdef MACOS_ENABLED + AudioDeviceID device_id; + UInt32 dev_id_size = sizeof(AudioDeviceID); + + AudioObjectPropertyAddress property_dev_id = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; + result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property_dev_id, 0, nullptr, &dev_id_size, &device_id); + ERR_FAIL_COND_V(result != noErr, FAILED); + + double hw_mix_rate; + UInt32 hw_mix_rate_size = sizeof(hw_mix_rate); + + AudioObjectPropertyAddress property_sr = { kAudioDevicePropertyNominalSampleRate, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain }; + result = AudioObjectGetPropertyData(device_id, &property_sr, 0, nullptr, &hw_mix_rate_size, &hw_mix_rate); + ERR_FAIL_COND_V(result != noErr, FAILED); +#else + double hw_mix_rate = [AVAudioSession sharedInstance].sampleRate; +#endif + mix_rate = hw_mix_rate; memset(&strdesc, 0, sizeof(strdesc)); strdesc.mFormatID = kAudioFormatLinearPCM; @@ -147,10 +164,10 @@ Error AudioDriverCoreAudio::init() { unsigned int buffer_size = buffer_frames * channels; samples_in.resize(buffer_size); - input_buf.resize(buffer_size); print_verbose("CoreAudio: detected " + itos(channels) + " channels"); - print_verbose("CoreAudio: audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms"); + print_verbose("CoreAudio: output sampling rate: " + itos(mix_rate) + " Hz"); + print_verbose("CoreAudio: output audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms"); AURenderCallbackStruct callback; memset(&callback, 0, sizeof(AURenderCallbackStruct)); @@ -275,6 +292,10 @@ int AudioDriverCoreAudio::get_mix_rate() const { return mix_rate; } +int AudioDriverCoreAudio::get_input_mix_rate() const { + return capture_mix_rate; +} + AudioDriver::SpeakerMode AudioDriverCoreAudio::get_speaker_mode() const { return get_speaker_mode_by_total_channels(channels); } @@ -378,14 +399,14 @@ Error AudioDriverCoreAudio::init_input_device() { UInt32 size; #ifdef MACOS_ENABLED - AudioDeviceID deviceId; + AudioDeviceID device_id; size = sizeof(AudioDeviceID); AudioObjectPropertyAddress property = { kAudioHardwarePropertyDefaultInputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain }; - result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId); + result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &device_id); ERR_FAIL_COND_V(result != noErr, FAILED); - result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID)); + result = AudioUnitSetProperty(input_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &device_id, sizeof(AudioDeviceID)); ERR_FAIL_COND_V(result != noErr, FAILED); #endif @@ -410,13 +431,23 @@ Error AudioDriverCoreAudio::init_input_device() { break; } - mix_rate = _get_configured_mix_rate(); +#ifdef MACOS_ENABLED + double hw_mix_rate; + UInt32 hw_mix_rate_size = sizeof(hw_mix_rate); + + AudioObjectPropertyAddress property_sr = { kAudioDevicePropertyNominalSampleRate, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain }; + result = AudioObjectGetPropertyData(device_id, &property_sr, 0, nullptr, &hw_mix_rate_size, &hw_mix_rate); + ERR_FAIL_COND_V(result != noErr, FAILED); +#else + double hw_mix_rate = [AVAudioSession sharedInstance].sampleRate; +#endif + capture_mix_rate = hw_mix_rate; memset(&strdesc, 0, sizeof(strdesc)); strdesc.mFormatID = kAudioFormatLinearPCM; strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; strdesc.mChannelsPerFrame = capture_channels; - strdesc.mSampleRate = mix_rate; + strdesc.mSampleRate = capture_mix_rate; strdesc.mFramesPerPacket = 1; strdesc.mBitsPerChannel = 16; strdesc.mBytesPerFrame = strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; @@ -425,6 +456,13 @@ Error AudioDriverCoreAudio::init_input_device() { result = AudioUnitSetProperty(input_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &strdesc, sizeof(strdesc)); ERR_FAIL_COND_V(result != noErr, FAILED); + int latency = Engine::get_singleton()->get_audio_output_latency(); + // Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels) + capture_buffer_frames = closest_power_of_2(latency * capture_mix_rate / 1000); + + unsigned int buffer_size = capture_buffer_frames * capture_channels; + input_buf.resize(buffer_size); + AURenderCallbackStruct callback; memset(&callback, 0, sizeof(AURenderCallbackStruct)); callback.inputProc = &AudioDriverCoreAudio::input_callback; @@ -435,6 +473,9 @@ Error AudioDriverCoreAudio::init_input_device() { result = AudioUnitInitialize(input_unit); ERR_FAIL_COND_V(result != noErr, FAILED); + print_verbose("CoreAudio: input sampling rate: " + itos(capture_mix_rate) + " Hz"); + print_verbose("CoreAudio: input audio buffer frames: " + itos(capture_buffer_frames) + " calculated latency: " + itos(capture_buffer_frames * 1000 / capture_mix_rate) + "ms"); + return OK; } @@ -477,7 +518,7 @@ void AudioDriverCoreAudio::finish_input_device() { } Error AudioDriverCoreAudio::input_start() { - input_buffer_init(buffer_frames); + input_buffer_init(capture_buffer_frames); OSStatus result = AudioOutputUnitStart(input_unit); if (result != noErr) { @@ -561,7 +602,7 @@ PackedStringArray AudioDriverCoreAudio::_get_device_list(bool input) { } void AudioDriverCoreAudio::_set_device(const String &output_device, bool input) { - AudioDeviceID deviceId; + AudioDeviceID device_id; bool found = false; if (output_device != "Default") { AudioObjectPropertyAddress prop; @@ -608,7 +649,7 @@ void AudioDriverCoreAudio::_set_device(const String &output_device, bool input) if (CFStringGetCString(cfname, buffer, maxSize, kCFStringEncodingUTF8)) { String name = String::utf8(buffer) + " (" + itos(audioDevices[i]) + ")"; if (name == output_device) { - deviceId = audioDevices[i]; + device_id = audioDevices[i]; found = true; } } @@ -626,14 +667,14 @@ void AudioDriverCoreAudio::_set_device(const String &output_device, bool input) UInt32 elem = input ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice; AudioObjectPropertyAddress property = { elem, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMain }; - OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &deviceId); + OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &property, 0, nullptr, &size, &device_id); ERR_FAIL_COND(result != noErr); found = true; } if (found) { - OSStatus result = AudioUnitSetProperty(input ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID)); + OSStatus result = AudioUnitSetProperty(input ? input_unit : audio_unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &device_id, sizeof(AudioDeviceID)); ERR_FAIL_COND(result != noErr); if (input) { diff --git a/drivers/d3d12/rendering_device_driver_d3d12.cpp b/drivers/d3d12/rendering_device_driver_d3d12.cpp index 7c546333c4..ab270e5e82 100644 --- a/drivers/d3d12/rendering_device_driver_d3d12.cpp +++ b/drivers/d3d12/rendering_device_driver_d3d12.cpp @@ -6583,7 +6583,7 @@ static Error create_command_signature(ID3D12Device *device, D3D12_INDIRECT_ARGUM HRESULT res = device->CreateCommandSignature(&cs_desc, nullptr, IID_PPV_ARGS(r_cmd_sig->GetAddressOf())); ERR_FAIL_COND_V_MSG(!SUCCEEDED(res), ERR_CANT_CREATE, "CreateCommandSignature failed with error " + vformat("0x%08ux", (uint64_t)res) + "."); return OK; -}; +} Error RenderingDeviceDriverD3D12::_initialize_frames(uint32_t p_frame_count) { Error err; diff --git a/drivers/gles3/storage/config.h b/drivers/gles3/storage/config.h index d60f295d66..06d88429be 100644 --- a/drivers/gles3/storage/config.h +++ b/drivers/gles3/storage/config.h @@ -110,7 +110,7 @@ public: PFNEGLIMAGETARGETTEXTURE2DOESPROC eglEGLImageTargetTexture2DOES = nullptr; #endif - static Config *get_singleton() { return singleton; }; + static Config *get_singleton() { return singleton; } Config(); ~Config(); diff --git a/drivers/gles3/storage/light_storage.h b/drivers/gles3/storage/light_storage.h index 5391e607c3..0695102640 100644 --- a/drivers/gles3/storage/light_storage.h +++ b/drivers/gles3/storage/light_storage.h @@ -306,8 +306,8 @@ public: /* Light API */ - Light *get_light(RID p_rid) { return light_owner.get_or_null(p_rid); }; - bool owns_light(RID p_rid) { return light_owner.owns(p_rid); }; + Light *get_light(RID p_rid) { return light_owner.get_or_null(p_rid); } + bool owns_light(RID p_rid) { return light_owner.owns(p_rid); } void _light_initialize(RID p_rid, RS::LightType p_type); @@ -434,8 +434,8 @@ public: /* LIGHT INSTANCE API */ - LightInstance *get_light_instance(RID p_rid) { return light_instance_owner.get_or_null(p_rid); }; - bool owns_light_instance(RID p_rid) { return light_instance_owner.owns(p_rid); }; + LightInstance *get_light_instance(RID p_rid) { return light_instance_owner.get_or_null(p_rid); } + bool owns_light_instance(RID p_rid) { return light_instance_owner.owns(p_rid); } virtual RID light_instance_create(RID p_light) override; virtual void light_instance_free(RID p_light_instance) override; @@ -633,8 +633,8 @@ public: /* PROBE API */ - ReflectionProbe *get_reflection_probe(RID p_rid) { return reflection_probe_owner.get_or_null(p_rid); }; - bool owns_reflection_probe(RID p_rid) { return reflection_probe_owner.owns(p_rid); }; + ReflectionProbe *get_reflection_probe(RID p_rid) { return reflection_probe_owner.get_or_null(p_rid); } + bool owns_reflection_probe(RID p_rid) { return reflection_probe_owner.owns(p_rid); } virtual RID reflection_probe_allocate() override; virtual void reflection_probe_initialize(RID p_rid) override; @@ -715,8 +715,8 @@ public: /* LIGHTMAP CAPTURE */ - Lightmap *get_lightmap(RID p_rid) { return lightmap_owner.get_or_null(p_rid); }; - bool owns_lightmap(RID p_rid) { return lightmap_owner.owns(p_rid); }; + Lightmap *get_lightmap(RID p_rid) { return lightmap_owner.get_or_null(p_rid); } + bool owns_lightmap(RID p_rid) { return lightmap_owner.owns(p_rid); } virtual RID lightmap_allocate() override; virtual void lightmap_initialize(RID p_rid) override; @@ -739,15 +739,15 @@ public: /* LIGHTMAP INSTANCE */ - LightmapInstance *get_lightmap_instance(RID p_rid) { return lightmap_instance_owner.get_or_null(p_rid); }; - bool owns_lightmap_instance(RID p_rid) { return lightmap_instance_owner.owns(p_rid); }; + LightmapInstance *get_lightmap_instance(RID p_rid) { return lightmap_instance_owner.get_or_null(p_rid); } + bool owns_lightmap_instance(RID p_rid) { return lightmap_instance_owner.owns(p_rid); } virtual RID lightmap_instance_create(RID p_lightmap) override; virtual void lightmap_instance_free(RID p_lightmap) override; virtual void lightmap_instance_set_transform(RID p_lightmap, const Transform3D &p_transform) override; /* SHADOW ATLAS API */ - bool owns_shadow_atlas(RID p_rid) { return shadow_atlas_owner.owns(p_rid); }; + bool owns_shadow_atlas(RID p_rid) { return shadow_atlas_owner.owns(p_rid); } virtual RID shadow_atlas_create() override; virtual void shadow_atlas_free(RID p_atlas) override; diff --git a/drivers/gles3/storage/material_storage.h b/drivers/gles3/storage/material_storage.h index 392ebcc570..6c21abc276 100644 --- a/drivers/gles3/storage/material_storage.h +++ b/drivers/gles3/storage/material_storage.h @@ -576,8 +576,8 @@ public: /* SHADER API */ - Shader *get_shader(RID p_rid) { return shader_owner.get_or_null(p_rid); }; - bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); }; + Shader *get_shader(RID p_rid) { return shader_owner.get_or_null(p_rid); } + bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); } void _shader_make_dirty(Shader *p_shader); @@ -598,8 +598,8 @@ public: /* MATERIAL API */ - Material *get_material(RID p_rid) { return material_owner.get_or_null(p_rid); }; - bool owns_material(RID p_rid) { return material_owner.owns(p_rid); }; + Material *get_material(RID p_rid) { return material_owner.get_or_null(p_rid); } + bool owns_material(RID p_rid) { return material_owner.owns(p_rid); } void _material_queue_update(Material *material, bool p_uniform, bool p_texture); void _update_queued_materials(); diff --git a/drivers/gles3/storage/mesh_storage.h b/drivers/gles3/storage/mesh_storage.h index 8615b89a30..0bb20bd369 100644 --- a/drivers/gles3/storage/mesh_storage.h +++ b/drivers/gles3/storage/mesh_storage.h @@ -280,8 +280,8 @@ public: /* MESH API */ - Mesh *get_mesh(RID p_rid) { return mesh_owner.get_or_null(p_rid); }; - bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); }; + Mesh *get_mesh(RID p_rid) { return mesh_owner.get_or_null(p_rid); } + bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); } virtual RID mesh_allocate() override; virtual void mesh_initialize(RID p_rid) override; @@ -443,8 +443,8 @@ public: /* MESH INSTANCE API */ - MeshInstance *get_mesh_instance(RID p_rid) { return mesh_instance_owner.get_or_null(p_rid); }; - bool owns_mesh_instance(RID p_rid) { return mesh_instance_owner.owns(p_rid); }; + MeshInstance *get_mesh_instance(RID p_rid) { return mesh_instance_owner.get_or_null(p_rid); } + bool owns_mesh_instance(RID p_rid) { return mesh_instance_owner.owns(p_rid); } virtual RID mesh_instance_create(RID p_base) override; virtual void mesh_instance_free(RID p_rid) override; @@ -492,8 +492,8 @@ public: /* MULTIMESH API */ - MultiMesh *get_multimesh(RID p_rid) { return multimesh_owner.get_or_null(p_rid); }; - bool owns_multimesh(RID p_rid) { return multimesh_owner.owns(p_rid); }; + MultiMesh *get_multimesh(RID p_rid) { return multimesh_owner.get_or_null(p_rid); } + bool owns_multimesh(RID p_rid) { return multimesh_owner.owns(p_rid); } virtual RID _multimesh_allocate() override; virtual void _multimesh_initialize(RID p_rid) override; @@ -571,8 +571,8 @@ public: /* SKELETON API */ - Skeleton *get_skeleton(RID p_rid) { return skeleton_owner.get_or_null(p_rid); }; - bool owns_skeleton(RID p_rid) { return skeleton_owner.owns(p_rid); }; + Skeleton *get_skeleton(RID p_rid) { return skeleton_owner.get_or_null(p_rid); } + bool owns_skeleton(RID p_rid) { return skeleton_owner.owns(p_rid); } virtual RID skeleton_allocate() override; virtual void skeleton_initialize(RID p_rid) override; diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp index 5f49a84fe8..14bbe635a4 100644 --- a/drivers/gles3/storage/texture_storage.cpp +++ b/drivers/gles3/storage/texture_storage.cpp @@ -2452,7 +2452,7 @@ Point2i TextureStorage::render_target_get_position(RID p_render_target) const { ERR_FAIL_NULL_V(rt, Point2i()); return rt->position; -}; +} void TextureStorage::render_target_set_size(RID p_render_target, int p_width, int p_height, uint32_t p_view_count) { RenderTarget *rt = render_target_owner.get_or_null(p_render_target); diff --git a/drivers/gles3/storage/texture_storage.h b/drivers/gles3/storage/texture_storage.h index d85d10e235..916662dcd6 100644 --- a/drivers/gles3/storage/texture_storage.h +++ b/drivers/gles3/storage/texture_storage.h @@ -478,8 +478,8 @@ public: /* Canvas Texture API */ - CanvasTexture *get_canvas_texture(RID p_rid) { return canvas_texture_owner.get_or_null(p_rid); }; - bool owns_canvas_texture(RID p_rid) { return canvas_texture_owner.owns(p_rid); }; + CanvasTexture *get_canvas_texture(RID p_rid) { return canvas_texture_owner.get_or_null(p_rid); } + bool owns_canvas_texture(RID p_rid) { return canvas_texture_owner.owns(p_rid); } virtual RID canvas_texture_allocate() override; virtual void canvas_texture_initialize(RID p_rid) override; @@ -499,8 +499,8 @@ public: return texture_owner.get_or_null(texture->proxy_to); } return texture; - }; - bool owns_texture(RID p_rid) { return texture_owner.owns(p_rid); }; + } + bool owns_texture(RID p_rid) { return texture_owner.owns(p_rid); } void texture_2d_initialize_from_texture(RID p_texture, Texture &p_tex) { texture_owner.initialize_rid(p_texture, p_tex); @@ -618,8 +618,8 @@ public: static GLuint system_fbo; - RenderTarget *get_render_target(RID p_rid) { return render_target_owner.get_or_null(p_rid); }; - bool owns_render_target(RID p_rid) { return render_target_owner.owns(p_rid); }; + RenderTarget *get_render_target(RID p_rid) { return render_target_owner.get_or_null(p_rid); } + bool owns_render_target(RID p_rid) { return render_target_owner.owns(p_rid); } void check_backbuffer(RenderTarget *rt, const bool uses_screen_texture, const bool uses_depth_texture); diff --git a/drivers/gles3/storage/utilities.h b/drivers/gles3/storage/utilities.h index 7c3b08717e..88ac802018 100644 --- a/drivers/gles3/storage/utilities.h +++ b/drivers/gles3/storage/utilities.h @@ -165,8 +165,8 @@ public: /* VISIBILITY NOTIFIER */ - VisibilityNotifier *get_visibility_notifier(RID p_rid) { return visibility_notifier_owner.get_or_null(p_rid); }; - bool owns_visibility_notifier(RID p_rid) const { return visibility_notifier_owner.owns(p_rid); }; + VisibilityNotifier *get_visibility_notifier(RID p_rid) { return visibility_notifier_owner.get_or_null(p_rid); } + bool owns_visibility_notifier(RID p_rid) const { return visibility_notifier_owner.owns(p_rid); } virtual RID visibility_notifier_allocate() override; virtual void visibility_notifier_initialize(RID p_notifier) override; diff --git a/drivers/metal/metal_objects.h b/drivers/metal/metal_objects.h index 38d5b53ffa..fd7d93bbbd 100644 --- a/drivers/metal/metal_objects.h +++ b/drivers/metal/metal_objects.h @@ -841,7 +841,7 @@ public: if (!enabled) return; [p_enc setStencilFrontReferenceValue:front_reference backReferenceValue:back_reference]; - }; + } } stencil; struct { @@ -855,7 +855,7 @@ public: //if (!enabled) // return; [p_enc setBlendColorRed:r green:g blue:b alpha:a]; - }; + } } blend; _FORCE_INLINE_ void apply(id<MTLRenderCommandEncoder> __unsafe_unretained p_enc) const { diff --git a/drivers/metal/rendering_device_driver_metal.h b/drivers/metal/rendering_device_driver_metal.h index 7c23624e43..f62a164ef9 100644 --- a/drivers/metal/rendering_device_driver_metal.h +++ b/drivers/metal/rendering_device_driver_metal.h @@ -410,7 +410,7 @@ public: virtual uint64_t api_trait_get(ApiTrait p_trait) override final; virtual bool has_feature(Features p_feature) override final; virtual const MultiviewCapabilities &get_multiview_capabilities() override final; - virtual String get_api_name() const override final { return "Metal"; }; + virtual String get_api_name() const override final { return "Metal"; } virtual String get_api_version() const override final; virtual String get_pipeline_cache_uuid() const override final; virtual const Capabilities &get_capabilities() const override final; diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h index 585e882059..6456467cb9 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.h +++ b/drivers/pulseaudio/audio_driver_pulseaudio.h @@ -100,7 +100,7 @@ class AudioDriverPulseAudio : public AudioDriver { public: virtual const char *get_name() const override { return "PulseAudio"; - }; + } virtual Error init() override; virtual void start() override; diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 0d908f4ace..f9f1168a97 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -35,6 +35,16 @@ #include "thirdparty/misc/smolv.h" #include "vulkan_hooks.h" +#if defined(ANDROID_ENABLED) +#include "platform/android/java_godot_wrapper.h" +#include "platform/android/os_android.h" +#include "platform/android/thread_jandroid.h" +#endif + +#if defined(SWAPPY_FRAME_PACING_ENABLED) +#include "thirdparty/swappy-frame-pacing/swappyVk.h" +#endif + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define PRINT_NATIVE_COMMANDS 0 @@ -538,6 +548,37 @@ Error RenderingDeviceDriverVulkan::_initialize_device_extensions() { err = vkEnumerateDeviceExtensionProperties(physical_device, nullptr, &device_extension_count, device_extensions.ptr()); ERR_FAIL_COND_V(err != VK_SUCCESS, ERR_CANT_CREATE); +#if defined(SWAPPY_FRAME_PACING_ENABLED) + if (swappy_frame_pacer_enable) { + char **swappy_required_extensions; + uint32_t swappy_required_extensions_count = 0; + // Determine number of extensions required by Swappy frame pacer. + SwappyVk_determineDeviceExtensions(physical_device, device_extension_count, device_extensions.ptr(), &swappy_required_extensions_count, nullptr); + + if (swappy_required_extensions_count < device_extension_count) { + // Determine the actual extensions. + swappy_required_extensions = (char **)malloc(swappy_required_extensions_count * sizeof(char *)); + char *pRequiredExtensionsData = (char *)malloc(swappy_required_extensions_count * (VK_MAX_EXTENSION_NAME_SIZE + 1)); + for (uint32_t i = 0; i < swappy_required_extensions_count; i++) { + swappy_required_extensions[i] = &pRequiredExtensionsData[i * (VK_MAX_EXTENSION_NAME_SIZE + 1)]; + } + SwappyVk_determineDeviceExtensions(physical_device, device_extension_count, + device_extensions.ptr(), &swappy_required_extensions_count, swappy_required_extensions); + + // Enable extensions requested by Swappy. + for (uint32_t i = 0; i < swappy_required_extensions_count; i++) { + CharString extension_name(swappy_required_extensions[i]); + if (requested_device_extensions.has(extension_name)) { + enabled_device_extension_names.insert(extension_name); + } + } + + free(pRequiredExtensionsData); + free(swappy_required_extensions); + } + } +#endif + #ifdef DEV_ENABLED for (uint32_t i = 0; i < device_extension_count; i++) { print_verbose(String("VULKAN: Found device extension ") + String::utf8(device_extensions[i].extensionName)); @@ -1379,6 +1420,18 @@ Error RenderingDeviceDriverVulkan::initialize(uint32_t p_device_index, uint32_t breadcrumb_buffer = buffer_create(2u * sizeof(uint32_t) * BREADCRUMB_BUFFER_ENTRIES, BufferUsageBits::BUFFER_USAGE_TRANSFER_TO_BIT, MemoryAllocationType::MEMORY_ALLOCATION_TYPE_CPU); #endif +#if defined(SWAPPY_FRAME_PACING_ENABLED) + swappy_frame_pacer_enable = GLOBAL_GET("display/window/frame_pacing/android/enable_frame_pacing"); + swappy_mode = GLOBAL_GET("display/window/frame_pacing/android/swappy_mode"); + + if (VulkanHooks::get_singleton() != nullptr) { + // Hooks control device creation & possibly presentation + // (e.g. OpenXR) thus it's too risky to use Swappy. + swappy_frame_pacer_enable = false; + OS::get_singleton()->print("VulkanHooks detected (e.g. OpenXR): Force-disabling Swappy Frame Pacing.\n"); + } +#endif + return OK; } @@ -2364,6 +2417,14 @@ RDD::CommandQueueID RenderingDeviceDriverVulkan::command_queue_create(CommandQue ERR_FAIL_COND_V_MSG(picked_queue_index >= queue_family.size(), CommandQueueID(), "A queue in the picked family could not be found."); +#if defined(SWAPPY_FRAME_PACING_ENABLED) + if (swappy_frame_pacer_enable) { + VkQueue selected_queue; + vkGetDeviceQueue(vk_device, family_index, picked_queue_index, &selected_queue); + SwappyVk_setQueueFamilyIndex(vk_device, selected_queue, family_index); + } +#endif + // Create the virtual queue. CommandQueue *command_queue = memnew(CommandQueue); command_queue->queue_family = family_index; @@ -2509,7 +2570,16 @@ Error RenderingDeviceDriverVulkan::command_queue_execute_and_present(CommandQueu present_info.pResults = results.ptr(); device_queue.submit_mutex.lock(); +#if defined(SWAPPY_FRAME_PACING_ENABLED) + if (swappy_frame_pacer_enable) { + err = SwappyVk_queuePresent(device_queue.queue, &present_info); + } else { + err = device_functions.QueuePresentKHR(device_queue.queue, &present_info); + } +#else err = device_functions.QueuePresentKHR(device_queue.queue, &present_info); +#endif + device_queue.submit_mutex.unlock(); // Set the index to an invalid value. If any of the swap chains returned out of date, indicate it should be resized the next time it's acquired. @@ -2691,6 +2761,14 @@ void RenderingDeviceDriverVulkan::_swap_chain_release(SwapChain *swap_chain) { swap_chain->framebuffers.clear(); if (swap_chain->vk_swapchain != VK_NULL_HANDLE) { +#if defined(SWAPPY_FRAME_PACING_ENABLED) + if (swappy_frame_pacer_enable) { + // Swappy has a bug where the ANativeWindow will be leaked if we call + // SwappyVk_destroySwapchain, so we must release it by hand. + SwappyVk_setWindow(vk_device, swap_chain->vk_swapchain, nullptr); + SwappyVk_destroySwapchain(vk_device, swap_chain->vk_swapchain); + } +#endif device_functions.DestroySwapchainKHR(vk_device, swap_chain->vk_swapchain, VKC::get_allocation_callbacks(VK_OBJECT_TYPE_SWAPCHAIN_KHR)); swap_chain->vk_swapchain = VK_NULL_HANDLE; } @@ -2807,6 +2885,20 @@ Error RenderingDeviceDriverVulkan::swap_chain_resize(CommandQueueID p_cmd_queue, VkResult err = functions.GetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, surface->vk_surface, &surface_capabilities); ERR_FAIL_COND_V(err != VK_SUCCESS, ERR_CANT_CREATE); + // No swapchain yet, this is the first time we're creating it. + if (!swap_chain->vk_swapchain) { + uint32_t width = surface_capabilities.currentExtent.width; + uint32_t height = surface_capabilities.currentExtent.height; + if (surface_capabilities.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR || + surface_capabilities.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR) { + // Swap to get identity width and height. + surface_capabilities.currentExtent.height = width; + surface_capabilities.currentExtent.width = height; + } + + native_display_size = surface_capabilities.currentExtent; + } + VkExtent2D extent; if (surface_capabilities.currentExtent.width == 0xFFFFFFFF) { // The current extent is currently undefined, so the current surface width and height will be clamped to the surface's capabilities. @@ -2871,15 +2963,8 @@ Error RenderingDeviceDriverVulkan::swap_chain_resize(CommandQueueID p_cmd_queue, desired_swapchain_images = MIN(desired_swapchain_images, surface_capabilities.maxImageCount); } - // Prefer identity transform if it's supported, use the current transform otherwise. - // This behavior is intended as Godot does not supported native rotation in platforms that use these bits. // Refer to the comment in command_queue_present() for more details. - VkSurfaceTransformFlagBitsKHR surface_transform_bits; - if (surface_capabilities.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) { - surface_transform_bits = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; - } else { - surface_transform_bits = surface_capabilities.currentTransform; - } + VkSurfaceTransformFlagBitsKHR surface_transform_bits = surface_capabilities.currentTransform; VkCompositeAlphaFlagBitsKHR composite_alpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; if (OS::get_singleton()->is_layered_allowed() || !(surface_capabilities.supportedCompositeAlpha & composite_alpha)) { @@ -2906,7 +2991,7 @@ Error RenderingDeviceDriverVulkan::swap_chain_resize(CommandQueueID p_cmd_queue, swap_create_info.minImageCount = desired_swapchain_images; swap_create_info.imageFormat = swap_chain->format; swap_create_info.imageColorSpace = swap_chain->color_space; - swap_create_info.imageExtent = extent; + swap_create_info.imageExtent = native_display_size; swap_create_info.imageArrayLayers = 1; swap_create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; swap_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; @@ -2917,6 +3002,39 @@ Error RenderingDeviceDriverVulkan::swap_chain_resize(CommandQueueID p_cmd_queue, err = device_functions.CreateSwapchainKHR(vk_device, &swap_create_info, VKC::get_allocation_callbacks(VK_OBJECT_TYPE_SWAPCHAIN_KHR), &swap_chain->vk_swapchain); ERR_FAIL_COND_V(err != VK_SUCCESS, ERR_CANT_CREATE); +#if defined(SWAPPY_FRAME_PACING_ENABLED) + if (swappy_frame_pacer_enable) { + const double max_fps = Engine::get_singleton()->get_max_fps(); + const uint64_t max_time = max_fps > 0 ? uint64_t((1000.0 * 1000.0 * 1000.0) / max_fps) : 0; + + SwappyVk_initAndGetRefreshCycleDuration(get_jni_env(), static_cast<OS_Android *>(OS::get_singleton())->get_godot_java()->get_activity(), physical_device, + vk_device, swap_chain->vk_swapchain, &swap_chain->refresh_duration); + SwappyVk_setWindow(vk_device, swap_chain->vk_swapchain, static_cast<OS_Android *>(OS::get_singleton())->get_native_window()); + SwappyVk_setSwapIntervalNS(vk_device, swap_chain->vk_swapchain, MAX(swap_chain->refresh_duration, max_time)); + + enum SwappyModes { + PIPELINE_FORCED_ON, + AUTO_FPS_PIPELINE_FORCED_ON, + AUTO_FPS_AUTO_PIPELINE, + }; + + switch (swappy_mode) { + case PIPELINE_FORCED_ON: + SwappyVk_setAutoSwapInterval(true); + SwappyVk_setAutoPipelineMode(true); + break; + case AUTO_FPS_PIPELINE_FORCED_ON: + SwappyVk_setAutoSwapInterval(true); + SwappyVk_setAutoPipelineMode(false); + break; + case AUTO_FPS_AUTO_PIPELINE: + SwappyVk_setAutoSwapInterval(false); + SwappyVk_setAutoPipelineMode(false); + break; + } + } +#endif + uint32_t image_count = 0; err = device_functions.GetSwapchainImagesKHR(vk_device, swap_chain->vk_swapchain, &image_count, nullptr); ERR_FAIL_COND_V(err != VK_SUCCESS, ERR_CANT_CREATE); @@ -3064,6 +3182,22 @@ RDD::DataFormat RenderingDeviceDriverVulkan::swap_chain_get_format(SwapChainID p } } +void RenderingDeviceDriverVulkan::swap_chain_set_max_fps(SwapChainID p_swap_chain, int p_max_fps) { + DEV_ASSERT(p_swap_chain.id != 0); + +#ifdef SWAPPY_FRAME_PACING_ENABLED + if (!swappy_frame_pacer_enable) { + return; + } + + SwapChain *swap_chain = (SwapChain *)(p_swap_chain.id); + if (swap_chain->vk_swapchain != VK_NULL_HANDLE) { + const uint64_t max_time = p_max_fps > 0 ? uint64_t((1000.0 * 1000.0 * 1000.0) / p_max_fps) : 0; + SwappyVk_setSwapIntervalNS(vk_device, swap_chain->vk_swapchain, MAX(swap_chain->refresh_duration, max_time)); + } +#endif +} + void RenderingDeviceDriverVulkan::swap_chain_free(SwapChainID p_swap_chain) { DEV_ASSERT(p_swap_chain.id != 0); diff --git a/drivers/vulkan/rendering_device_driver_vulkan.h b/drivers/vulkan/rendering_device_driver_vulkan.h index a7ec22e37b..33cce30b34 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.h +++ b/drivers/vulkan/rendering_device_driver_vulkan.h @@ -143,6 +143,11 @@ class RenderingDeviceDriverVulkan : public RenderingDeviceDriver { #if defined(VK_TRACK_DEVICE_MEMORY) bool device_memory_report_support = false; #endif +#if defined(SWAPPY_FRAME_PACING_ENABLED) + // Swappy frame pacer for Android. + bool swappy_frame_pacer_enable = false; + uint8_t swappy_mode = 2; // See default value for display/window/frame_pacing/android/swappy_mode. +#endif DeviceFunctions device_functions; void _register_requested_device_extension(const CharString &p_extension_name, bool p_required); @@ -355,9 +360,13 @@ private: LocalVector<uint32_t> command_queues_acquired_semaphores; RenderPassID render_pass; uint32_t image_index = 0; +#ifdef ANDROID_ENABLED + uint64_t refresh_duration = 0; +#endif }; void _swap_chain_release(SwapChain *p_swap_chain); + VkExtent2D native_display_size; public: virtual SwapChainID swap_chain_create(RenderingContextDriver::SurfaceID p_surface) override final; @@ -365,6 +374,7 @@ public: virtual FramebufferID swap_chain_acquire_framebuffer(CommandQueueID p_cmd_queue, SwapChainID p_swap_chain, bool &r_resize_required) override final; virtual RenderPassID swap_chain_get_render_pass(SwapChainID p_swap_chain) override final; virtual DataFormat swap_chain_get_format(SwapChainID p_swap_chain) override final; + virtual void swap_chain_set_max_fps(SwapChainID p_swap_chain, int p_max_fps) override final; virtual void swap_chain_free(SwapChainID p_swap_chain) override final; /*********************/ diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp index 4e7c9695a5..b800e5f1f4 100644 --- a/drivers/wasapi/audio_driver_wasapi.cpp +++ b/drivers/wasapi/audio_driver_wasapi.cpp @@ -85,7 +85,7 @@ public: _In_ const WAVEFORMATEX *pFormat, /* [annotation][in] */ _In_opt_ LPCGUID AudioSessionGuid) = 0; -}; +} __CRT_UUID_DECL(IAudioClient3, 0x7ED4EE07, 0x8E67, 0x4CD4, 0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42) #endif // __IAudioClient3_INTERFACE_DEFINED__ diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 0da474afd4..1053468452 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -716,7 +716,7 @@ class AnimationTrackEditor : public VBoxContainer { struct SelectedKey { int track = 0; int key = 0; - bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; }; + bool operator<(const SelectedKey &p_key) const { return track == p_key.track ? key < p_key.key : track < p_key.track; } }; struct KeyInfo { diff --git a/editor/debugger/editor_debugger_inspector.h b/editor/debugger/editor_debugger_inspector.h index fac9525943..860c2bf582 100644 --- a/editor/debugger/editor_debugger_inspector.h +++ b/editor/debugger/editor_debugger_inspector.h @@ -48,7 +48,7 @@ public: List<PropertyInfo> prop_list; HashMap<StringName, Variant> prop_values; - ObjectID get_remote_object_id() { return remote_object_id; }; + ObjectID get_remote_object_id() { return remote_object_id; } String get_title(); Variant get_variant(const StringName &p_name); diff --git a/editor/editor_node.h b/editor/editor_node.h index 696caf857c..39a4c7df65 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -932,7 +932,7 @@ public: void dim_editor(bool p_dimming); bool is_editor_dimmed() const; - void edit_current() { _edit_current(); }; + void edit_current() { _edit_current(); } bool has_scenes_in_session(); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 158ea4b8a7..ccb6e21c3e 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2638,7 +2638,7 @@ EditorPropertyColor::EditorPropertyColor() { void EditorPropertyNodePath::_set_read_only(bool p_read_only) { assign->set_disabled(p_read_only); menu->set_disabled(p_read_only); -}; +} Variant EditorPropertyNodePath::_get_cache_value(const StringName &p_prop, bool &r_valid) const { if (p_prop == get_edited_property()) { diff --git a/editor/export/codesign.h b/editor/export/codesign.h index 9a858c49ac..92366da0f6 100644 --- a/editor/export/codesign.h +++ b/editor/export/codesign.h @@ -166,7 +166,7 @@ public: virtual int get_size() const override; - virtual uint32_t get_index_type() const override { return 0x00000002; }; + virtual uint32_t get_index_type() const override { return 0x00000002; } virtual void write_to_file(Ref<FileAccess> p_file) const override; }; @@ -188,7 +188,7 @@ public: virtual int get_size() const override; - virtual uint32_t get_index_type() const override { return 0x00000005; }; + virtual uint32_t get_index_type() const override { return 0x00000005; } virtual void write_to_file(Ref<FileAccess> p_file) const override; }; @@ -210,7 +210,7 @@ public: virtual int get_size() const override; - virtual uint32_t get_index_type() const override { return 0x00000007; }; + virtual uint32_t get_index_type() const override { return 0x00000007; } virtual void write_to_file(Ref<FileAccess> p_file) const override; }; @@ -311,7 +311,7 @@ public: virtual PackedByteArray get_hash_sha256() const override; virtual int get_size() const override; - virtual uint32_t get_index_type() const override { return 0x00000000; }; + virtual uint32_t get_index_type() const override { return 0x00000000; } virtual void write_to_file(Ref<FileAccess> p_file) const override; }; @@ -330,7 +330,7 @@ public: virtual PackedByteArray get_hash_sha256() const override; virtual int get_size() const override; - virtual uint32_t get_index_type() const override { return 0x00010000; }; + virtual uint32_t get_index_type() const override { return 0x00010000; } virtual void write_to_file(Ref<FileAccess> p_file) const override; }; diff --git a/editor/export/project_export.h b/editor/export/project_export.h index e360596be6..bbf0d81228 100644 --- a/editor/export/project_export.h +++ b/editor/export/project_export.h @@ -216,7 +216,7 @@ public: Ref<EditorExportPreset> get_current_preset() const; - bool is_exporting() const { return exporting; }; + bool is_exporting() const { return exporting; } ProjectExportDialog(); ~ProjectExportDialog(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 2df0b2edaa..7edd514c48 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -2716,7 +2716,7 @@ void FileSystemDock::focus_on_filter() { } void FileSystemDock::create_directory(const String &p_path, const String &p_base_dir) { - Error err = EditorFileSystem::get_singleton()->make_dir_recursive(p_path, p_base_dir); + Error err = EditorFileSystem::get_singleton()->make_dir_recursive(p_path.trim_prefix(p_base_dir), p_base_dir); if (err != OK) { EditorNode::get_singleton()->show_warning(vformat(TTR("Could not create folder: %s"), error_names[err])); } diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 819abbd389..f48676d24d 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -402,7 +402,7 @@ public: FileSortOption get_file_sort() const { return file_sort; } void set_file_list_display_mode(FileListDisplayMode p_mode); - FileListDisplayMode get_file_list_display_mode() const { return file_list_display_mode; }; + FileListDisplayMode get_file_list_display_mode() const { return file_list_display_mode; } Tree *get_tree_control() { return tree; } diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index 7600748685..1735e325fc 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -350,7 +350,7 @@ void EditorFileDialog::shortcut_input(const Ref<InputEvent> &p_event) { void EditorFileDialog::set_enable_multiple_selection(bool p_enable) { item_list->set_select_mode(p_enable ? ItemList::SELECT_MULTI : ItemList::SELECT_SINGLE); -}; +} Vector<String> EditorFileDialog::get_selected_files() const { Vector<String> list; @@ -360,7 +360,7 @@ Vector<String> EditorFileDialog::get_selected_files() const { } } return list; -}; +} void EditorFileDialog::update_dir() { if (drives->is_visible()) { diff --git a/editor/gui/editor_toaster.cpp b/editor/gui/editor_toaster.cpp index 24f19db578..a38ed7f4c1 100644 --- a/editor/gui/editor_toaster.cpp +++ b/editor/gui/editor_toaster.cpp @@ -566,7 +566,7 @@ EditorToaster::EditorToaster() { eh.errfunc = _error_handler; add_error_handler(&eh); -}; +} EditorToaster::~EditorToaster() { singleton = nullptr; diff --git a/editor/import/3d/collada.h b/editor/import/3d/collada.h index 416b917a46..f9c26e090c 100644 --- a/editor/import/3d/collada.h +++ b/editor/import/3d/collada.h @@ -359,7 +359,7 @@ public: for (int i = 0; i < children.size(); i++) { memdelete(children[i]); } - }; + } }; struct NodeSkeleton : public Node { diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index d13a022d52..a686e55f57 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -436,6 +436,7 @@ void InspectorDock::_notification(int p_what) { PopupMenu *resource_extra_popup = resource_extra_button->get_popup(); resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_EDIT_CLIPBOARD), get_editor_theme_icon(SNAME("ActionPaste"))); resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_COPY), get_editor_theme_icon(SNAME("ActionCopy"))); + resource_extra_popup->set_item_icon(resource_extra_popup->get_item_index(RESOURCE_SHOW_IN_FILESYSTEM), get_editor_theme_icon(SNAME("ShowInFileSystem"))); if (is_layout_rtl()) { backward_button->set_icon(get_editor_theme_icon(SNAME("Forward"))); diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 60ce8100aa..924f7abdd2 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -113,7 +113,7 @@ class InspectorDock : public VBoxContainer { void _new_resource(); void _load_resource(const String &p_type = ""); - void _open_resource_selector() { _load_resource(); }; // just used to call from arg-less signal + void _open_resource_selector() { _load_resource(); } // just used to call from arg-less signal void _resource_file_selected(const String &p_file); void _save_resource(bool save_as); void _unref_resource(); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 1581e7cc66..8bc1ec7907 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1397,7 +1397,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_timeline_o } track_editor->set_anim_pos(pos); -}; +} void AnimationPlayerEditor::_animation_player_changed(Object *p_pl) { _update_player(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index e9a796dae7..05d5f68363 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1464,10 +1464,12 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) { List<CanvasItem *> selection = _get_edited_canvas_items(false, true, &has_locked_items); // Remove not movable nodes - for (CanvasItem *E : selection) { - if (!_is_node_movable(E, true)) { + for (List<CanvasItem *>::Element *E = selection.front(); E;) { + List<CanvasItem *>::Element *N = E->next(); + if (!_is_node_movable(E->get(), true)) { selection.erase(E); } + E = N; } drag_selection = selection; diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index 24943af60f..29dae38445 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -157,7 +157,7 @@ ControlPositioningWarning::ControlPositioningWarning() { void EditorPropertyAnchorsPreset::_set_read_only(bool p_read_only) { options->set_disabled(p_read_only); -}; +} void EditorPropertyAnchorsPreset::_option_selected(int p_which) { int64_t val = options->get_item_metadata(p_which); @@ -221,7 +221,7 @@ void EditorPropertySizeFlags::_set_read_only(bool p_read_only) { check->set_disabled(p_read_only); } flag_presets->set_disabled(p_read_only); -}; +} void EditorPropertySizeFlags::_preset_selected(int p_which) { int preset = flag_presets->get_item_id(p_which); diff --git a/editor/plugins/control_editor_plugin.h b/editor/plugins/control_editor_plugin.h index 2672e8ef97..56e9f6ced4 100644 --- a/editor/plugins/control_editor_plugin.h +++ b/editor/plugins/control_editor_plugin.h @@ -241,7 +241,7 @@ protected: static ControlEditorToolbar *singleton; public: - bool is_anchors_mode_enabled() { return anchors_mode; }; + bool is_anchors_mode_enabled() { return anchors_mode; } static ControlEditorToolbar *get_singleton() { return singleton; } diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index 164aa3eccc..cb082ec513 100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -168,7 +168,7 @@ protected: virtual Vector2 _get_offset(int p_idx) const override; - virtual bool _has_uv() const override { return true; }; + virtual bool _has_uv() const override { return true; } virtual void _commit_action() override; void _notification(int p_what); diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 81beaf6f91..9a5d02d9e7 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -351,12 +351,12 @@ void Skeleton3DEditor::set_keyable(const bool p_keyable) { } else { animation_hb->hide(); } -}; +} void Skeleton3DEditor::set_bone_options_enabled(const bool p_bone_options_enabled) { skeleton_options->get_popup()->set_item_disabled(SKELETON_OPTION_RESET_SELECTED_POSES, !p_bone_options_enabled); skeleton_options->get_popup()->set_item_disabled(SKELETON_OPTION_SELECTED_POSES_TO_RESTS, !p_bone_options_enabled); -}; +} void Skeleton3DEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("update_all"), &Skeleton3DEditor::update_all); diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 0265183dfa..c6f8c5d357 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -228,14 +228,14 @@ public: void move_skeleton_bone(NodePath p_skeleton_path, int32_t p_selected_boneidx, int32_t p_target_boneidx); - Skeleton3D *get_skeleton() const { return skeleton; }; + Skeleton3D *get_skeleton() const { return skeleton; } bool is_edit_mode() const { return edit_mode; } void update_bone_original(); - Vector3 get_bone_original_position() const { return bone_original_position; }; - Quaternion get_bone_original_rotation() const { return bone_original_rotation; }; - Vector3 get_bone_original_scale() const { return bone_original_scale; }; + Vector3 get_bone_original_position() const { return bone_original_position; } + Quaternion get_bone_original_rotation() const { return bone_original_rotation; } + Vector3 get_bone_original_scale() const { return bone_original_scale; } Skeleton3DEditor(EditorInspectorPluginSkeleton *e_plugin, Skeleton3D *skeleton); ~Skeleton3DEditor(); diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index b806d1e042..e9f920b438 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -496,13 +496,13 @@ void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_ float TileAtlasView::get_zoom() const { return zoom_widget->get_zoom(); -}; +} void TileAtlasView::set_transform(float p_zoom, Vector2i p_panning) { zoom_widget->set_zoom(p_zoom); panning = p_panning; _update_zoom_and_panning(); -}; +} void TileAtlasView::set_padding(Side p_side, int p_padding) { ERR_FAIL_COND(p_padding < 0); diff --git a/editor/plugins/tiles/tile_atlas_view.h b/editor/plugins/tiles/tile_atlas_view.h index 8fcf942056..025df4fda0 100644 --- a/editor/plugins/tiles/tile_atlas_view.h +++ b/editor/plugins/tiles/tile_atlas_view.h @@ -135,8 +135,8 @@ public: void set_padding(Side p_side, int p_padding); // Left side. - void set_texture_grid_visible(bool p_visible) { base_tiles_texture_grid->set_visible(p_visible); }; - void set_tile_shape_grid_visible(bool p_visible) { base_tiles_shape_grid->set_visible(p_visible); }; + void set_texture_grid_visible(bool p_visible) { base_tiles_texture_grid->set_visible(p_visible); } + void set_tile_shape_grid_visible(bool p_visible) { base_tiles_shape_grid->set_visible(p_visible); } Vector2i get_atlas_tile_coords_at_pos(const Vector2 p_pos, bool p_clamp = false) const; @@ -148,7 +148,7 @@ public: } p_control->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); p_control->set_mouse_filter(Control::MOUSE_FILTER_PASS); - }; + } // Right side. Vector3i get_alternative_tile_at_pos(const Vector2 p_pos) const; @@ -162,7 +162,7 @@ public: } p_control->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); p_control->set_mouse_filter(Control::MOUSE_FILTER_PASS); - }; + } // Redraw everything. void queue_redraw(); diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index c6921699a4..3a4af941d4 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -1100,11 +1100,10 @@ void TileDataDefaultEditor::forward_draw_over_atlas(TileAtlasView *p_tile_atlas_ } p_canvas_item->draw_set_transform_matrix(Transform2D()); } -}; +} void TileDataDefaultEditor::forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) { - -}; +} void TileDataDefaultEditor::forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_set_atlas_source, const Ref<InputEvent> &p_event) { Ref<InputEventMouseMotion> mm = p_event; diff --git a/editor/plugins/tiles/tile_data_editors.h b/editor/plugins/tiles/tile_data_editors.h index 1426bb4c2f..312eb724ed 100644 --- a/editor/plugins/tiles/tile_data_editors.h +++ b/editor/plugins/tiles/tile_data_editors.h @@ -62,7 +62,7 @@ public: void set_tile_set(Ref<TileSet> p_tile_set); // Input to handle painting. - virtual Control *get_toolbar() { return nullptr; }; + virtual Control *get_toolbar() { return nullptr; } virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {} virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) {} virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) {} @@ -238,7 +238,7 @@ protected: virtual void _setup_undo_redo_action(TileSetAtlasSource *p_tile_set_atlas_source, const HashMap<TileMapCell, Variant, TileMapCell> &p_previous_values, const Variant &p_new_value); public: - virtual Control *get_toolbar() override { return toolbar; }; + virtual Control *get_toolbar() override { return toolbar; } virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override; @@ -375,7 +375,7 @@ protected: void _notification(int p_what); public: - virtual Control *get_toolbar() override { return toolbar; }; + virtual Control *get_toolbar() override { return toolbar; } virtual void forward_draw_over_atlas(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; virtual void forward_draw_over_alternatives(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, CanvasItem *p_canvas_item, Transform2D p_transform) override; virtual void forward_painting_atlas_gui_input(TileAtlasView *p_tile_atlas_view, TileSetAtlasSource *p_tile_atlas_source, const Ref<InputEvent> &p_event) override; diff --git a/editor/plugins/tiles/tile_map_layer_editor.h b/editor/plugins/tiles/tile_map_layer_editor.h index 805af7b58e..bcba34299d 100644 --- a/editor/plugins/tiles/tile_map_layer_editor.h +++ b/editor/plugins/tiles/tile_map_layer_editor.h @@ -63,9 +63,9 @@ public: virtual Vector<TabData> get_tabs() const { return Vector<TabData>(); - }; + } - virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return false; }; + virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return false; } virtual void forward_canvas_draw_over_viewport(Control *p_overlay) {} virtual void tile_set_changed() {} virtual void edit(ObjectID p_tile_map_layer_id) {} diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index c1a8338f81..39f2f51ef3 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -80,7 +80,7 @@ public: int get_id() const; void edit(Ref<TileSet> p_tile_set, Ref<TileSetAtlasSource> p_tile_set_atlas_source, int p_source_id); - Ref<TileSetAtlasSource> get_edited() { return tile_set_atlas_source; }; + Ref<TileSetAtlasSource> get_edited() { return tile_set_atlas_source; } }; // -- Proxy object for a tile, needed by the inspector -- @@ -101,8 +101,8 @@ public: static void _bind_methods(); public: - Ref<TileSetAtlasSource> get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; }; - RBSet<TileSelection> get_edited_tiles() const { return tiles; }; + Ref<TileSetAtlasSource> get_edited_tile_set_atlas_source() const { return tile_set_atlas_source; } + RBSet<TileSelection> get_edited_tiles() const { return tiles; } // Update the proxyed object. void edit(Ref<TileSetAtlasSource> p_tile_set_atlas_source, const RBSet<TileSelection> &p_tiles = RBSet<TileSelection>()); diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index b295e5733e..f8ceb871dc 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -1270,7 +1270,7 @@ bool ProjectConverter3To4::test_single_array(const char *p_array[][2], bool p_ig } } return valid; -}; +} // Returns arguments from given function execution, this cannot be really done as regex. // `abc(d,e(f,g),h)` -> [d], [e(f,g)], [h] @@ -1469,7 +1469,7 @@ void ProjectConverter3To4::rename_colors(Vector<SourceLine> &source_lines, const } } } -}; +} // Convert hexadecimal colors from ARGB to RGBA void ProjectConverter3To4::convert_hexadecimal_colors(Vector<SourceLine> &source_lines, const RegExContainer ®_container) { @@ -1566,7 +1566,7 @@ void ProjectConverter3To4::rename_classes(Vector<SourceLine> &source_lines, cons } } } -}; +} Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &lines, const RegExContainer ®_container) { Vector<String> found_renames; @@ -1618,7 +1618,7 @@ void ProjectConverter3To4::rename_gdscript_functions(Vector<SourceLine> &source_ process_gdscript_line(line, reg_container, builtin); } } -}; +} Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer ®_container, bool builtin) { int current_line = 1; @@ -2438,7 +2438,7 @@ void ProjectConverter3To4::rename_csharp_functions(Vector<SourceLine> &source_li process_csharp_line(line, reg_container); } } -}; +} Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer ®_container) { int current_line = 1; @@ -2847,7 +2847,7 @@ void ProjectConverter3To4::custom_rename(Vector<SourceLine> &source_lines, const line = reg.sub(line, to, true); } } -}; +} Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, const String &from, const String &to) { Vector<String> found_renames; diff --git a/editor/rename_dialog.h b/editor/rename_dialog.h index 37d159b4e2..5c2ac2558d 100644 --- a/editor/rename_dialog.h +++ b/editor/rename_dialog.h @@ -49,7 +49,7 @@ class TabContainer; class RenameDialog : public ConfirmationDialog { GDCLASS(RenameDialog, ConfirmationDialog); - virtual void ok_pressed() override { rename(); }; + virtual void ok_pressed() override { rename(); } void _cancel_pressed() {} void _features_toggled(bool pressed); void _insert_text(const String &text); diff --git a/editor/surface_upgrade_tool.h b/editor/surface_upgrade_tool.h index 59745250e4..130c49dcac 100644 --- a/editor/surface_upgrade_tool.h +++ b/editor/surface_upgrade_tool.h @@ -54,9 +54,9 @@ protected: static void _bind_methods(); public: - static SurfaceUpgradeTool *get_singleton() { return singleton; }; + static SurfaceUpgradeTool *get_singleton() { return singleton; } - bool is_show_requested() const { return show_requested; }; + bool is_show_requested() const { return show_requested; } void show_popup() { _show_popup(); } void prepare_upgrade(); diff --git a/editor/themes/editor_color_map.h b/editor/themes/editor_color_map.h index c1176749f2..fba39f249e 100644 --- a/editor/themes/editor_color_map.h +++ b/editor/themes/editor_color_map.h @@ -50,8 +50,8 @@ public: static void add_conversion_color_pair(const String &p_from_color, const String &p_to_color); static void add_conversion_exception(const StringName &p_icon_name); - static HashMap<Color, Color> &get_color_conversion_map() { return color_conversion_map; }; - static HashSet<StringName> &get_color_conversion_exceptions() { return color_conversion_exceptions; }; + static HashMap<Color, Color> &get_color_conversion_map() { return color_conversion_map; } + static HashSet<StringName> &get_color_conversion_exceptions() { return color_conversion_exceptions; } static void create(); static void finish(); diff --git a/methods.py b/methods.py index 9e881773c9..65b88a5c65 100644 --- a/methods.py +++ b/methods.py @@ -404,10 +404,6 @@ def convert_custom_modules_path(path): return path -def disable_module(self): - self.disabled_modules.append(self.current_module) - - def module_add_dependencies(self, module, dependencies, optional=False): """ Adds dependencies for a given module. @@ -428,19 +424,21 @@ def module_check_dependencies(self, module): Meant to be used in module `can_build` methods. Returns a boolean (True if dependencies are satisfied). """ - missing_deps = [] + missing_deps = set() required_deps = self.module_dependencies[module][0] if module in self.module_dependencies else [] for dep in required_deps: opt = "module_{}_enabled".format(dep) - if opt not in self or not self[opt]: - missing_deps.append(dep) - - if missing_deps != []: - print_warning( - "Disabling '{}' module as the following dependencies are not satisfied: {}".format( - module, ", ".join(missing_deps) + if opt not in self or not self[opt] or not module_check_dependencies(self, dep): + missing_deps.add(dep) + + if missing_deps: + if module not in self.disabled_modules: + print_warning( + "Disabling '{}' module as the following dependencies are not satisfied: {}".format( + module, ", ".join(missing_deps) + ) ) - ) + self.disabled_modules.add(module) return False else: return True diff --git a/misc/utility/.clang-format-glsl b/misc/utility/.clang-format-glsl new file mode 100644 index 0000000000..59efa8fa35 --- /dev/null +++ b/misc/utility/.clang-format-glsl @@ -0,0 +1,42 @@ +# GLSL-specific rules. +# The rules should be the same as .clang-format, except those explicitly mentioned. +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: + Kind: Never + OverEmptyLines: 0 +AllowAllParametersOfDeclarationOnNextLine: false +BreakConstructorInitializers: AfterColon +ColumnLimit: 0 +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +IncludeCategories: + - Regex: ^".*"$ + Priority: 1 + - Regex: ^<.*\.h>$ + Priority: 2 + - Regex: ^<.*>$ + Priority: 3 +IndentCaseLabels: true +IndentWidth: 4 +JavaImportGroups: + - org.godotengine + - android + - androidx + - com.android + - com.google + - java + - javax +KeepEmptyLinesAtTheStartOfBlocks: false +ObjCBlockIndentWidth: 4 +PackConstructorInitializers: NextLine +RemoveSemicolon: false # Differs from base .clang-format +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +Standard: c++20 +TabWidth: 4 +UseTab: Always diff --git a/modules/camera/camera_linux.cpp b/modules/camera/camera_linux.cpp index 0cfb6b7b9e..e5558bf96c 100644 --- a/modules/camera/camera_linux.cpp +++ b/modules/camera/camera_linux.cpp @@ -161,7 +161,7 @@ bool CameraLinux::_can_query_format(int p_file_descriptor, int p_type) { CameraLinux::CameraLinux() { camera_thread.start(CameraLinux::camera_thread_func, this); -}; +} CameraLinux::~CameraLinux() { exit_flag.set(); diff --git a/modules/camera/camera_macos.mm b/modules/camera/camera_macos.mm index de4f814846..bd718a0cb6 100644 --- a/modules/camera/camera_macos.mm +++ b/modules/camera/camera_macos.mm @@ -212,12 +212,12 @@ public: AVCaptureDevice *CameraFeedMacOS::get_device() const { return device; -}; +} CameraFeedMacOS::CameraFeedMacOS() { device = nullptr; capture_session = nullptr; -}; +} void CameraFeedMacOS::set_device(AVCaptureDevice *p_device) { device = p_device; @@ -231,7 +231,7 @@ void CameraFeedMacOS::set_device(AVCaptureDevice *p_device) { } else if ([p_device position] == AVCaptureDevicePositionFront) { position = CameraFeed::FEED_FRONT; }; -}; +} bool CameraFeedMacOS::activate_feed() { if (capture_session) { @@ -257,7 +257,7 @@ bool CameraFeedMacOS::activate_feed() { }; return true; -}; +} void CameraFeedMacOS::deactivate_feed() { // end camera capture if we have one @@ -265,7 +265,7 @@ void CameraFeedMacOS::deactivate_feed() { [capture_session cleanup]; capture_session = nullptr; }; -}; +} ////////////////////////////////////////////////////////////////////////// // MyDeviceNotifications - This is a little helper class gets notifications @@ -351,7 +351,7 @@ void CameraMacOS::update_feeds() { add_feed(newfeed); }; }; -}; +} CameraMacOS::CameraMacOS() { // Find available cameras we have at this time @@ -359,4 +359,4 @@ CameraMacOS::CameraMacOS() { // should only have one of these.... device_notifications = [[MyDeviceNotifications alloc] initForServer:this]; -}; +} diff --git a/modules/camera/camera_win.cpp b/modules/camera/camera_win.cpp index 755642270e..7871595d91 100644 --- a/modules/camera/camera_win.cpp +++ b/modules/camera/camera_win.cpp @@ -64,13 +64,13 @@ CameraFeedWindows::~CameraFeedWindows() { }; ///@TODO free up anything used by this -}; +} bool CameraFeedWindows::activate_feed() { ///@TODO this should activate our camera and start the process of capturing frames return true; -}; +} ///@TODO we should probably have a callback method here that is being called by the // camera API which provides frames and call back into the CameraServer to update our texture @@ -91,4 +91,4 @@ CameraWindows::CameraWindows() { add_active_cameras(); // need to add something that will react to devices being connected/removed... -}; +} diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 6ea44c5fc3..601d0e0c24 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -46,7 +46,12 @@ enum { DDPF_ALPHAONLY = 0x00000002, DDPF_FOURCC = 0x00000004, DDPF_RGB = 0x00000040, - DDPF_RG_SNORM = 0x00080000 + DDPF_RG_SNORM = 0x00080000, + DDSC2_CUBEMAP = 0x200, + DDSC2_VOLUME = 0x200000, + DX10D_1D = 2, + DX10D_2D = 3, + DX10D_3D = 4, }; enum DDSFourCC { @@ -139,6 +144,15 @@ enum DDSFormat { DDS_MAX }; +enum DDSType { + DDST_2D = 1, + DDST_CUBEMAP, + DDST_3D, + + DDST_TYPE_MASK = 0x7F, + DDST_ARRAY = 0x80, +}; + struct DDSFormatInfo { const char *name = nullptr; bool compressed = false; @@ -180,7 +194,7 @@ static const DDSFormatInfo dds_format_info[DDS_MAX] = { { "GRAYSCALE_ALPHA_4", false, 1, 1, Image::FORMAT_LA8 } }; -static DDSFormat dxgi_to_dds_format(uint32_t p_dxgi_format) { +inline DDSFormat _dxgi_to_dds_format(uint32_t p_dxgi_format) { switch (p_dxgi_format) { case DXGI_R32G32B32A32_FLOAT: { return DDS_RGBA32F; @@ -267,210 +281,23 @@ static DDSFormat dxgi_to_dds_format(uint32_t p_dxgi_format) { } } -Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { - if (r_error) { - *r_error = ERR_CANT_OPEN; - } - - Error err; - Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ, &err); - if (f.is_null()) { - return Ref<Resource>(); - } - - Ref<FileAccess> fref(f); - if (r_error) { - *r_error = ERR_FILE_CORRUPT; - } - - ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Unable to open DDS texture file '" + p_path + "'."); - - uint32_t magic = f->get_32(); - uint32_t hsize = f->get_32(); - uint32_t flags = f->get_32(); - uint32_t height = f->get_32(); - uint32_t width = f->get_32(); - uint32_t pitch = f->get_32(); - /* uint32_t depth = */ f->get_32(); - uint32_t mipmaps = f->get_32(); - - // Skip reserved. - for (int i = 0; i < 11; i++) { - f->get_32(); - } - - // Validate. - // We don't check DDSD_CAPS or DDSD_PIXELFORMAT, as they're mandatory when writing, - // but non-mandatory when reading (as some writers don't set them). - if (magic != DDS_MAGIC || hsize != 124) { - ERR_FAIL_V_MSG(Ref<Resource>(), "Invalid or unsupported DDS texture file '" + p_path + "'."); - } - - /* uint32_t format_size = */ f->get_32(); - uint32_t format_flags = f->get_32(); - uint32_t format_fourcc = f->get_32(); - uint32_t format_rgb_bits = f->get_32(); - uint32_t format_red_mask = f->get_32(); - uint32_t format_green_mask = f->get_32(); - uint32_t format_blue_mask = f->get_32(); - uint32_t format_alpha_mask = f->get_32(); - - /* uint32_t caps_1 = */ f->get_32(); - /* uint32_t caps_2 = */ f->get_32(); - /* uint32_t caps_3 = */ f->get_32(); - /* uint32_t caps_4 = */ f->get_32(); - - // Skip reserved. - f->get_32(); - - if (f->get_position() < 128) { - f->seek(128); - } - - DDSFormat dds_format = DDS_MAX; - - if (format_flags & DDPF_FOURCC) { - // FourCC formats. - switch (format_fourcc) { - case DDFCC_DXT1: { - dds_format = DDS_DXT1; - } break; - case DDFCC_DXT2: - case DDFCC_DXT3: { - dds_format = DDS_DXT3; - } break; - case DDFCC_DXT4: - case DDFCC_DXT5: { - dds_format = DDS_DXT5; - } break; - case DDFCC_ATI1: - case DDFCC_BC4U: { - dds_format = DDS_ATI1; - } break; - case DDFCC_ATI2: - case DDFCC_BC5U: - case DDFCC_A2XY: { - dds_format = DDS_ATI2; - } break; - case DDFCC_R16F: { - dds_format = DDS_R16F; - } break; - case DDFCC_RG16F: { - dds_format = DDS_RG16F; - } break; - case DDFCC_RGBA16F: { - dds_format = DDS_RGBA16F; - } break; - case DDFCC_R32F: { - dds_format = DDS_R32F; - } break; - case DDFCC_RG32F: { - dds_format = DDS_RG32F; - } break; - case DDFCC_RGBA32F: { - dds_format = DDS_RGBA32F; - } break; - case DDFCC_DX10: { - uint32_t dxgi_format = f->get_32(); - /* uint32_t dimension = */ f->get_32(); - /* uint32_t misc_flags_1 = */ f->get_32(); - /* uint32_t array_size = */ f->get_32(); - /* uint32_t misc_flags_2 = */ f->get_32(); - - dds_format = dxgi_to_dds_format(dxgi_format); - } break; - - default: { - ERR_FAIL_V_MSG(Ref<Resource>(), "Unrecognized or unsupported FourCC in DDS '" + p_path + "'."); - } - } - - } else if (format_flags & DDPF_RGB) { - // Channel-bitmasked formats. - if (format_flags & DDPF_ALPHAPIXELS) { - // With alpha. - if (format_rgb_bits == 32 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff && format_alpha_mask == 0xff000000) { - dds_format = DDS_BGRA8; - } else if (format_rgb_bits == 32 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000 && format_alpha_mask == 0xff000000) { - dds_format = DDS_RGBA8; - } else if (format_rgb_bits == 16 && format_red_mask == 0x00007c00 && format_green_mask == 0x000003e0 && format_blue_mask == 0x0000001f && format_alpha_mask == 0x00008000) { - dds_format = DDS_BGR5A1; - } else if (format_rgb_bits == 32 && format_red_mask == 0x3ff00000 && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff && format_alpha_mask == 0xc0000000) { - dds_format = DDS_BGR10A2; - } else if (format_rgb_bits == 32 && format_red_mask == 0x3ff && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff00000 && format_alpha_mask == 0xc0000000) { - dds_format = DDS_RGB10A2; - } else if (format_rgb_bits == 16 && format_red_mask == 0xf00 && format_green_mask == 0xf0 && format_blue_mask == 0xf && format_alpha_mask == 0xf000) { - dds_format = DDS_BGRA4; - } else if (format_rgb_bits == 16 && format_red_mask == 0xe0 && format_green_mask == 0x1c && format_blue_mask == 0x3 && format_alpha_mask == 0xff00) { - dds_format = DDS_B2GR3A8; - } +static Ref<Image> _dds_load_layer(Ref<FileAccess> p_file, DDSFormat p_dds_format, uint32_t p_width, uint32_t p_height, uint32_t p_mipmaps, uint32_t p_pitch, uint32_t p_flags, Vector<uint8_t> &r_src_data) { + const DDSFormatInfo &info = dds_format_info[p_dds_format]; - } else { - // Without alpha. - if (format_rgb_bits == 24 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff) { - dds_format = DDS_BGR8; - } else if (format_rgb_bits == 24 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000) { - dds_format = DDS_RGB8; - } else if (format_rgb_bits == 16 && format_red_mask == 0x0000f800 && format_green_mask == 0x000007e0 && format_blue_mask == 0x0000001f) { - dds_format = DDS_BGR565; - } else if (format_rgb_bits == 8 && format_red_mask == 0xe0 && format_green_mask == 0x1c && format_blue_mask == 0x3) { - dds_format = DDS_B2GR3; - } - } - - } else { - // Other formats. - if (format_flags & DDPF_ALPHAONLY && format_rgb_bits == 8 && format_alpha_mask == 0xff) { - // Alpha only. - dds_format = DDS_LUMINANCE; - } - } - - // Depending on the writer, luminance formats may or may not have the DDPF_RGB or DDPF_LUMINANCE flags defined, - // so we check for these formats after everything else failed. - if (dds_format == DDS_MAX) { - if (format_flags & DDPF_ALPHAPIXELS) { - // With alpha. - if (format_rgb_bits == 16 && format_red_mask == 0xff && format_alpha_mask == 0xff00) { - dds_format = DDS_LUMINANCE_ALPHA; - } else if (format_rgb_bits == 8 && format_red_mask == 0xf && format_alpha_mask == 0xf0) { - dds_format = DDS_LUMINANCE_ALPHA_4; - } - - } else { - // Without alpha. - if (format_rgb_bits == 8 && format_red_mask == 0xff) { - dds_format = DDS_LUMINANCE; - } - } - } - - // No format detected, error. - if (dds_format == DDS_MAX) { - ERR_FAIL_V_MSG(Ref<Resource>(), "Unrecognized or unsupported color layout in DDS '" + p_path + "'."); - } - - if (!(flags & DDSD_MIPMAPCOUNT)) { - mipmaps = 1; - } - - Vector<uint8_t> src_data; - - const DDSFormatInfo &info = dds_format_info[dds_format]; - uint32_t w = width; - uint32_t h = height; + uint32_t w = p_width; + uint32_t h = p_height; if (info.compressed) { // BC compressed. uint32_t size = MAX(info.divisor, w) / info.divisor * MAX(info.divisor, h) / info.divisor * info.block_size; - if (flags & DDSD_LINEARSIZE) { - ERR_FAIL_COND_V_MSG(size != pitch, Ref<Resource>(), "DDS header flags specify that a linear size of the top-level image is present, but the specified size does not match the expected value."); + if (p_flags & DDSD_LINEARSIZE) { + ERR_FAIL_COND_V_MSG(size != p_pitch, Ref<Resource>(), "DDS header flags specify that a linear size of the top-level image is present, but the specified size does not match the expected value."); } else { - ERR_FAIL_COND_V_MSG(pitch != 0, Ref<Resource>(), "DDS header flags specify that no linear size will given for the top-level image, but a non-zero linear size value is present in the header."); + ERR_FAIL_COND_V_MSG(p_pitch != 0, Ref<Resource>(), "DDS header flags specify that no linear size will given for the top-level image, but a non-zero linear size value is present in the header."); } - for (uint32_t i = 1; i < mipmaps; i++) { + for (uint32_t i = 1; i < p_mipmaps; i++) { w = MAX(1u, w >> 1); h = MAX(1u, h >> 1); @@ -478,22 +305,22 @@ Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_orig size += bsize; } - src_data.resize(size); - uint8_t *wb = src_data.ptrw(); - f->get_buffer(wb, size); + r_src_data.resize(size); + uint8_t *wb = r_src_data.ptrw(); + p_file->get_buffer(wb, size); } else { // Generic uncompressed. - uint32_t size = width * height * info.block_size; + uint32_t size = p_width * p_height * info.block_size; - for (uint32_t i = 1; i < mipmaps; i++) { + for (uint32_t i = 1; i < p_mipmaps; i++) { w = (w + 1) >> 1; h = (h + 1) >> 1; size += w * h * info.block_size; } // Calculate the space these formats will take up after decoding. - switch (dds_format) { + switch (p_dds_format) { case DDS_BGR565: size = size * 3 / 2; break; @@ -513,12 +340,11 @@ Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_orig break; } - src_data.resize(size); - uint8_t *wb = src_data.ptrw(); - f->get_buffer(wb, size); + r_src_data.resize(size); + uint8_t *wb = r_src_data.ptrw(); + p_file->get_buffer(wb, size); - // Decode nonstandard formats. - switch (dds_format) { + switch (p_dds_format) { case DDS_BGR5A1: { // To RGBA8. int colcount = size / 4; @@ -705,14 +531,282 @@ Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_orig } } - Ref<Image> img = memnew(Image(width, height, mipmaps - 1, info.format, src_data)); - Ref<ImageTexture> texture = ImageTexture::create_from_image(img); + return memnew(Image(p_width, p_height, p_mipmaps > 1, info.format, r_src_data)); +} + +Ref<Resource> ResourceFormatDDS::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) { + if (r_error) { + *r_error = ERR_CANT_OPEN; + } + + Error err; + Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ, &err); + if (f.is_null()) { + return Ref<Resource>(); + } + Ref<FileAccess> fref(f); if (r_error) { - *r_error = OK; + *r_error = ERR_FILE_CORRUPT; + } + + ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), vformat("Unable to open DDS texture file '%s'.", p_path)); + + uint32_t magic = f->get_32(); + uint32_t hsize = f->get_32(); + uint32_t flags = f->get_32(); + uint32_t height = f->get_32(); + uint32_t width = f->get_32(); + uint32_t pitch = f->get_32(); + uint32_t depth = f->get_32(); + uint32_t mipmaps = f->get_32(); + + // Skip reserved. + for (int i = 0; i < 11; i++) { + f->get_32(); + } + + // Validate. + // We don't check DDSD_CAPS or DDSD_PIXELFORMAT, as they're mandatory when writing, + // but non-mandatory when reading (as some writers don't set them). + if (magic != DDS_MAGIC || hsize != 124) { + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Invalid or unsupported DDS texture file '%s'.", p_path)); + } + + /* uint32_t format_size = */ f->get_32(); + uint32_t format_flags = f->get_32(); + uint32_t format_fourcc = f->get_32(); + uint32_t format_rgb_bits = f->get_32(); + uint32_t format_red_mask = f->get_32(); + uint32_t format_green_mask = f->get_32(); + uint32_t format_blue_mask = f->get_32(); + uint32_t format_alpha_mask = f->get_32(); + + /* uint32_t caps_1 = */ f->get_32(); + uint32_t caps_2 = f->get_32(); + /* uint32_t caps_3 = */ f->get_32(); + /* uint32_t caps_4 = */ f->get_32(); + + // Skip reserved. + f->get_32(); + + if (f->get_position() < 128) { + f->seek(128); + } + + uint32_t layer_count = 1; + uint32_t dds_type = DDST_2D; + + if (caps_2 & DDSC2_CUBEMAP) { + dds_type = DDST_CUBEMAP; + layer_count *= 6; + + } else if (caps_2 & DDSC2_VOLUME) { + dds_type = DDST_3D; + layer_count = depth; + } + + DDSFormat dds_format = DDS_MAX; + + if (format_flags & DDPF_FOURCC) { + // FourCC formats. + switch (format_fourcc) { + case DDFCC_DXT1: { + dds_format = DDS_DXT1; + } break; + case DDFCC_DXT2: + case DDFCC_DXT3: { + dds_format = DDS_DXT3; + } break; + case DDFCC_DXT4: + case DDFCC_DXT5: { + dds_format = DDS_DXT5; + } break; + case DDFCC_ATI1: + case DDFCC_BC4U: { + dds_format = DDS_ATI1; + } break; + case DDFCC_ATI2: + case DDFCC_BC5U: + case DDFCC_A2XY: { + dds_format = DDS_ATI2; + } break; + case DDFCC_R16F: { + dds_format = DDS_R16F; + } break; + case DDFCC_RG16F: { + dds_format = DDS_RG16F; + } break; + case DDFCC_RGBA16F: { + dds_format = DDS_RGBA16F; + } break; + case DDFCC_R32F: { + dds_format = DDS_R32F; + } break; + case DDFCC_RG32F: { + dds_format = DDS_RG32F; + } break; + case DDFCC_RGBA32F: { + dds_format = DDS_RGBA32F; + } break; + case DDFCC_DX10: { + uint32_t dxgi_format = f->get_32(); + uint32_t dimension = f->get_32(); + /* uint32_t misc_flags_1 = */ f->get_32(); + uint32_t array_size = f->get_32(); + /* uint32_t misc_flags_2 = */ f->get_32(); + + if (dimension == DX10D_3D) { + dds_type = DDST_3D; + layer_count = depth; + } + + if (array_size > 1) { + layer_count *= array_size; + dds_type |= DDST_ARRAY; + } + + dds_format = _dxgi_to_dds_format(dxgi_format); + } break; + + default: { + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Unrecognized or unsupported FourCC in DDS '%s'.", p_path)); + } + } + + } else if (format_flags & DDPF_RGB) { + // Channel-bitmasked formats. + if (format_flags & DDPF_ALPHAPIXELS) { + // With alpha. + if (format_rgb_bits == 32 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff && format_alpha_mask == 0xff000000) { + dds_format = DDS_BGRA8; + } else if (format_rgb_bits == 32 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000 && format_alpha_mask == 0xff000000) { + dds_format = DDS_RGBA8; + } else if (format_rgb_bits == 16 && format_red_mask == 0x00007c00 && format_green_mask == 0x000003e0 && format_blue_mask == 0x0000001f && format_alpha_mask == 0x00008000) { + dds_format = DDS_BGR5A1; + } else if (format_rgb_bits == 32 && format_red_mask == 0x3ff00000 && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff && format_alpha_mask == 0xc0000000) { + dds_format = DDS_BGR10A2; + } else if (format_rgb_bits == 32 && format_red_mask == 0x3ff && format_green_mask == 0xffc00 && format_blue_mask == 0x3ff00000 && format_alpha_mask == 0xc0000000) { + dds_format = DDS_RGB10A2; + } else if (format_rgb_bits == 16 && format_red_mask == 0xf00 && format_green_mask == 0xf0 && format_blue_mask == 0xf && format_alpha_mask == 0xf000) { + dds_format = DDS_BGRA4; + } else if (format_rgb_bits == 16 && format_red_mask == 0xe0 && format_green_mask == 0x1c && format_blue_mask == 0x3 && format_alpha_mask == 0xff00) { + dds_format = DDS_B2GR3A8; + } + + } else { + // Without alpha. + if (format_rgb_bits == 24 && format_red_mask == 0xff0000 && format_green_mask == 0xff00 && format_blue_mask == 0xff) { + dds_format = DDS_BGR8; + } else if (format_rgb_bits == 24 && format_red_mask == 0xff && format_green_mask == 0xff00 && format_blue_mask == 0xff0000) { + dds_format = DDS_RGB8; + } else if (format_rgb_bits == 16 && format_red_mask == 0x0000f800 && format_green_mask == 0x000007e0 && format_blue_mask == 0x0000001f) { + dds_format = DDS_BGR565; + } else if (format_rgb_bits == 8 && format_red_mask == 0xe0 && format_green_mask == 0x1c && format_blue_mask == 0x3) { + dds_format = DDS_B2GR3; + } + } + + } else { + // Other formats. + if (format_flags & DDPF_ALPHAONLY && format_rgb_bits == 8 && format_alpha_mask == 0xff) { + // Alpha only. + dds_format = DDS_LUMINANCE; + } + } + + // Depending on the writer, luminance formats may or may not have the DDPF_RGB or DDPF_LUMINANCE flags defined, + // so we check for these formats after everything else failed. + if (dds_format == DDS_MAX) { + if (format_flags & DDPF_ALPHAPIXELS) { + // With alpha. + if (format_rgb_bits == 16 && format_red_mask == 0xff && format_alpha_mask == 0xff00) { + dds_format = DDS_LUMINANCE_ALPHA; + } else if (format_rgb_bits == 8 && format_red_mask == 0xf && format_alpha_mask == 0xf0) { + dds_format = DDS_LUMINANCE_ALPHA_4; + } + + } else { + // Without alpha. + if (format_rgb_bits == 8 && format_red_mask == 0xff) { + dds_format = DDS_LUMINANCE; + } + } + } + + // No format detected, error. + if (dds_format == DDS_MAX) { + ERR_FAIL_V_MSG(Ref<Resource>(), vformat("Unrecognized or unsupported color layout in DDS '%s'.", p_path)); + } + + if (!(flags & DDSD_MIPMAPCOUNT)) { + mipmaps = 1; + } + + Vector<uint8_t> src_data; + + Vector<Ref<Image>> images; + images.resize(layer_count); + + for (uint32_t i = 0; i < layer_count; i++) { + images.write[i] = _dds_load_layer(f, dds_format, width, height, mipmaps, pitch, flags, src_data); + } + + if ((dds_type & DDST_TYPE_MASK) == DDST_2D) { + if (dds_type & DDST_ARRAY) { + Ref<Texture2DArray> texture = memnew(Texture2DArray()); + texture->create_from_images(images); + + if (r_error) { + *r_error = OK; + } + + return texture; + + } else { + if (r_error) { + *r_error = OK; + } + + return ImageTexture::create_from_image(images[0]); + } + + } else if ((dds_type & DDST_TYPE_MASK) == DDST_CUBEMAP) { + ERR_FAIL_COND_V(layer_count % 6 != 0, Ref<Resource>()); + + if (dds_type & DDST_ARRAY) { + Ref<CubemapArray> texture = memnew(CubemapArray()); + texture->create_from_images(images); + + if (r_error) { + *r_error = OK; + } + + return texture; + + } else { + Ref<Cubemap> texture = memnew(Cubemap()); + texture->create_from_images(images); + + if (r_error) { + *r_error = OK; + } + + return texture; + } + + } else if ((dds_type & DDST_TYPE_MASK) == DDST_3D) { + Ref<ImageTexture3D> texture = memnew(ImageTexture3D()); + texture->create(images[0]->get_format(), width, height, layer_count, mipmaps > 1, images); + + if (r_error) { + *r_error = OK; + } + + return texture; } - return texture; + return Ref<Resource>(); } void ResourceFormatDDS::get_recognized_extensions(List<String> *p_extensions) const { @@ -720,12 +814,12 @@ void ResourceFormatDDS::get_recognized_extensions(List<String> *p_extensions) co } bool ResourceFormatDDS::handles_type(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Texture2D"); + return ClassDB::is_parent_class(p_type, "Texture"); } String ResourceFormatDDS::get_resource_type(const String &p_path) const { if (p_path.get_extension().to_lower() == "dds") { - return "ImageTexture"; + return "Texture"; } return ""; } diff --git a/modules/gdscript/gdscript_tokenizer_buffer.h b/modules/gdscript/gdscript_tokenizer_buffer.h index 55df66e50f..d5d2a4d096 100644 --- a/modules/gdscript/gdscript_tokenizer_buffer.h +++ b/modules/gdscript/gdscript_tokenizer_buffer.h @@ -79,7 +79,7 @@ public: virtual bool is_past_cursor() const override; virtual void push_expression_indented_block() override; // For lambdas, or blocks inside expressions. virtual void pop_expression_indented_block() override; // For lambdas, or blocks inside expressions. - virtual bool is_text() override { return false; }; + virtual bool is_text() override { return false; } #ifdef TOOLS_ENABLED virtual const HashMap<int, CommentData> &get_comments() const override { diff --git a/modules/godot_physics_2d/godot_joints_2d.h b/modules/godot_physics_2d/godot_joints_2d.h index c6a1fdb692..54884e112a 100644 --- a/modules/godot_physics_2d/godot_joints_2d.h +++ b/modules/godot_physics_2d/godot_joints_2d.h @@ -70,7 +70,7 @@ public: body->remove_constraint(this, i); } } - }; + } }; class GodotPinJoint2D : public GodotJoint2D { diff --git a/modules/godot_physics_2d/godot_physics_server_2d.cpp b/modules/godot_physics_2d/godot_physics_server_2d.cpp index 8df17992ea..71d1d3b6b1 100644 --- a/modules/godot_physics_2d/godot_physics_server_2d.cpp +++ b/modules/godot_physics_2d/godot_physics_server_2d.cpp @@ -116,7 +116,7 @@ void GodotPhysicsServer2D::shape_set_data(RID p_shape, const Variant &p_data) { GodotShape2D *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_NULL(shape); shape->set_data(p_data); -}; +} void GodotPhysicsServer2D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { GodotShape2D *shape = shape_owner.get_or_null(p_shape); @@ -128,14 +128,14 @@ PhysicsServer2D::ShapeType GodotPhysicsServer2D::shape_get_type(RID p_shape) con const GodotShape2D *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM); return shape->get_type(); -}; +} Variant GodotPhysicsServer2D::shape_get_data(RID p_shape) const { const GodotShape2D *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_NULL_V(shape, Variant()); ERR_FAIL_COND_V(!shape->is_configured(), Variant()); return shape->get_data(); -}; +} real_t GodotPhysicsServer2D::shape_get_custom_solver_bias(RID p_shape) const { const GodotShape2D *shape = shape_owner.get_or_null(p_shape); @@ -226,7 +226,7 @@ RID GodotPhysicsServer2D::space_create() { area->set_priority(-1); return id; -}; +} void GodotPhysicsServer2D::space_set_active(RID p_space, bool p_active) { GodotSpace2D *space = space_owner.get_or_null(p_space); @@ -445,13 +445,13 @@ void GodotPhysicsServer2D::area_set_param(RID p_area, AreaParameter p_param, con GodotArea2D *area = area_owner.get_or_null(p_area); ERR_FAIL_NULL(area); area->set_param(p_param, p_value); -}; +} void GodotPhysicsServer2D::area_set_transform(RID p_area, const Transform2D &p_transform) { GodotArea2D *area = area_owner.get_or_null(p_area); ERR_FAIL_NULL(area); area->set_transform(p_transform); -}; +} Variant GodotPhysicsServer2D::area_get_param(RID p_area, AreaParameter p_param) const { if (space_owner.owns(p_area)) { @@ -462,14 +462,14 @@ Variant GodotPhysicsServer2D::area_get_param(RID p_area, AreaParameter p_param) ERR_FAIL_NULL_V(area, Variant()); return area->get_param(p_param); -}; +} Transform2D GodotPhysicsServer2D::area_get_transform(RID p_area) const { GodotArea2D *area = area_owner.get_or_null(p_area); ERR_FAIL_NULL_V(area, Transform2D()); return area->get_transform(); -}; +} void GodotPhysicsServer2D::area_set_pickable(RID p_area, bool p_pickable) { GodotArea2D *area = area_owner.get_or_null(p_area); @@ -551,7 +551,7 @@ void GodotPhysicsServer2D::body_set_space(RID p_body, RID p_space) { body->clear_constraint_list(); body->set_space(space); -}; +} RID GodotPhysicsServer2D::body_get_space(RID p_body) const { GodotBody2D *body = body_owner.get_or_null(p_body); @@ -562,7 +562,7 @@ RID GodotPhysicsServer2D::body_get_space(RID p_body) const { return RID(); } return space->get_self(); -}; +} void GodotPhysicsServer2D::body_set_mode(RID p_body, BodyMode p_mode) { GodotBody2D *body = body_owner.get_or_null(p_body); @@ -570,14 +570,14 @@ void GodotPhysicsServer2D::body_set_mode(RID p_body, BodyMode p_mode) { FLUSH_QUERY_CHECK(body); body->set_mode(p_mode); -}; +} PhysicsServer2D::BodyMode GodotPhysicsServer2D::body_get_mode(RID p_body) const { GodotBody2D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL_V(body, BODY_MODE_STATIC); return body->get_mode(); -}; +} void GodotPhysicsServer2D::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) { GodotBody2D *body = body_owner.get_or_null(p_body); @@ -902,7 +902,7 @@ void GodotPhysicsServer2D::body_set_axis_velocity(RID p_body, const Vector2 &p_a v += p_axis_velocity; body->set_linear_velocity(v); body->wakeup(); -}; +} void GodotPhysicsServer2D::body_add_collision_exception(RID p_body, RID p_body_b) { GodotBody2D *body = body_owner.get_or_null(p_body); @@ -910,7 +910,7 @@ void GodotPhysicsServer2D::body_add_collision_exception(RID p_body, RID p_body_b body->add_exception(p_body_b); body->wakeup(); -}; +} void GodotPhysicsServer2D::body_remove_collision_exception(RID p_body, RID p_body_b) { GodotBody2D *body = body_owner.get_or_null(p_body); @@ -918,7 +918,7 @@ void GodotPhysicsServer2D::body_remove_collision_exception(RID p_body, RID p_bod body->remove_exception(p_body_b); body->wakeup(); -}; +} void GodotPhysicsServer2D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { GodotBody2D *body = body_owner.get_or_null(p_body); @@ -927,31 +927,31 @@ void GodotPhysicsServer2D::body_get_collision_exceptions(RID p_body, List<RID> * for (int i = 0; i < body->get_exceptions().size(); i++) { p_exceptions->push_back(body->get_exceptions()[i]); } -}; +} void GodotPhysicsServer2D::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { GodotBody2D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL(body); -}; +} real_t GodotPhysicsServer2D::body_get_contacts_reported_depth_threshold(RID p_body) const { GodotBody2D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL_V(body, 0); return 0; -}; +} void GodotPhysicsServer2D::body_set_omit_force_integration(RID p_body, bool p_omit) { GodotBody2D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL(body); body->set_omit_force_integration(p_omit); -}; +} bool GodotPhysicsServer2D::body_is_omitting_force_integration(RID p_body) const { GodotBody2D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL_V(body, false); return body->get_omit_force_integration(); -}; +} void GodotPhysicsServer2D::body_set_max_contacts_reported(RID p_body, int p_contacts) { GodotBody2D *body = body_owner.get_or_null(p_body); diff --git a/modules/godot_physics_3d/godot_physics_server_3d.cpp b/modules/godot_physics_3d/godot_physics_server_3d.cpp index 6d0949acbe..43f8d2658d 100644 --- a/modules/godot_physics_3d/godot_physics_server_3d.cpp +++ b/modules/godot_physics_3d/godot_physics_server_3d.cpp @@ -106,7 +106,7 @@ void GodotPhysicsServer3D::shape_set_data(RID p_shape, const Variant &p_data) { GodotShape3D *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_NULL(shape); shape->set_data(p_data); -}; +} void GodotPhysicsServer3D::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { GodotShape3D *shape = shape_owner.get_or_null(p_shape); @@ -118,14 +118,14 @@ PhysicsServer3D::ShapeType GodotPhysicsServer3D::shape_get_type(RID p_shape) con const GodotShape3D *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_NULL_V(shape, SHAPE_CUSTOM); return shape->get_type(); -}; +} Variant GodotPhysicsServer3D::shape_get_data(RID p_shape) const { const GodotShape3D *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_NULL_V(shape, Variant()); ERR_FAIL_COND_V(!shape->is_configured(), Variant()); return shape->get_data(); -}; +} void GodotPhysicsServer3D::shape_set_margin(RID p_shape, real_t p_margin) { } @@ -156,7 +156,7 @@ RID GodotPhysicsServer3D::space_create() { space->set_static_global_body(sgb); return id; -}; +} void GodotPhysicsServer3D::space_set_active(RID p_space, bool p_active) { GodotSpace3D *space = space_owner.get_or_null(p_space); @@ -354,13 +354,13 @@ void GodotPhysicsServer3D::area_set_param(RID p_area, AreaParameter p_param, con GodotArea3D *area = area_owner.get_or_null(p_area); ERR_FAIL_NULL(area); area->set_param(p_param, p_value); -}; +} void GodotPhysicsServer3D::area_set_transform(RID p_area, const Transform3D &p_transform) { GodotArea3D *area = area_owner.get_or_null(p_area); ERR_FAIL_NULL(area); area->set_transform(p_transform); -}; +} Variant GodotPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) const { if (space_owner.owns(p_area)) { @@ -371,14 +371,14 @@ Variant GodotPhysicsServer3D::area_get_param(RID p_area, AreaParameter p_param) ERR_FAIL_NULL_V(area, Variant()); return area->get_param(p_param); -}; +} Transform3D GodotPhysicsServer3D::area_get_transform(RID p_area) const { GodotArea3D *area = area_owner.get_or_null(p_area); ERR_FAIL_NULL_V(area, Transform3D()); return area->get_transform(); -}; +} void GodotPhysicsServer3D::area_set_collision_layer(RID p_area, uint32_t p_layer) { GodotArea3D *area = area_owner.get_or_null(p_area); @@ -444,7 +444,7 @@ RID GodotPhysicsServer3D::body_create() { RID rid = body_owner.make_rid(body); body->set_self(rid); return rid; -}; +} void GodotPhysicsServer3D::body_set_space(RID p_body, RID p_space) { GodotBody3D *body = body_owner.get_or_null(p_body); @@ -462,7 +462,7 @@ void GodotPhysicsServer3D::body_set_space(RID p_body, RID p_space) { body->clear_constraint_map(); body->set_space(space); -}; +} RID GodotPhysicsServer3D::body_get_space(RID p_body) const { GodotBody3D *body = body_owner.get_or_null(p_body); @@ -473,21 +473,21 @@ RID GodotPhysicsServer3D::body_get_space(RID p_body) const { return RID(); } return space->get_self(); -}; +} void GodotPhysicsServer3D::body_set_mode(RID p_body, BodyMode p_mode) { GodotBody3D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL(body); body->set_mode(p_mode); -}; +} PhysicsServer3D::BodyMode GodotPhysicsServer3D::body_get_mode(RID p_body) const { GodotBody3D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL_V(body, BODY_MODE_STATIC); return body->get_mode(); -}; +} void GodotPhysicsServer3D::body_add_shape(RID p_body, RID p_shape, const Transform3D &p_transform, bool p_disabled) { GodotBody3D *body = body_owner.get_or_null(p_body); @@ -836,7 +836,7 @@ void GodotPhysicsServer3D::body_add_collision_exception(RID p_body, RID p_body_b body->add_exception(p_body_b); body->wakeup(); -}; +} void GodotPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_body_b) { GodotBody3D *body = body_owner.get_or_null(p_body); @@ -844,7 +844,7 @@ void GodotPhysicsServer3D::body_remove_collision_exception(RID p_body, RID p_bod body->remove_exception(p_body_b); body->wakeup(); -}; +} void GodotPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { GodotBody3D *body = body_owner.get_or_null(p_body); @@ -853,31 +853,31 @@ void GodotPhysicsServer3D::body_get_collision_exceptions(RID p_body, List<RID> * for (int i = 0; i < body->get_exceptions().size(); i++) { p_exceptions->push_back(body->get_exceptions()[i]); } -}; +} void GodotPhysicsServer3D::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { GodotBody3D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL(body); -}; +} real_t GodotPhysicsServer3D::body_get_contacts_reported_depth_threshold(RID p_body) const { GodotBody3D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL_V(body, 0); return 0; -}; +} void GodotPhysicsServer3D::body_set_omit_force_integration(RID p_body, bool p_omit) { GodotBody3D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL(body); body->set_omit_force_integration(p_omit); -}; +} bool GodotPhysicsServer3D::body_is_omitting_force_integration(RID p_body) const { GodotBody3D *body = body_owner.get_or_null(p_body); ERR_FAIL_NULL_V(body, false); return body->get_omit_force_integration(); -}; +} void GodotPhysicsServer3D::body_set_max_contacts_reported(RID p_body, int p_contacts) { GodotBody3D *body = body_owner.get_or_null(p_body); @@ -1770,4 +1770,4 @@ GodotPhysicsServer3D::GodotPhysicsServer3D(bool p_using_threads) { GodotBroadPhase3D::create_func = GodotBroadPhase3DBVH::_create; using_threads = p_using_threads; -}; +} diff --git a/modules/godot_physics_3d/godot_soft_body_3d.cpp b/modules/godot_physics_3d/godot_soft_body_3d.cpp index 7284076a47..e8be227d09 100644 --- a/modules/godot_physics_3d/godot_soft_body_3d.cpp +++ b/modules/godot_physics_3d/godot_soft_body_3d.cpp @@ -1121,7 +1121,7 @@ struct AABBQueryResult { _FORCE_INLINE_ bool operator()(void *p_data) { return result_callback(soft_body->get_node_index(p_data), userdata); - }; + } }; void GodotSoftBody3D::query_aabb(const AABB &p_aabb, GodotSoftBody3D::QueryResultCallback p_result_callback, void *p_userdata) { @@ -1140,7 +1140,7 @@ struct RayQueryResult { _FORCE_INLINE_ bool operator()(void *p_data) { return result_callback(soft_body->get_face_index(p_data), userdata); - }; + } }; void GodotSoftBody3D::query_ray(const Vector3 &p_from, const Vector3 &p_to, GodotSoftBody3D::QueryResultCallback p_result_callback, void *p_userdata) { diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h index 5e1da550d7..d24f00723f 100644 --- a/modules/mbedtls/crypto_mbedtls.h +++ b/modules/mbedtls/crypto_mbedtls.h @@ -57,7 +57,7 @@ public: virtual Error save(const String &p_path, bool p_public_only); virtual String save_to_string(bool p_public_only); virtual Error load_from_string(const String &p_string_key, bool p_public_only); - virtual bool is_public_only() const { return public_only; }; + virtual bool is_public_only() const { return public_only; } CryptoKeyMbedTLS() { mbedtls_pk_init(&pkey); diff --git a/modules/mobile_vr/mobile_vr_interface.cpp b/modules/mobile_vr/mobile_vr_interface.cpp index f27281866a..e5f1a940ec 100644 --- a/modules/mobile_vr/mobile_vr_interface.cpp +++ b/modules/mobile_vr/mobile_vr_interface.cpp @@ -37,11 +37,11 @@ StringName MobileVRInterface::get_name() const { return "Native mobile"; -}; +} uint32_t MobileVRInterface::get_capabilities() const { return XRInterface::XR_STEREO; -}; +} Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) { // Our magnetometer doesn't give us nice clean data. @@ -98,7 +98,7 @@ Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) { }; return mag_scaled; -}; +} Basis MobileVRInterface::combine_acc_mag(const Vector3 &p_grav, const Vector3 &p_magneto) { // yup, stock standard cross product solution... @@ -117,7 +117,7 @@ Basis MobileVRInterface::combine_acc_mag(const Vector3 &p_grav, const Vector3 &p acc_mag_m3.rows[2] = magneto; return acc_mag_m3; -}; +} void MobileVRInterface::set_position_from_sensors() { _THREAD_SAFE_METHOD_ @@ -215,7 +215,7 @@ void MobileVRInterface::set_position_from_sensors() { head_transform.basis = orientation.orthonormalized(); last_ticks = ticks; -}; +} void MobileVRInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("set_eye_height", "eye_height"), &MobileVRInterface::set_eye_height); @@ -280,51 +280,51 @@ Rect2 MobileVRInterface::get_offset_rect() const { void MobileVRInterface::set_iod(const double p_iod) { intraocular_dist = p_iod; -}; +} double MobileVRInterface::get_iod() const { return intraocular_dist; -}; +} void MobileVRInterface::set_display_width(const double p_display_width) { display_width = p_display_width; -}; +} double MobileVRInterface::get_display_width() const { return display_width; -}; +} void MobileVRInterface::set_display_to_lens(const double p_display_to_lens) { display_to_lens = p_display_to_lens; -}; +} double MobileVRInterface::get_display_to_lens() const { return display_to_lens; -}; +} void MobileVRInterface::set_oversample(const double p_oversample) { oversample = p_oversample; -}; +} double MobileVRInterface::get_oversample() const { return oversample; -}; +} void MobileVRInterface::set_k1(const double p_k1) { k1 = p_k1; -}; +} double MobileVRInterface::get_k1() const { return k1; -}; +} void MobileVRInterface::set_k2(const double p_k2) { k2 = p_k2; -}; +} double MobileVRInterface::get_k2() const { return k2; -}; +} float MobileVRInterface::get_vrs_min_radius() const { return xr_vrs.get_vrs_min_radius(); @@ -345,7 +345,7 @@ void MobileVRInterface::set_vrs_strength(float p_vrs_strength) { uint32_t MobileVRInterface::get_view_count() { // needs stereo... return 2; -}; +} XRInterface::TrackingStatus MobileVRInterface::get_tracking_status() const { return tracking_state; @@ -353,7 +353,7 @@ XRInterface::TrackingStatus MobileVRInterface::get_tracking_status() const { bool MobileVRInterface::is_initialized() const { return (initialized); -}; +} bool MobileVRInterface::initialize() { XRServer *xr_server = XRServer::get_singleton(); @@ -387,7 +387,7 @@ bool MobileVRInterface::initialize() { }; return true; -}; +} void MobileVRInterface::uninitialize() { if (initialized) { @@ -408,7 +408,7 @@ void MobileVRInterface::uninitialize() { initialized = false; }; -}; +} Dictionary MobileVRInterface::get_system_info() { Dictionary dict; @@ -442,7 +442,7 @@ Size2 MobileVRInterface::get_render_target_size() { target_size.y *= oversample; return target_size; -}; +} Transform3D MobileVRInterface::get_camera_transform() { _THREAD_SAFE_METHOD_ @@ -463,7 +463,7 @@ Transform3D MobileVRInterface::get_camera_transform() { } return transform_for_eye; -}; +} Transform3D MobileVRInterface::get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) { _THREAD_SAFE_METHOD_ @@ -497,7 +497,7 @@ Transform3D MobileVRInterface::get_transform_for_view(uint32_t p_view, const Tra }; return transform_for_eye; -}; +} Projection MobileVRInterface::get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) { _THREAD_SAFE_METHOD_ @@ -508,7 +508,7 @@ Projection MobileVRInterface::get_projection_for_view(uint32_t p_view, double p_ eye.set_for_hmd(p_view + 1, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far); return eye; -}; +} Vector<BlitToScreen> MobileVRInterface::post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) { _THREAD_SAFE_METHOD_ @@ -571,7 +571,7 @@ void MobileVRInterface::process() { head->set_pose("default", head_transform, Vector3(), Vector3(), tracking_confidence); } }; -}; +} RID MobileVRInterface::get_vrs_texture() { PackedVector2Array eye_foci; @@ -597,4 +597,4 @@ MobileVRInterface::~MobileVRInterface() { if (is_initialized()) { uninitialize(); }; -}; +} diff --git a/modules/mobile_vr/mobile_vr_interface.h b/modules/mobile_vr/mobile_vr_interface.h index 490b1c393c..d054ef14b3 100644 --- a/modules/mobile_vr/mobile_vr_interface.h +++ b/modules/mobile_vr/mobile_vr_interface.h @@ -97,19 +97,19 @@ private: float floor_decimals(const float p_value, const float p_decimals) { float power_of_10 = pow(10.0f, p_decimals); return floor(p_value * power_of_10) / power_of_10; - }; + } Vector3 floor_decimals(const Vector3 &p_vector, const float p_decimals) { return Vector3(floor_decimals(p_vector.x, p_decimals), floor_decimals(p_vector.y, p_decimals), floor_decimals(p_vector.z, p_decimals)); - }; + } Vector3 low_pass(const Vector3 &p_vector, const Vector3 &p_last_vector, const float p_factor) { return p_vector + (p_factor * (p_last_vector - p_vector)); - }; + } Vector3 scrub(const Vector3 &p_vector, const Vector3 &p_last_vector, const float p_decimals, const float p_factor) { return low_pass(floor_decimals(p_vector, p_decimals), p_last_vector, p_factor); - }; + } void set_position_from_sensors(); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 3d12994469..6ae9ce56c6 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -500,8 +500,8 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::debug_get_current_stack_info() } _recursion_flag_ = true; SCOPE_EXIT { - _recursion_flag_ = false; - }; + _recursion_flag_ = false; // clang-format off + }; // clang-format on if (!gdmono || !gdmono->is_runtime_initialized()) { return Vector<StackInfo>(); diff --git a/modules/multiplayer/scene_multiplayer.h b/modules/multiplayer/scene_multiplayer.h index 725cb9dbb6..5b668e1651 100644 --- a/modules/multiplayer/scene_multiplayer.h +++ b/modules/multiplayer/scene_multiplayer.h @@ -52,14 +52,14 @@ public: virtual void set_target_peer(int p_peer_id) override {} virtual int get_packet_peer() const override { return 0; } - virtual TransferMode get_packet_mode() const override { return TRANSFER_MODE_RELIABLE; }; + virtual TransferMode get_packet_mode() const override { return TRANSFER_MODE_RELIABLE; } virtual int get_packet_channel() const override { return 0; } virtual void disconnect_peer(int p_peer, bool p_force = false) override {} virtual bool is_server() const override { return true; } virtual void poll() override {} virtual void close() override {} virtual int get_unique_id() const override { return TARGET_PEER_SERVER; } - virtual ConnectionStatus get_connection_status() const override { return CONNECTION_CONNECTED; }; + virtual ConnectionStatus get_connection_status() const override { return CONNECTION_CONNECTED; } }; class SceneMultiplayer : public MultiplayerAPI { diff --git a/modules/navigation/2d/nav_mesh_generator_2d.cpp b/modules/navigation/2d/nav_mesh_generator_2d.cpp index 78983187c7..16cef0dd34 100644 --- a/modules/navigation/2d/nav_mesh_generator_2d.cpp +++ b/modules/navigation/2d/nav_mesh_generator_2d.cpp @@ -755,7 +755,7 @@ void NavMeshGenerator2D::generator_parse_source_geometry_data(Ref<NavigationPoly for (Node *E : parse_nodes) { generator_parse_geometry_node(p_navigation_mesh, p_source_geometry_data, E, recurse_children); } -}; +} static void generator_recursive_process_polytree_items(List<TPPLPoly> &p_tppl_in_polygon, const Clipper2Lib::PolyPathD *p_polypath_item) { using namespace Clipper2Lib; diff --git a/modules/navigation/3d/nav_mesh_generator_3d.cpp b/modules/navigation/3d/nav_mesh_generator_3d.cpp index e92a9d304b..ce1551e584 100644 --- a/modules/navigation/3d/nav_mesh_generator_3d.cpp +++ b/modules/navigation/3d/nav_mesh_generator_3d.cpp @@ -660,7 +660,7 @@ void NavMeshGenerator3D::generator_parse_source_geometry_data(const Ref<Navigati for (Node *parse_node : parse_nodes) { generator_parse_geometry_node(p_navigation_mesh, p_source_geometry_data, parse_node, recurse_children); } -}; +} void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<NavigationMesh> p_navigation_mesh, const Ref<NavigationMeshSourceGeometryData3D> &p_source_geometry_data) { if (p_navigation_mesh.is_null() || p_source_geometry_data.is_null()) { diff --git a/modules/navigation/nav_agent.cpp b/modules/navigation/nav_agent.cpp index 2dbe57eb4a..037b237328 100644 --- a/modules/navigation/nav_agent.cpp +++ b/modules/navigation/nav_agent.cpp @@ -308,7 +308,7 @@ void NavAgent::set_avoidance_priority(real_t p_priority) { rvo_agent_2d.avoidance_priority_ = avoidance_priority; } agent_dirty = true; -}; +} bool NavAgent::check_dirty() { const bool was_dirty = agent_dirty; diff --git a/modules/navigation/nav_agent.h b/modules/navigation/nav_agent.h index 18997803f2..e3671504f2 100644 --- a/modules/navigation/nav_agent.h +++ b/modules/navigation/nav_agent.h @@ -130,13 +130,13 @@ public: const Vector3 &get_velocity_forced() const { return velocity_forced; } void set_avoidance_layers(uint32_t p_layers); - uint32_t get_avoidance_layers() const { return avoidance_layers; }; + uint32_t get_avoidance_layers() const { return avoidance_layers; } void set_avoidance_mask(uint32_t p_mask); - uint32_t get_avoidance_mask() const { return avoidance_mask; }; + uint32_t get_avoidance_mask() const { return avoidance_mask; } void set_avoidance_priority(real_t p_priority); - real_t get_avoidance_priority() const { return avoidance_priority; }; + real_t get_avoidance_priority() const { return avoidance_priority; } void set_paused(bool p_paused); bool get_paused() const; diff --git a/modules/navigation/nav_link.cpp b/modules/navigation/nav_link.cpp index c693cc91c8..61c3b59fab 100644 --- a/modules/navigation/nav_link.cpp +++ b/modules/navigation/nav_link.cpp @@ -57,7 +57,7 @@ void NavLink::set_enabled(bool p_enabled) { // TODO: This should not require a full rebuild as the link has not really changed. link_dirty = true; -}; +} void NavLink::set_bidirectional(bool p_bidirectional) { if (bidirectional == p_bidirectional) { diff --git a/modules/navigation/nav_obstacle.h b/modules/navigation/nav_obstacle.h index e231e83836..a6aca9d637 100644 --- a/modules/navigation/nav_obstacle.h +++ b/modules/navigation/nav_obstacle.h @@ -92,7 +92,7 @@ public: bool is_map_changed(); void set_avoidance_layers(uint32_t p_layers); - uint32_t get_avoidance_layers() const { return avoidance_layers; }; + uint32_t get_avoidance_layers() const { return avoidance_layers; } void set_paused(bool p_paused); bool get_paused() const; diff --git a/modules/navigation/nav_region.cpp b/modules/navigation/nav_region.cpp index 2c91b80af2..679997b8e1 100644 --- a/modules/navigation/nav_region.cpp +++ b/modules/navigation/nav_region.cpp @@ -59,7 +59,7 @@ void NavRegion::set_enabled(bool p_enabled) { // TODO: This should not require a full rebuild as the region has not really changed. polygons_dirty = true; -}; +} void NavRegion::set_use_edge_connections(bool p_enabled) { if (use_edge_connections != p_enabled) { diff --git a/modules/navigation/nav_region.h b/modules/navigation/nav_region.h index c015802b92..d13f666e9a 100644 --- a/modules/navigation/nav_region.h +++ b/modules/navigation/nav_region.h @@ -94,7 +94,7 @@ public: gd::ClosestPointQueryResult get_closest_point_info(const Vector3 &p_point) const; Vector3 get_random_point(uint32_t p_navigation_layers, bool p_uniformly) const; - real_t get_surface_area() const { return surface_area; }; + real_t get_surface_area() const { return surface_area; } bool sync(); diff --git a/modules/noise/tests/test_noise_texture_2d.h b/modules/noise/tests/test_noise_texture_2d.h index 0d18d66e74..0cccb678ec 100644 --- a/modules/noise/tests/test_noise_texture_2d.h +++ b/modules/noise/tests/test_noise_texture_2d.h @@ -44,7 +44,7 @@ class NoiseTextureTester : public RefCounted { public: NoiseTextureTester(const NoiseTexture2D *const p_texture) : - texture{ p_texture } {}; + texture{ p_texture } {} Color compute_average_color(const Ref<Image> &p_noise_image) { Color r_avg_color{}; diff --git a/modules/noise/tests/test_noise_texture_3d.h b/modules/noise/tests/test_noise_texture_3d.h index 434cd20a08..78616d478e 100644 --- a/modules/noise/tests/test_noise_texture_3d.h +++ b/modules/noise/tests/test_noise_texture_3d.h @@ -44,7 +44,7 @@ class NoiseTexture3DTester : public RefCounted { public: NoiseTexture3DTester(const NoiseTexture3D *const p_texture) : - texture{ p_texture } {}; + texture{ p_texture } {} Color compute_average_color(const Ref<Image> &p_noise_image) { Color r_avg_color{}; diff --git a/modules/openxr/editor/openxr_action_editor.h b/modules/openxr/editor/openxr_action_editor.h index 11d1fd657a..b672fe7340 100644 --- a/modules/openxr/editor/openxr_action_editor.h +++ b/modules/openxr/editor/openxr_action_editor.h @@ -68,7 +68,7 @@ protected: void _do_set_action_type(OpenXRAction::ActionType p_action_type); public: - Ref<OpenXRAction> get_action() { return action; }; + Ref<OpenXRAction> get_action() { return action; } OpenXRActionEditor(Ref<OpenXRAction> p_action); }; diff --git a/modules/openxr/editor/openxr_action_set_editor.h b/modules/openxr/editor/openxr_action_set_editor.h index 3261f3a29e..21437aa631 100644 --- a/modules/openxr/editor/openxr_action_set_editor.h +++ b/modules/openxr/editor/openxr_action_set_editor.h @@ -87,7 +87,7 @@ protected: void _do_remove_action_editor(OpenXRActionEditor *p_action_editor); public: - Ref<OpenXRActionSet> get_action_set() { return action_set; }; + Ref<OpenXRActionSet> get_action_set() { return action_set; } void set_focus_on_entry(); void remove_all_actions(); diff --git a/modules/openxr/extensions/platform/openxr_opengl_extension.cpp b/modules/openxr/extensions/platform/openxr_opengl_extension.cpp index 07e26298bf..f75da49d87 100644 --- a/modules/openxr/extensions/platform/openxr_opengl_extension.cpp +++ b/modules/openxr/extensions/platform/openxr_opengl_extension.cpp @@ -64,7 +64,7 @@ HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() { #else request_extensions[XR_KHR_OPENGL_ENABLE_EXTENSION_NAME] = nullptr; #endif -#if defined(LINUXBSD_ENABLED) && defined(EGL_ENABLED) +#if defined(LINUXBSD_ENABLED) && defined(EGL_ENABLED) && defined(WAYLAND_ENABLED) request_extensions[XR_MNDX_EGL_ENABLE_EXTENSION_NAME] = &egl_extension_enabled; #endif @@ -135,7 +135,7 @@ XrGraphicsBindingOpenGLESAndroidKHR OpenXROpenGLExtension::graphics_binding_gl; #ifdef X11_ENABLED XrGraphicsBindingOpenGLXlibKHR OpenXROpenGLExtension::graphics_binding_gl; #endif -#ifdef EGL_ENABLED +#if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED) XrGraphicsBindingEGLMNDX OpenXROpenGLExtension::graphics_binding_egl; #endif #endif diff --git a/modules/openxr/extensions/platform/openxr_opengl_extension.h b/modules/openxr/extensions/platform/openxr_opengl_extension.h index beb68e47e3..f4a73c667b 100644 --- a/modules/openxr/extensions/platform/openxr_opengl_extension.h +++ b/modules/openxr/extensions/platform/openxr_opengl_extension.h @@ -68,7 +68,7 @@ private: #ifdef X11_ENABLED static XrGraphicsBindingOpenGLXlibKHR graphics_binding_gl; #endif -#ifdef EGL_ENABLED +#if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED) static XrGraphicsBindingEGLMNDX graphics_binding_egl; bool egl_extension_enabled = false; diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index c67be5a2b3..715d24cfd9 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -1294,7 +1294,7 @@ bool OpenXRAPI::create_main_swapchains(Size2i p_size) { } return true; -}; +} void OpenXRAPI::destroy_session() { // TODO need to figure out if we're still rendering our current frame @@ -2353,7 +2353,7 @@ void OpenXRAPI::post_draw_viewport(RID p_render_target) { for (OpenXRExtensionWrapper *wrapper : registered_extension_wrappers) { wrapper->on_post_draw_viewport(p_render_target); } -}; +} void OpenXRAPI::end_frame() { XrResult result; diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h index 0d1e4eb414..ecffce1816 100644 --- a/modules/openxr/openxr_api.h +++ b/modules/openxr/openxr_api.h @@ -396,12 +396,12 @@ private: } public: - XrInstance get_instance() const { return instance; }; - XrSystemId get_system_id() const { return system_id; }; - XrSession get_session() const { return session; }; - OpenXRGraphicsExtensionWrapper *get_graphics_extension() const { return graphics_extension; }; - String get_runtime_name() const { return runtime_name; }; - String get_runtime_version() const { return runtime_version; }; + XrInstance get_instance() const { return instance; } + XrSystemId get_system_id() const { return system_id; } + XrSession get_session() const { return session; } + OpenXRGraphicsExtensionWrapper *get_graphics_extension() const { return graphics_extension; } + String get_runtime_name() const { return runtime_name; } + String get_runtime_version() const { return runtime_version; } // helper method to convert an XrPosef to a Transform3D Transform3D transform_from_pose(const XrPosef &p_pose); diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp index 500a58acc3..8e0c672e58 100644 --- a/modules/openxr/openxr_interface.cpp +++ b/modules/openxr/openxr_interface.cpp @@ -160,11 +160,11 @@ void OpenXRInterface::_bind_methods() { StringName OpenXRInterface::get_name() const { return StringName("OpenXR"); -}; +} uint32_t OpenXRInterface::get_capabilities() const { return XRInterface::XR_VR + XRInterface::XR_STEREO; -}; +} PackedStringArray OpenXRInterface::get_suggested_tracker_names() const { // These are hardcoded in OpenXR, note that they will only be available if added to our action map @@ -611,7 +611,7 @@ bool OpenXRInterface::initialize_on_startup() const { bool OpenXRInterface::is_initialized() const { return initialized; -}; +} bool OpenXRInterface::initialize() { XRServer *xr_server = XRServer::get_singleton(); diff --git a/modules/raycast/raycast_occlusion_cull.cpp b/modules/raycast/raycast_occlusion_cull.cpp index 54dc040583..634c370b05 100644 --- a/modules/raycast/raycast_occlusion_cull.cpp +++ b/modules/raycast/raycast_occlusion_cull.cpp @@ -140,7 +140,7 @@ void RaycastOcclusionCull::RaycastHZBuffer::_generate_camera_rays(const CameraRa Vector3 dir; if (p_data->camera_orthogonal) { - dir = -p_data->camera_dir; + dir = p_data->camera_dir; tile.ray.org_x[j] = pixel_pos.x - dir.x * p_data->z_near; tile.ray.org_y[j] = pixel_pos.y - dir.y * p_data->z_near; tile.ray.org_z[j] = pixel_pos.z - dir.z * p_data->z_near; diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index ce95622f09..d30b2aae19 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -156,11 +156,11 @@ bool TextServerFallback::_has(const RID &p_rid) { String TextServerFallback::_get_support_data_filename() const { return ""; -}; +} String TextServerFallback::_get_support_data_info() const { return "Not supported"; -}; +} bool TextServerFallback::_load_support_data(const String &p_filename) { return false; // No extra data used. @@ -4728,7 +4728,7 @@ void TextServerFallback::_update_settings() { TextServerFallback::TextServerFallback() { _insert_feature_sets(); ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &TextServerFallback::_update_settings)); -}; +} void TextServerFallback::_cleanup() { for (const KeyValue<SystemFontKey, SystemFontCache> &E : system_fonts) { @@ -4747,4 +4747,4 @@ TextServerFallback::~TextServerFallback() { FT_Done_FreeType(ft_library); } #endif -}; +} diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 2725a61a82..f7c6ea899f 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -645,7 +645,7 @@ VideoStreamPlaybackTheora::~VideoStreamPlaybackTheora() { memdelete(thread_sem); #endif clear(); -}; +} void VideoStreamTheora::_bind_methods() {} diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp index 26256a4e30..19df397002 100644 --- a/modules/webrtc/webrtc_peer_connection_js.cpp +++ b/modules/webrtc/webrtc_peer_connection_js.cpp @@ -150,5 +150,5 @@ WebRTCPeerConnectionJS::~WebRTCPeerConnectionJS() { godot_js_rtc_pc_destroy(_js_id); _js_id = 0; } -}; +} #endif diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h index fe0bc594e6..89dc4fa36e 100644 --- a/modules/websocket/emws_peer.h +++ b/modules/websocket/emws_peer.h @@ -84,7 +84,7 @@ public: virtual int get_available_packet_count() const override; virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; - virtual int get_max_packet_size() const override { return packet_buffer.size(); }; + virtual int get_max_packet_size() const override { return packet_buffer.size(); } // WebSocketPeer virtual Error send(const uint8_t *p_buffer, int p_buffer_size, WriteMode p_mode) override; diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index fb01da7ce2..c4fe18630c 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -127,7 +127,7 @@ public: virtual int get_available_packet_count() const override; virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override; - virtual int get_max_packet_size() const override { return packet_buffer.size(); }; + virtual int get_max_packet_size() const override { return packet_buffer.size(); } // WebSocketPeer virtual Error send(const uint8_t *p_buffer, int p_buffer_size, WriteMode p_mode) override; diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index 352d495dd4..f45135a611 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -271,19 +271,19 @@ void WebXRInterfaceJS::_set_environment_blend_mode(String p_blend_mode_string) { StringName WebXRInterfaceJS::get_name() const { return "WebXR"; -}; +} uint32_t WebXRInterfaceJS::get_capabilities() const { return XRInterface::XR_STEREO | XRInterface::XR_MONO | XRInterface::XR_VR | XRInterface::XR_AR; -}; +} uint32_t WebXRInterfaceJS::get_view_count() { return godot_webxr_get_view_count(); -}; +} bool WebXRInterfaceJS::is_initialized() const { return (initialized); -}; +} bool WebXRInterfaceJS::initialize() { XRServer *xr_server = XRServer::get_singleton(); @@ -333,7 +333,7 @@ bool WebXRInterfaceJS::initialize() { }; return true; -}; +} void WebXRInterfaceJS::uninitialize() { if (initialized) { @@ -378,7 +378,7 @@ void WebXRInterfaceJS::uninitialize() { environment_blend_mode = XRInterface::XR_ENV_BLEND_MODE_OPAQUE; initialized = false; }; -}; +} Dictionary WebXRInterfaceJS::get_system_info() { Dictionary dict; @@ -427,7 +427,7 @@ Size2 WebXRInterfaceJS::get_render_target_size() { render_targetsize.height = (float)js_size[1]; return render_targetsize; -}; +} Transform3D WebXRInterfaceJS::get_camera_transform() { Transform3D camera_transform; @@ -445,7 +445,7 @@ Transform3D WebXRInterfaceJS::get_camera_transform() { } return camera_transform; -}; +} Transform3D WebXRInterfaceJS::get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) { XRServer *xr_server = XRServer::get_singleton(); @@ -464,7 +464,7 @@ Transform3D WebXRInterfaceJS::get_transform_for_view(uint32_t p_view, const Tran transform_for_view.origin *= world_scale; return p_cam_transform * xr_server->get_reference_frame() * transform_for_view; -}; +} Projection WebXRInterfaceJS::get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) { Projection view; @@ -527,7 +527,7 @@ Vector<BlitToScreen> WebXRInterfaceJS::post_draw_viewport(RID p_render_target, c texture_storage->render_target_set_reattach_textures(p_render_target, false); return blit_to_screen; -}; +} RID WebXRInterfaceJS::_get_color_texture() { unsigned int texture_id = godot_webxr_get_color_texture(); @@ -608,7 +608,7 @@ void WebXRInterfaceJS::process() { _update_input_source(i); } }; -}; +} void WebXRInterfaceJS::_update_input_source(int p_input_source_id) { XRServer *xr_server = XRServer::get_singleton(); @@ -871,13 +871,13 @@ WebXRInterfaceJS::WebXRInterfaceJS() { initialized = false; session_mode = "inline"; requested_reference_space_types = "local"; -}; +} WebXRInterfaceJS::~WebXRInterfaceJS() { // and make sure we cleanup if we haven't already if (initialized) { uninitialize(); }; -}; +} #endif // WEB_ENABLED diff --git a/platform/android/detect.py b/platform/android/detect.py index 937bdbaa07..4bc7e9474b 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -96,6 +96,15 @@ def install_ndk_if_needed(env: "SConsEnvironment"): env["ANDROID_NDK_ROOT"] = get_android_ndk_root(env) +def detect_swappy(): + archs = ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"] + has_swappy = True + for arch in archs: + if not os.path.isfile("thirdparty/swappy-frame-pacing/" + arch + "/libswappy_static.a"): + has_swappy = False + return has_swappy + + def configure(env: "SConsEnvironment"): # Validate arch. supported_arches = ["x86_32", "x86_64", "arm32", "arm64"] @@ -170,19 +179,42 @@ def configure(env: "SConsEnvironment"): CCFLAGS=("-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden".split()) ) + has_swappy = detect_swappy() + if not has_swappy: + print_warning( + "Swappy Frame Pacing not detected! It is strongly recommended you download it from https://github.com/darksylinc/godot-swappy/releases and extract it so that the following files can be found:\n" + + " thirdparty/swappy-frame-pacing/arm64-v8a/libswappy_static.a\n" + + " thirdparty/swappy-frame-pacing/armeabi-v7a/libswappy_static.a\n" + + " thirdparty/swappy-frame-pacing/x86/libswappy_static.a\n" + + " thirdparty/swappy-frame-pacing/x86_64/libswappy_static.a\n" + + "Without Swappy, Godot apps on Android will inevitable suffer stutter and struggle to keep consistent 30/60/90/120 fps. Though Swappy cannot guarantee your app will be stutter-free, not having Swappy will guarantee there will be stutter even on the best phones and the most simple of scenes." + ) + if env["swappy"]: + print_error("Use build option `swappy=no` to ignore missing Swappy dependency and build without it.") + sys.exit(255) + if get_min_sdk_version(env["ndk_platform"]) >= 24: env.Append(CPPDEFINES=[("_FILE_OFFSET_BITS", 64)]) if env["arch"] == "x86_32": # The NDK adds this if targeting API < 24, so we can drop it when Godot targets it at least env.Append(CCFLAGS=["-mstackrealign"]) + if has_swappy: + env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/x86"]) + elif env["arch"] == "x86_64": + if has_swappy: + env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/x86_64"]) elif env["arch"] == "arm32": env.Append(CCFLAGS="-march=armv7-a -mfloat-abi=softfp".split()) env.Append(CPPDEFINES=["__ARM_ARCH_7__", "__ARM_ARCH_7A__"]) env.Append(CPPDEFINES=["__ARM_NEON__"]) + if has_swappy: + env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/armeabi-v7a"]) elif env["arch"] == "arm64": env.Append(CCFLAGS=["-mfix-cortex-a53-835769"]) env.Append(CPPDEFINES=["__ARM_ARCH_8A__"]) + if has_swappy: + env.Append(LIBPATH=["../../thirdparty/swappy-frame-pacing/arm64-v8a"]) env.Append(CCFLAGS=["-ffp-contract=off"]) @@ -197,6 +229,9 @@ def configure(env: "SConsEnvironment"): if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"]) + if has_swappy: + env.Append(CPPDEFINES=["SWAPPY_FRAME_PACING_ENABLED"]) + env.Append(LIBS=["swappy_static"]) if not env["use_volk"]: env.Append(LIBS=["vulkan"]) diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index c269f4d167..f5032eaa40 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -71,7 +71,7 @@ bool DisplayServerAndroid::has_feature(Feature p_feature) const { case FEATURE_MOUSE: //case FEATURE_MOUSE_WARP: //case FEATURE_NATIVE_DIALOG: - //case FEATURE_NATIVE_DIALOG_INPUT: + case FEATURE_NATIVE_DIALOG_INPUT: //case FEATURE_NATIVE_DIALOG_FILE: //case FEATURE_NATIVE_ICON: //case FEATURE_WINDOW_TRANSPARENCY: @@ -176,6 +176,19 @@ bool DisplayServerAndroid::clipboard_has() const { } } +Error DisplayServerAndroid::dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) { + GodotJavaWrapper *godot_java = OS_Android::get_singleton()->get_godot_java(); + ERR_FAIL_NULL_V(godot_java, FAILED); + input_dialog_callback = p_callback; + return godot_java->show_input_dialog(p_title, p_description, p_partial); +} + +void DisplayServerAndroid::emit_input_dialog_callback(String p_text) { + if (input_dialog_callback.is_valid()) { + input_dialog_callback.call_deferred(p_text); + } +} + TypedArray<Rect2> DisplayServerAndroid::get_display_cutouts() const { GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java(); ERR_FAIL_NULL_V(godot_io_java, Array()); @@ -216,6 +229,14 @@ DisplayServer::ScreenOrientation DisplayServerAndroid::screen_get_orientation(in return (ScreenOrientation)orientation; } +int DisplayServerAndroid::screen_get_internal_current_rotation(int p_screen) const { + GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java(); + ERR_FAIL_NULL_V(godot_io_java, 0); + + const int rotation = godot_io_java->get_internal_current_screen_rotation(); + return rotation; +} + int DisplayServerAndroid::get_screen_count() const { return 1; } diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h index 65c6a53446..0b8b4dd6e8 100644 --- a/platform/android/display_server_android.h +++ b/platform/android/display_server_android.h @@ -87,6 +87,8 @@ class DisplayServerAndroid : public DisplayServer { Callable system_theme_changed; + Callable input_dialog_callback; + void _window_callback(const Callable &p_callable, const Variant &p_arg, bool p_deferred = false) const; static void _dispatch_input_events(const Ref<InputEvent> &p_event); @@ -116,6 +118,9 @@ public: virtual String clipboard_get() const override; virtual bool clipboard_has() const override; + virtual Error dialog_input_text(String p_title, String p_description, String p_partial, const Callable &p_callback) override; + void emit_input_dialog_callback(String p_text); + virtual TypedArray<Rect2> get_display_cutouts() const override; virtual Rect2i get_display_safe_area() const override; @@ -124,6 +129,7 @@ public: virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW) override; virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const override; + virtual int screen_get_internal_current_rotation(int p_screen) const override; virtual int get_screen_count() const override; virtual int get_primary_screen() const override; diff --git a/platform/android/java/lib/res/values/dimens.xml b/platform/android/java/lib/res/values/dimens.xml index 9034dbbcc1..287d1c8920 100644 --- a/platform/android/java/lib/res/values/dimens.xml +++ b/platform/android/java/lib/res/values/dimens.xml @@ -1,4 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="text_edit_height">48dp</dimen> + <dimen name="input_dialog_padding_horizontal">10dp</dimen> + <dimen name="input_dialog_padding_vertical">5dp</dimen> </resources> diff --git a/platform/android/java/lib/res/values/strings.xml b/platform/android/java/lib/res/values/strings.xml index 03752e092e..e44addadd0 100644 --- a/platform/android/java/lib/res/values/strings.xml +++ b/platform/android/java/lib/res/values/strings.xml @@ -55,4 +55,7 @@ <string name="kilobytes_per_second">%1$s KB/s</string> <string name="time_remaining">Time remaining: %1$s</string> <string name="time_remaining_notification">%1$s left</string> + + <!-- Labels for the dialog action buttons --> + <string name="dialog_ok">OK</string> </resources> diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt index 61c027d3ee..9ad1e0b740 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.kt @@ -44,6 +44,7 @@ import android.os.* import android.util.Log import android.util.TypedValue import android.view.* +import android.widget.EditText import android.widget.FrameLayout import androidx.annotation.Keep import androidx.annotation.StringRes @@ -81,6 +82,7 @@ import java.util.* import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference + /** * Core component used to interface with the native layer of the engine. * @@ -777,7 +779,7 @@ class Godot(private val context: Context) { val builder = AlertDialog.Builder(activity) builder.setMessage(message).setTitle(title) builder.setPositiveButton( - "OK" + R.string.dialog_ok ) { dialog: DialogInterface, id: Int -> okCallback?.run() dialog.cancel() @@ -889,6 +891,31 @@ class Godot(private val context: Context) { } /** + * Popup a dialog to input text. + */ + @Keep + private fun showInputDialog(title: String, message: String, existingText: String) { + val activity: Activity = getActivity() ?: return + val inputField = EditText(activity) + val paddingHorizontal = activity.resources.getDimensionPixelSize(R.dimen.input_dialog_padding_horizontal) + val paddingVertical = activity.resources.getDimensionPixelSize(R.dimen.input_dialog_padding_vertical) + inputField.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical) + inputField.setText(existingText) + runOnUiThread { + val builder = AlertDialog.Builder(activity) + builder.setMessage(message).setTitle(title).setView(inputField) + builder.setPositiveButton(R.string.dialog_ok) { + dialog: DialogInterface, id: Int -> + GodotLib.inputDialogCallback(inputField.text.toString()) + dialog.dismiss() + } + val dialog = builder.create() + dialog.show() + } + } + + + /** * Destroys the Godot Engine and kill the process it's running in. */ @JvmOverloads diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java index f060c7aaff..5543745444 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java @@ -47,6 +47,7 @@ import android.util.DisplayMetrics; import android.util.Log; import android.view.Display; import android.view.DisplayCutout; +import android.view.Surface; import android.view.WindowInsets; import androidx.core.content.FileProvider; @@ -295,6 +296,28 @@ public class GodotIO { } } + /** + This function is used by DisplayServer::screen_get_internal_current_rotation (C++) + and is used to implement a performance optimization in devices that do not offer + a HW rotator. + @return + Rotation in degrees, in multiples of 90° + */ + public int getInternalCurrentScreenRotation() { + int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); + + switch (rotation) { + case Surface.ROTATION_90: + return 90; + case Surface.ROTATION_180: + return 180; + case Surface.ROTATION_270: + return 270; + default: + return 0; + } + } + public void setEdit(GodotEditText _edit) { edit = _edit; } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index 295a4a6340..3c58e05dda 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -225,6 +225,11 @@ public class GodotLib { public static native void onNightModeChanged(); /** + * Invoked on the input dialog submitted. + */ + public static native void inputDialogCallback(String p_text); + + /** * Invoked on the GL thread to configure the height of the virtual keyboard. */ public static native void setVirtualKeyboardHeight(int p_height); diff --git a/platform/android/java_godot_io_wrapper.cpp b/platform/android/java_godot_io_wrapper.cpp index 623db39985..e58ef50a73 100644 --- a/platform/android/java_godot_io_wrapper.cpp +++ b/platform/android/java_godot_io_wrapper.cpp @@ -66,6 +66,7 @@ GodotIOJavaWrapper::GodotIOJavaWrapper(JNIEnv *p_env, jobject p_godot_io_instanc _has_hardware_keyboard = p_env->GetMethodID(cls, "hasHardwareKeyboard", "()Z"); _set_screen_orientation = p_env->GetMethodID(cls, "setScreenOrientation", "(I)V"); _get_screen_orientation = p_env->GetMethodID(cls, "getScreenOrientation", "()I"); + _get_internal_current_screen_rotation = p_env->GetMethodID(cls, "getInternalCurrentScreenRotation", "()I"); _get_system_dir = p_env->GetMethodID(cls, "getSystemDir", "(IZ)Ljava/lang/String;"); } } @@ -267,6 +268,16 @@ int GodotIOJavaWrapper::get_screen_orientation() { } } +int GodotIOJavaWrapper::get_internal_current_screen_rotation() { + if (_get_internal_current_screen_rotation) { + JNIEnv *env = get_jni_env(); + ERR_FAIL_NULL_V(env, 0); + return env->CallIntMethod(godot_io_instance, _get_internal_current_screen_rotation); + } else { + return 0; + } +} + String GodotIOJavaWrapper::get_system_dir(int p_dir, bool p_shared_storage) { if (_get_system_dir) { JNIEnv *env = get_jni_env(); diff --git a/platform/android/java_godot_io_wrapper.h b/platform/android/java_godot_io_wrapper.h index 0a372641cb..903bdce4be 100644 --- a/platform/android/java_godot_io_wrapper.h +++ b/platform/android/java_godot_io_wrapper.h @@ -61,6 +61,7 @@ private: jmethodID _has_hardware_keyboard = 0; jmethodID _set_screen_orientation = 0; jmethodID _get_screen_orientation = 0; + jmethodID _get_internal_current_screen_rotation = 0; jmethodID _get_system_dir = 0; public: @@ -88,6 +89,7 @@ public: void set_vk_height(int p_height); void set_screen_orientation(int p_orient); int get_screen_orientation(); + int get_internal_current_screen_rotation(); String get_system_dir(int p_dir, bool p_shared_storage); }; diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index 1a256959cd..997534ada3 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -540,6 +540,14 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onNightModeChanged(JN } } +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_inputDialogCallback(JNIEnv *env, jclass clazz, jstring p_text) { + DisplayServerAndroid *ds = (DisplayServerAndroid *)DisplayServer::get_singleton(); + if (ds) { + String text = jstring_to_string(p_text, env); + ds->emit_input_dialog_callback(text); + } +} + JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result) { String permission = jstring_to_string(p_permission, env); if (permission == "android.permission.RECORD_AUDIO" && p_result) { diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h index 2165ce264b..65ba1b2953 100644 --- a/platform/android/java_godot_lib_jni.h +++ b/platform/android/java_godot_lib_jni.h @@ -67,6 +67,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv * JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jclass clazz, jint p_height); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_requestPermissionResult(JNIEnv *env, jclass clazz, jstring p_permission, jboolean p_result); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onNightModeChanged(JNIEnv *env, jclass clazz); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_inputDialogCallback(JNIEnv *env, jclass clazz, jstring p_text); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererResumed(JNIEnv *env, jclass clazz); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_onRendererPaused(JNIEnv *env, jclass clazz); JNIEXPORT jboolean JNICALL Java_org_godotengine_godot_GodotLib_shouldDispatchInputToRenderThread(JNIEnv *env, jclass clazz); diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index d3b30e4589..aae6ff23da 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -67,6 +67,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_activity, jobject p_ _get_clipboard = p_env->GetMethodID(godot_class, "getClipboard", "()Ljava/lang/String;"); _set_clipboard = p_env->GetMethodID(godot_class, "setClipboard", "(Ljava/lang/String;)V"); _has_clipboard = p_env->GetMethodID(godot_class, "hasClipboard", "()Z"); + _show_input_dialog = p_env->GetMethodID(godot_class, "showInputDialog", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); _request_permission = p_env->GetMethodID(godot_class, "requestPermission", "(Ljava/lang/String;)Z"); _request_permissions = p_env->GetMethodID(godot_class, "requestPermissions", "()Z"); _get_granted_permissions = p_env->GetMethodID(godot_class, "getGrantedPermissions", "()[Ljava/lang/String;"); @@ -268,6 +269,23 @@ bool GodotJavaWrapper::has_clipboard() { } } +Error GodotJavaWrapper::show_input_dialog(const String &p_title, const String &p_message, const String &p_existing_text) { + if (_show_input_dialog) { + JNIEnv *env = get_jni_env(); + ERR_FAIL_NULL_V(env, ERR_UNCONFIGURED); + jstring jStrTitle = env->NewStringUTF(p_title.utf8().get_data()); + jstring jStrMessage = env->NewStringUTF(p_message.utf8().get_data()); + jstring jStrExistingText = env->NewStringUTF(p_existing_text.utf8().get_data()); + env->CallVoidMethod(godot_instance, _show_input_dialog, jStrTitle, jStrMessage, jStrExistingText); + env->DeleteLocalRef(jStrTitle); + env->DeleteLocalRef(jStrMessage); + env->DeleteLocalRef(jStrExistingText); + return OK; + } else { + return ERR_UNCONFIGURED; + } +} + bool GodotJavaWrapper::request_permission(const String &p_name) { if (_request_permission) { JNIEnv *env = get_jni_env(); diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h index 51d7f98541..4fa3098397 100644 --- a/platform/android/java_godot_wrapper.h +++ b/platform/android/java_godot_wrapper.h @@ -58,6 +58,7 @@ private: jmethodID _get_clipboard = nullptr; jmethodID _set_clipboard = nullptr; jmethodID _has_clipboard = nullptr; + jmethodID _show_input_dialog = nullptr; jmethodID _request_permission = nullptr; jmethodID _request_permissions = nullptr; jmethodID _get_granted_permissions = nullptr; @@ -103,6 +104,7 @@ public: void set_clipboard(const String &p_text); bool has_has_clipboard(); bool has_clipboard(); + Error show_input_dialog(const String &p_title, const String &p_message, const String &p_existing_text); bool request_permission(const String &p_name); bool request_permissions(); Vector<String> get_granted_permissions() const; diff --git a/platform/ios/ios.mm b/platform/ios/ios.mm index 6943de5ac8..26067b94bb 100644 --- a/platform/ios/ios.mm +++ b/platform/ios/ios.mm @@ -42,7 +42,7 @@ void iOS::_bind_methods() { ClassDB::bind_method(D_METHOD("supports_haptic_engine"), &iOS::supports_haptic_engine); ClassDB::bind_method(D_METHOD("start_haptic_engine"), &iOS::start_haptic_engine); ClassDB::bind_method(D_METHOD("stop_haptic_engine"), &iOS::stop_haptic_engine); -}; +} bool iOS::supports_haptic_engine() { if (@available(iOS 13, *)) { diff --git a/platform/linuxbsd/crash_handler_linuxbsd.h b/platform/linuxbsd/crash_handler_linuxbsd.h index 684f62b249..a14b93e11b 100644 --- a/platform/linuxbsd/crash_handler_linuxbsd.h +++ b/platform/linuxbsd/crash_handler_linuxbsd.h @@ -38,7 +38,7 @@ public: void initialize(); void disable(); - bool is_disabled() const { return disabled; }; + bool is_disabled() const { return disabled; } CrashHandler(); ~CrashHandler(); diff --git a/platform/linuxbsd/export/export_plugin.h b/platform/linuxbsd/export/export_plugin.h index 9e016bd4c3..c8842b3a17 100644 --- a/platform/linuxbsd/export/export_plugin.h +++ b/platform/linuxbsd/export/export_plugin.h @@ -55,7 +55,7 @@ class EditorExportPlatformLinuxBSD : public EditorExportPlatformPC { ssh_args = p_ssh_arg; cmd_args = p_cmd_args; wait = p_wait; - }; + } }; Ref<ImageTexture> run_icon; diff --git a/platform/macos/crash_handler_macos.h b/platform/macos/crash_handler_macos.h index f821283167..d52cb7234a 100644 --- a/platform/macos/crash_handler_macos.h +++ b/platform/macos/crash_handler_macos.h @@ -38,7 +38,7 @@ public: void initialize(); void disable(); - bool is_disabled() const { return disabled; }; + bool is_disabled() const { return disabled; } CrashHandler(); ~CrashHandler(); diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h index 4ded2f3301..ef8d1bb8ab 100644 --- a/platform/macos/export/export_plugin.h +++ b/platform/macos/export/export_plugin.h @@ -76,7 +76,7 @@ class EditorExportPlatformMacOS : public EditorExportPlatform { ssh_args = p_ssh_arg; cmd_args = p_cmd_args; wait = p_wait; - }; + } }; Ref<ImageTexture> run_icon; diff --git a/platform/windows/crash_handler_windows.h b/platform/windows/crash_handler_windows.h index a0a0b610d0..f47d9ec66e 100644 --- a/platform/windows/crash_handler_windows.h +++ b/platform/windows/crash_handler_windows.h @@ -51,7 +51,7 @@ public: void initialize(); void disable(); - bool is_disabled() const { return disabled; }; + bool is_disabled() const { return disabled; } CrashHandler(); ~CrashHandler(); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index b8a1ec29b6..07424a3b4c 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -316,8 +316,8 @@ public: } // IFileDialogEvents methods - HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog *) { return S_OK; }; - HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog *) { return S_OK; }; + HRESULT STDMETHODCALLTYPE OnFileOk(IFileDialog *) { return S_OK; } + HRESULT STDMETHODCALLTYPE OnFolderChange(IFileDialog *) { return S_OK; } HRESULT STDMETHODCALLTYPE OnFolderChanging(IFileDialog *p_pfd, IShellItem *p_item) { if (root.is_empty()) { @@ -336,11 +336,11 @@ public: return S_OK; } - HRESULT STDMETHODCALLTYPE OnHelp(IFileDialog *) { return S_OK; }; - HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog *) { return S_OK; }; - HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog *, IShellItem *, FDE_SHAREVIOLATION_RESPONSE *) { return S_OK; }; - HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog *pfd) { return S_OK; }; - HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog *, IShellItem *, FDE_OVERWRITE_RESPONSE *) { return S_OK; }; + HRESULT STDMETHODCALLTYPE OnHelp(IFileDialog *) { return S_OK; } + HRESULT STDMETHODCALLTYPE OnSelectionChange(IFileDialog *) { return S_OK; } + HRESULT STDMETHODCALLTYPE OnShareViolation(IFileDialog *, IShellItem *, FDE_SHAREVIOLATION_RESPONSE *) { return S_OK; } + HRESULT STDMETHODCALLTYPE OnTypeChange(IFileDialog *pfd) { return S_OK; } + HRESULT STDMETHODCALLTYPE OnOverwrite(IFileDialog *, IShellItem *, FDE_OVERWRITE_RESPONSE *) { return S_OK; } // IFileDialogControlEvents methods HRESULT STDMETHODCALLTYPE OnItemSelected(IFileDialogCustomize *p_pfdc, DWORD p_ctl_id, DWORD p_item_idx) { @@ -350,14 +350,14 @@ public: return S_OK; } - HRESULT STDMETHODCALLTYPE OnButtonClicked(IFileDialogCustomize *, DWORD) { return S_OK; }; + HRESULT STDMETHODCALLTYPE OnButtonClicked(IFileDialogCustomize *, DWORD) { return S_OK; } HRESULT STDMETHODCALLTYPE OnCheckButtonToggled(IFileDialogCustomize *p_pfdc, DWORD p_ctl_id, BOOL p_checked) { if (ctls.has(p_ctl_id)) { selected[ctls[p_ctl_id]] = (bool)p_checked; } return S_OK; } - HRESULT STDMETHODCALLTYPE OnControlActivating(IFileDialogCustomize *, DWORD) { return S_OK; }; + HRESULT STDMETHODCALLTYPE OnControlActivating(IFileDialogCustomize *, DWORD) { return S_OK; } Dictionary get_selected() { return selected; diff --git a/platform/windows/export/export_plugin.h b/platform/windows/export/export_plugin.h index 1972b36845..89db449424 100644 --- a/platform/windows/export/export_plugin.h +++ b/platform/windows/export/export_plugin.h @@ -59,7 +59,7 @@ class EditorExportPlatformWindows : public EditorExportPlatformPC { ssh_args = p_ssh_arg; cmd_args = p_cmd_args; wait = p_wait; - }; + } }; Ref<ImageTexture> run_icon; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index adc72a79e9..ce4ebb03f2 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1363,7 +1363,7 @@ public: locale = p_locale; n_sub = p_nsub; rtl = p_rtl; - }; + } virtual ~FallbackTextAnalysisSource() {} }; diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 7020d162fe..ebed1e84e6 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -115,11 +115,11 @@ void Camera2D::set_zoom(const Vector2 &p_zoom) { Point2 old_smoothed_camera_pos = smoothed_camera_pos; _update_scroll(); smoothed_camera_pos = old_smoothed_camera_pos; -}; +} Vector2 Camera2D::get_zoom() const { return zoom; -}; +} Transform2D Camera2D::get_camera_transform() { if (!get_tree()) { diff --git a/scene/2d/navigation_obstacle_2d.h b/scene/2d/navigation_obstacle_2d.h index 30328f7086..28c5f902e6 100644 --- a/scene/2d/navigation_obstacle_2d.h +++ b/scene/2d/navigation_obstacle_2d.h @@ -84,7 +84,7 @@ public: real_t get_radius() const { return radius; } void set_vertices(const Vector<Vector2> &p_vertices); - const Vector<Vector2> &get_vertices() const { return vertices; }; + const Vector<Vector2> &get_vertices() const { return vertices; } void set_avoidance_layers(uint32_t p_layers); uint32_t get_avoidance_layers() const; @@ -96,7 +96,7 @@ public: bool get_avoidance_layer_value(int p_layer_number) const; void set_velocity(const Vector2 p_velocity); - Vector2 get_velocity() const { return velocity; }; + Vector2 get_velocity() const { return velocity; } void _avoidance_done(Vector3 p_new_velocity); // Dummy diff --git a/scene/2d/tile_map_layer.cpp b/scene/2d/tile_map_layer.cpp index ebb03e4e73..f737e23126 100644 --- a/scene/2d/tile_map_layer.cpp +++ b/scene/2d/tile_map_layer.cpp @@ -946,7 +946,7 @@ void TileMapLayer::_physics_draw_cell_debug(const RID &p_canvas_item, const Vect rs->canvas_item_add_set_transform(p_canvas_item, Transform2D()); } } -}; +} #endif // DEBUG_ENABLED /////////////////////////////// Navigation ////////////////////////////////////// diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp index c70fa3ca2e..aafc2141af 100644 --- a/scene/3d/camera_3d.cpp +++ b/scene/3d/camera_3d.cpp @@ -377,7 +377,7 @@ void Camera3D::set_projection(ProjectionType p_mode) { RID Camera3D::get_camera() const { return camera; -}; +} void Camera3D::make_current() { current = true; @@ -423,7 +423,7 @@ bool Camera3D::is_current() const { Vector3 Camera3D::project_ray_normal(const Point2 &p_pos) const { Vector3 ray = project_local_ray_normal(p_pos); return get_camera_transform().basis.xform(ray).normalized(); -}; +} Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); @@ -441,7 +441,7 @@ Vector3 Camera3D::project_local_ray_normal(const Point2 &p_pos) const { } return ray; -}; +} Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { ERR_FAIL_COND_V_MSG(!is_inside_tree(), Vector3(), "Camera is not inside scene."); @@ -470,7 +470,7 @@ Vector3 Camera3D::project_ray_origin(const Point2 &p_pos) const { } else { return get_camera_transform().origin; }; -}; +} bool Camera3D::is_position_behind(const Vector3 &p_pos) const { Transform3D t = get_global_transform(); diff --git a/scene/3d/navigation_obstacle_3d.h b/scene/3d/navigation_obstacle_3d.h index e9a4669fa2..99288fc59e 100644 --- a/scene/3d/navigation_obstacle_3d.h +++ b/scene/3d/navigation_obstacle_3d.h @@ -95,7 +95,7 @@ public: real_t get_height() const { return height; } void set_vertices(const Vector<Vector3> &p_vertices); - const Vector<Vector3> &get_vertices() const { return vertices; }; + const Vector<Vector3> &get_vertices() const { return vertices; } void set_avoidance_layers(uint32_t p_layers); uint32_t get_avoidance_layers() const; @@ -107,7 +107,7 @@ public: bool get_use_3d_avoidance() const { return use_3d_avoidance; } void set_velocity(const Vector3 p_velocity); - Vector3 get_velocity() const { return velocity; }; + Vector3 get_velocity() const { return velocity; } void _avoidance_done(Vector3 p_new_velocity); // Dummy diff --git a/scene/3d/node_3d.h b/scene/3d/node_3d.h index 217ee28cf1..20288fad3a 100644 --- a/scene/3d/node_3d.h +++ b/scene/3d/node_3d.h @@ -233,8 +233,8 @@ public: #ifdef TOOLS_ENABLED virtual Transform3D get_global_gizmo_transform() const; virtual Transform3D get_local_gizmo_transform() const; - virtual void set_transform_gizmo_visible(bool p_enabled) { data.transform_gizmo_visible = p_enabled; }; - virtual bool is_transform_gizmo_visible() const { return data.transform_gizmo_visible; }; + virtual void set_transform_gizmo_visible(bool p_enabled) { data.transform_gizmo_visible = p_enabled; } + virtual bool is_transform_gizmo_visible() const { return data.transform_gizmo_visible; } #endif virtual void reparent(Node *p_parent, bool p_keep_global_transform = true) override; diff --git a/scene/3d/xr_nodes.cpp b/scene/3d/xr_nodes.cpp index 214c1f77ca..9869b241d3 100644 --- a/scene/3d/xr_nodes.cpp +++ b/scene/3d/xr_nodes.cpp @@ -89,7 +89,7 @@ PackedStringArray XRCamera3D::get_configuration_warnings() const { } return warnings; -}; +} Vector3 XRCamera3D::project_local_ray_normal(const Point2 &p_pos) const { // get our XRServer @@ -114,7 +114,7 @@ Vector3 XRCamera3D::project_local_ray_normal(const Point2 &p_pos) const { ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_near()).normalized(); return ray; -}; +} Point2 XRCamera3D::unproject_position(const Vector3 &p_pos) const { // get our XRServer @@ -144,7 +144,7 @@ Point2 XRCamera3D::unproject_position(const Vector3 &p_pos) const { res.y = (-p.normal.y * 0.5 + 0.5) * viewport_size.y; return res; -}; +} Vector3 XRCamera3D::project_position(const Point2 &p_point, real_t p_z_depth) const { // get our XRServer @@ -174,7 +174,7 @@ Vector3 XRCamera3D::project_position(const Point2 &p_point, real_t p_z_depth) co Vector3 p(point.x, point.y, -p_z_depth); return get_camera_transform().xform(p); -}; +} Vector<Plane> XRCamera3D::get_frustum() const { // get our XRServer @@ -193,7 +193,7 @@ Vector<Plane> XRCamera3D::get_frustum() const { // TODO Just use the first view for now, this is mostly for debugging so we may look into using our combined projection here. Projection cm = xr_interface->get_projection_for_view(0, viewport_size.aspect(), get_near(), get_far()); return cm.get_projection_planes(get_camera_transform()); -}; +} XRCamera3D::XRCamera3D() { XRServer *xr_server = XRServer::get_singleton(); @@ -240,7 +240,7 @@ void XRNode3D::_bind_methods() { ClassDB::bind_method(D_METHOD("trigger_haptic_pulse", "action_name", "frequency", "amplitude", "duration_sec", "delay_sec"), &XRNode3D::trigger_haptic_pulse); ADD_SIGNAL(MethodInfo("tracking_changed", PropertyInfo(Variant::BOOL, "tracking"))); -}; +} void XRNode3D::_validate_property(PropertyInfo &p_property) const { XRServer *xr_server = XRServer::get_singleton(); @@ -499,7 +499,7 @@ void XRController3D::_bind_methods() { ADD_SIGNAL(MethodInfo("input_float_changed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::FLOAT, "value"))); ADD_SIGNAL(MethodInfo("input_vector2_changed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::VECTOR2, "value"))); ADD_SIGNAL(MethodInfo("profile_changed", PropertyInfo(Variant::STRING, "role"))); -}; +} void XRController3D::_bind_tracker() { XRNode3D::_bind_tracker(); diff --git a/scene/debugger/scene_debugger.h b/scene/debugger/scene_debugger.h index 0c28ca2a0c..be2642a2ae 100644 --- a/scene/debugger/scene_debugger.h +++ b/scene/debugger/scene_debugger.h @@ -158,7 +158,7 @@ private: LiveEditor() { singleton = this; live_edit_root = NodePath("/root"); - }; + } static LiveEditor *singleton; diff --git a/scene/gui/color_mode.h b/scene/gui/color_mode.h index 94193ccf74..0abc90bb44 100644 --- a/scene/gui/color_mode.h +++ b/scene/gui/color_mode.h @@ -41,9 +41,9 @@ public: virtual String get_name() const = 0; - virtual int get_slider_count() const { return 3; }; + virtual int get_slider_count() const { return 3; } virtual float get_slider_step() const = 0; - virtual float get_spinbox_arrow_step() const { return get_slider_step(); }; + virtual float get_spinbox_arrow_step() const { return get_slider_step(); } virtual String get_slider_label(int idx) const = 0; virtual float get_slider_max(int idx) const = 0; virtual float get_slider_value(int idx) const = 0; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 5052deb65a..4b3007543b 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -120,11 +120,11 @@ void Control::_edit_set_state(const Dictionary &p_state) { void Control::_edit_set_position(const Point2 &p_position) { ERR_FAIL_COND_MSG(!Engine::get_singleton()->is_editor_hint(), "This function can only be used from editor plugins."); set_position(p_position, ControlEditorToolbar::get_singleton()->is_anchors_mode_enabled() && get_parent_control()); -}; +} Point2 Control::_edit_get_position() const { return get_position(); -}; +} void Control::_edit_set_scale(const Size2 &p_scale) { set_scale(p_scale); diff --git a/scene/gui/range.h b/scene/gui/range.h index b1c2446ded..710fed8645 100644 --- a/scene/gui/range.h +++ b/scene/gui/range.h @@ -64,7 +64,7 @@ class Range : public Control { protected: virtual void _value_changed(double p_value); - void _notify_shared_value_changed() { shared->emit_value_changed(); }; + void _notify_shared_value_changed() { shared->emit_value_changed(); } static void _bind_methods(); diff --git a/scene/gui/rich_text_effect.h b/scene/gui/rich_text_effect.h index 681f068fb2..94e1bd4f04 100644 --- a/scene/gui/rich_text_effect.h +++ b/scene/gui/rich_text_effect.h @@ -79,20 +79,20 @@ public: Color get_color() { return color; } void set_color(Color p_color) { color = p_color; } - uint32_t get_glyph_index() const { return glyph_index; }; - void set_glyph_index(uint32_t p_glyph_index) { glyph_index = p_glyph_index; }; + uint32_t get_glyph_index() const { return glyph_index; } + void set_glyph_index(uint32_t p_glyph_index) { glyph_index = p_glyph_index; } - uint16_t get_glyph_flags() const { return glyph_flags; }; - void set_glyph_flags(uint16_t p_glyph_flags) { glyph_flags = p_glyph_flags; }; + uint16_t get_glyph_flags() const { return glyph_flags; } + void set_glyph_flags(uint16_t p_glyph_flags) { glyph_flags = p_glyph_flags; } - uint8_t get_glyph_count() const { return glyph_count; }; - void set_glyph_count(uint8_t p_glyph_count) { glyph_count = p_glyph_count; }; + uint8_t get_glyph_count() const { return glyph_count; } + void set_glyph_count(uint8_t p_glyph_count) { glyph_count = p_glyph_count; } - int32_t get_relative_index() const { return relative_index; }; - void set_relative_index(int32_t p_relative_index) { relative_index = p_relative_index; }; + int32_t get_relative_index() const { return relative_index; } + void set_relative_index(int32_t p_relative_index) { relative_index = p_relative_index; } - RID get_font() const { return font; }; - void set_font(RID p_font) { font = p_font; }; + RID get_font() const { return font; } + void set_font(RID p_font) { font = p_font; } Dictionary get_environment() { return environment; } void set_environment(Dictionary p_environment) { environment = p_environment; } diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 1ac0e8b59f..312b538a99 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -461,7 +461,7 @@ void ScrollContainer::update_scrollbars() { void ScrollContainer::_scroll_moved(float) { queue_sort(); -}; +} void ScrollContainer::set_h_scroll(int p_pos) { h_scroll->set_value(p_pos); @@ -625,7 +625,7 @@ void ScrollContainer::_bind_methods() { BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, panel_style, "panel"); GLOBAL_DEF("gui/common/default_scroll_deadzone", 0); -}; +} ScrollContainer::ScrollContainer() { h_scroll = memnew(HScrollBar); @@ -641,4 +641,4 @@ ScrollContainer::ScrollContainer() { deadzone = GLOBAL_GET("gui/common/default_scroll_deadzone"); set_clip_contents(true); -}; +} diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 94b105d486..e0d552848d 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -693,9 +693,9 @@ protected: void _set_symbol_lookup_word(const String &p_symbol); // Theme items. - virtual Color _get_brace_mismatch_color() const { return Color(); }; - virtual Color _get_code_folding_color() const { return Color(); }; - virtual Ref<Texture2D> _get_folded_eol_icon() const { return Ref<Texture2D>(); }; + virtual Color _get_brace_mismatch_color() const { return Color(); } + virtual Color _get_code_folding_color() const { return Color(); } + virtual Ref<Texture2D> _get_folded_eol_icon() const { return Ref<Texture2D>(); } /* Text manipulation */ diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index c267ff93c6..47bb0643b3 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -340,11 +340,11 @@ Ref<BitMap> TextureButton::get_click_mask() const { Ref<Texture2D> TextureButton::get_texture_focused() const { return focused; -}; +} void TextureButton::set_texture_focused(const Ref<Texture2D> &p_focused) { focused = p_focused; -}; +} void TextureButton::_set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture) { DEV_ASSERT(p_destination); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 40917ee8f1..aab6f672f0 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1099,7 +1099,7 @@ void TreeItem::clear_children() { first_child = nullptr; last_child = nullptr; children_cache.clear(); -}; +} int TreeItem::get_index() { int idx = 0; @@ -4827,7 +4827,7 @@ void Tree::clear() { _determine_hovered_item(); queue_redraw(); -}; +} void Tree::set_hide_root(bool p_enabled) { if (hide_root == p_enabled) { diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h index 028c2cb2cf..5c4477234b 100644 --- a/scene/main/canvas_item.h +++ b/scene/main/canvas_item.h @@ -211,20 +211,20 @@ public: virtual Size2 _edit_get_scale() const = 0; // Used to rotate the node - virtual bool _edit_use_rotation() const { return false; }; + virtual bool _edit_use_rotation() const { return false; } virtual void _edit_set_rotation(real_t p_rotation) {} - virtual real_t _edit_get_rotation() const { return 0.0; }; + virtual real_t _edit_get_rotation() const { return 0.0; } // Used to resize/move the node - virtual bool _edit_use_rect() const { return false; }; // MAYBE REPLACE BY A _edit_get_editmode() + virtual bool _edit_use_rect() const { return false; } // MAYBE REPLACE BY A _edit_get_editmode() virtual void _edit_set_rect(const Rect2 &p_rect) {} - virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); }; - virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); }; // LOOKS WEIRD + virtual Rect2 _edit_get_rect() const { return Rect2(0, 0, 0, 0); } + virtual Size2 _edit_get_minimum_size() const { return Size2(-1, -1); } // LOOKS WEIRD // Used to set a pivot - virtual bool _edit_use_pivot() const { return false; }; + virtual bool _edit_use_pivot() const { return false; } virtual void _edit_set_pivot(const Point2 &p_pivot) {} - virtual Point2 _edit_get_pivot() const { return Point2(); }; + virtual Point2 _edit_get_pivot() const { return Point2(); } virtual Transform2D _edit_get_transform() const; #endif @@ -375,7 +375,7 @@ public: TextureRepeat get_texture_repeat_in_tree() const; // Used by control nodes to retrieve the parent's anchorable area - virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); }; + virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); } int get_canvas_layer() const; CanvasLayer *get_canvas_layer_node() const; diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index 29166f3d92..9222ce6df3 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -245,7 +245,7 @@ Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) { } return ret; -}; +} void InstancePlaceholder::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stored_values", "with_order"), &InstancePlaceholder::get_stored_values, DEFVAL(false)); diff --git a/scene/main/window.h b/scene/main/window.h index 6517350b78..0994fc6012 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -374,7 +374,7 @@ public: bool is_wrapping_controls() const; void child_controls_changed(); - Window *get_exclusive_child() const { return exclusive_child; }; + Window *get_exclusive_child() const { return exclusive_child; } Window *get_parent_visible_window() const; Viewport *get_parent_viewport() const; diff --git a/scene/resources/2d/navigation_mesh_source_geometry_data_2d.cpp b/scene/resources/2d/navigation_mesh_source_geometry_data_2d.cpp index e3f14539a8..07e9caa713 100644 --- a/scene/resources/2d/navigation_mesh_source_geometry_data_2d.cpp +++ b/scene/resources/2d/navigation_mesh_source_geometry_data_2d.cpp @@ -43,7 +43,7 @@ void NavigationMeshSourceGeometryData2D::clear() { bool NavigationMeshSourceGeometryData2D::has_data() { RWLockRead read_lock(geometry_rwlock); return traversable_outlines.size(); -}; +} void NavigationMeshSourceGeometryData2D::clear_projected_obstructions() { RWLockWrite write_lock(geometry_rwlock); diff --git a/scene/resources/2d/tile_set.cpp b/scene/resources/2d/tile_set.cpp index e624bdb32f..ca80486363 100644 --- a/scene/resources/2d/tile_set.cpp +++ b/scene/resources/2d/tile_set.cpp @@ -174,13 +174,13 @@ void TileMapPattern::set_size(const Size2i &p_size) { bool TileMapPattern::is_empty() const { return pattern.is_empty(); -}; +} void TileMapPattern::clear() { size = Size2i(); pattern.clear(); emit_changed(); -}; +} bool TileMapPattern::_set(const StringName &p_name, const Variant &p_value) { if (p_name == "tile_data") { @@ -571,11 +571,11 @@ void TileSet::set_uv_clipping(bool p_uv_clipping) { bool TileSet::is_uv_clipping() const { return uv_clipping; -}; +} int TileSet::get_occlusion_layers_count() const { return occlusion_layers.size(); -}; +} void TileSet::add_occlusion_layer(int p_index) { if (p_index < 0) { @@ -3691,7 +3691,7 @@ Array TileSet::compatibility_tilemap_map(int p_tile_id, Vector2i p_coords, bool return cannot_convert_array; break; } -}; +} #endif // DISABLE_DEPRECATED @@ -4432,7 +4432,7 @@ TileSet *TileSetSource::get_tile_set() const { void TileSetSource::reset_state() { tile_set = nullptr; -}; +} void TileSetSource::_bind_methods() { // Base tiles diff --git a/scene/resources/2d/tile_set.h b/scene/resources/2d/tile_set.h index 15e1a16359..7979e2ca39 100644 --- a/scene/resources/2d/tile_set.h +++ b/scene/resources/2d/tile_set.h @@ -278,7 +278,7 @@ public: bool operator==(const TerrainsPattern &p_terrains_pattern) const; bool operator!=(const TerrainsPattern &p_terrains_pattern) const { return !operator==(p_terrains_pattern); - }; + } void set_terrain(int p_terrain); int get_terrain() const; @@ -812,8 +812,8 @@ public: // Scenes accessors. Lot are similar to "Alternative tiles". int get_scene_tiles_count() { return get_alternative_tiles_count(Vector2i()); } - int get_scene_tile_id(int p_index) { return get_alternative_tile_id(Vector2i(), p_index); }; - bool has_scene_tile_id(int p_id) { return has_alternative_tile(Vector2i(), p_id); }; + int get_scene_tile_id(int p_index) { return get_alternative_tile_id(Vector2i(), p_index); } + bool has_scene_tile_id(int p_id) { return has_alternative_tile(Vector2i(), p_id); } int create_scene_tile(Ref<PackedScene> p_packed_scene = Ref<PackedScene>(), int p_id_override = -1); void set_scene_tile_id(int p_id, int p_new_id); void set_scene_tile_scene(int p_id, Ref<PackedScene> p_packed_scene); diff --git a/scene/resources/3d/navigation_mesh_source_geometry_data_3d.cpp b/scene/resources/3d/navigation_mesh_source_geometry_data_3d.cpp index 59366592ce..74dca88423 100644 --- a/scene/resources/3d/navigation_mesh_source_geometry_data_3d.cpp +++ b/scene/resources/3d/navigation_mesh_source_geometry_data_3d.cpp @@ -71,7 +71,7 @@ void NavigationMeshSourceGeometryData3D::append_arrays(const Vector<float> &p_ve bool NavigationMeshSourceGeometryData3D::has_data() { RWLockRead read_lock(geometry_rwlock); return vertices.size() && indices.size(); -}; +} void NavigationMeshSourceGeometryData3D::clear() { RWLockWrite write_lock(geometry_rwlock); diff --git a/scene/resources/3d/primitive_meshes.h b/scene/resources/3d/primitive_meshes.h index 85f46a482a..e68ac7fb26 100644 --- a/scene/resources/3d/primitive_meshes.h +++ b/scene/resources/3d/primitive_meshes.h @@ -545,7 +545,7 @@ private: ContourPoint(const Vector2 &p_pt, bool p_sharp) { point = p_pt; sharp = p_sharp; - }; + } }; struct ContourInfo { diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 57a4e35f7a..f0b182503a 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1048,7 +1048,7 @@ int Animation::find_track(const NodePath &p_path, const TrackType p_type) const } }; return -1; -}; +} Animation::TrackType Animation::get_cache_type(TrackType p_type) { if (p_type == Animation::TYPE_BEZIER) { diff --git a/scene/resources/camera_attributes.cpp b/scene/resources/camera_attributes.cpp index 3a021720c6..3a0c207a5d 100644 --- a/scene/resources/camera_attributes.cpp +++ b/scene/resources/camera_attributes.cpp @@ -487,7 +487,7 @@ void CameraAttributesPhysical::_bind_methods() { ADD_GROUP("Auto Exposure", "auto_exposure_"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_min_exposure_value", PROPERTY_HINT_RANGE, "-16.0,16.0,0.01,or_greater,suffix:EV100"), "set_auto_exposure_min_exposure_value", "get_auto_exposure_min_exposure_value"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_max_exposure_value", PROPERTY_HINT_RANGE, "-16.0,16.0,0.01,or_greater,suffix:EV100"), "set_auto_exposure_max_exposure_value", "get_auto_exposure_max_exposure_value"); -}; +} CameraAttributesPhysical::CameraAttributesPhysical() { _update_exposure(); diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 4d1d733f8b..848ae2713d 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -45,23 +45,23 @@ void MeshConvexDecompositionSettings::set_max_concavity(real_t p_max_concavity) real_t MeshConvexDecompositionSettings::get_max_concavity() const { return max_concavity; -}; +} void MeshConvexDecompositionSettings::set_symmetry_planes_clipping_bias(real_t p_symmetry_planes_clipping_bias) { symmetry_planes_clipping_bias = CLAMP(p_symmetry_planes_clipping_bias, 0.0, 1.0); -}; +} real_t MeshConvexDecompositionSettings::get_symmetry_planes_clipping_bias() const { return symmetry_planes_clipping_bias; -}; +} void MeshConvexDecompositionSettings::set_revolution_axes_clipping_bias(real_t p_revolution_axes_clipping_bias) { revolution_axes_clipping_bias = CLAMP(p_revolution_axes_clipping_bias, 0.0, 1.0); -}; +} real_t MeshConvexDecompositionSettings::get_revolution_axes_clipping_bias() const { return revolution_axes_clipping_bias; -}; +} void MeshConvexDecompositionSettings::set_min_volume_per_convex_hull(real_t p_min_volume_per_convex_hull) { min_volume_per_convex_hull = CLAMP(p_min_volume_per_convex_hull, 0.0001, 0.01); diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index 5200eba2a8..3b18e082a1 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -119,7 +119,7 @@ private: SmoothGroupVertex(const Vertex &p_vertex) { vertex = p_vertex.vertex; smooth_group = p_vertex.smooth_group; - }; + } }; struct SmoothGroupVertexHasher { diff --git a/scene/resources/text_paragraph.h b/scene/resources/text_paragraph.h index 7512955fb3..8b7f21fa9a 100644 --- a/scene/resources/text_paragraph.h +++ b/scene/resources/text_paragraph.h @@ -152,7 +152,7 @@ public: int hit_test(const Point2 &p_coords) const; - Mutex &get_mutex() const { return _thread_safe_; }; + Mutex &get_mutex() const { return _thread_safe_; } TextParagraph(const String &p_text, const Ref<Font> &p_font, int p_font_size, const String &p_language = "", float p_width = -1.f, TextServer::Direction p_direction = TextServer::DIRECTION_AUTO, TextServer::Orientation p_orientation = TextServer::ORIENTATION_HORIZONTAL); TextParagraph(); diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h index 823bad1d2e..96f8182732 100644 --- a/servers/audio/audio_driver_dummy.h +++ b/servers/audio/audio_driver_dummy.h @@ -61,7 +61,7 @@ class AudioDriverDummy : public AudioDriver { public: virtual const char *get_name() const override { return "Dummy"; - }; + } virtual Error init() override; virtual void start() override; diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index d400b5790f..42aa43269b 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -390,7 +390,7 @@ int AudioStreamPlaybackMicrophone::_mix_internal(AudioFrame *p_buffer, int p_fra Vector<int32_t> buf = AudioDriver::get_singleton()->get_input_buffer(); unsigned int input_size = AudioDriver::get_singleton()->get_input_size(); - int mix_rate = AudioDriver::get_singleton()->get_mix_rate(); + int mix_rate = AudioDriver::get_singleton()->get_input_mix_rate(); unsigned int playback_delay = MIN(((50 * mix_rate) / 1000) * 2, buf.size() >> 1); #ifdef DEBUG_ENABLED unsigned int input_position = AudioDriver::get_singleton()->get_input_position(); @@ -441,7 +441,7 @@ int AudioStreamPlaybackMicrophone::mix(AudioFrame *p_buffer, float p_rate_scale, } float AudioStreamPlaybackMicrophone::get_stream_sampling_rate() { - return AudioDriver::get_singleton()->get_mix_rate(); + return AudioDriver::get_singleton()->get_input_mix_rate(); } void AudioStreamPlaybackMicrophone::start(double p_from_pos) { diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 17b573ab7b..14c4c3b7e1 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -1618,6 +1618,10 @@ float AudioServer::get_mix_rate() const { return AudioDriver::get_singleton()->get_mix_rate(); } +float AudioServer::get_input_mix_rate() const { + return AudioDriver::get_singleton()->get_input_mix_rate(); +} + float AudioServer::read_output_peak_db() const { return 0; } @@ -1950,6 +1954,7 @@ void AudioServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_speaker_mode"), &AudioServer::get_speaker_mode); ClassDB::bind_method(D_METHOD("get_mix_rate"), &AudioServer::get_mix_rate); + ClassDB::bind_method(D_METHOD("get_input_mix_rate"), &AudioServer::get_input_mix_rate); ClassDB::bind_method(D_METHOD("get_driver_name"), &AudioServer::get_driver_name); diff --git a/servers/audio_server.h b/servers/audio_server.h index d4e1aa9995..8978ad438e 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -99,6 +99,7 @@ public: virtual Error init() = 0; virtual void start() = 0; virtual int get_mix_rate() const = 0; + virtual int get_input_mix_rate() const { return get_mix_rate(); } virtual SpeakerMode get_speaker_mode() const = 0; virtual float get_latency() { return 0; } @@ -443,6 +444,7 @@ public: virtual SpeakerMode get_speaker_mode() const; virtual float get_mix_rate() const; + virtual float get_input_mix_rate() const; virtual float read_output_peak_db() const; diff --git a/servers/camera_server.cpp b/servers/camera_server.cpp index bf698e3945..b78a0c44e7 100644 --- a/servers/camera_server.cpp +++ b/servers/camera_server.cpp @@ -53,13 +53,13 @@ void CameraServer::_bind_methods() { BIND_ENUM_CONSTANT(FEED_YCBCR_IMAGE); BIND_ENUM_CONSTANT(FEED_Y_IMAGE); BIND_ENUM_CONSTANT(FEED_CBCR_IMAGE); -}; +} CameraServer *CameraServer::singleton = nullptr; CameraServer *CameraServer::get_singleton() { return singleton; -}; +} int CameraServer::get_free_id() { bool id_exists = true; @@ -77,7 +77,7 @@ int CameraServer::get_free_id() { }; return newid; -}; +} int CameraServer::get_feed_index(int p_id) { for (int i = 0; i < feeds.size(); i++) { @@ -87,7 +87,7 @@ int CameraServer::get_feed_index(int p_id) { }; return -1; -}; +} Ref<CameraFeed> CameraServer::get_feed_by_id(int p_id) { int index = get_feed_index(p_id); @@ -97,7 +97,7 @@ Ref<CameraFeed> CameraServer::get_feed_by_id(int p_id) { } else { return feeds[index]; } -}; +} void CameraServer::add_feed(const Ref<CameraFeed> &p_feed) { ERR_FAIL_COND(p_feed.is_null()); @@ -109,7 +109,7 @@ void CameraServer::add_feed(const Ref<CameraFeed> &p_feed) { // let whomever is interested know emit_signal(SNAME("camera_feed_added"), p_feed->get_id()); -}; +} void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { for (int i = 0; i < feeds.size(); i++) { @@ -126,17 +126,17 @@ void CameraServer::remove_feed(const Ref<CameraFeed> &p_feed) { return; }; }; -}; +} Ref<CameraFeed> CameraServer::get_feed(int p_index) { ERR_FAIL_INDEX_V(p_index, feeds.size(), nullptr); return feeds[p_index]; -}; +} int CameraServer::get_feed_count() { return feeds.size(); -}; +} TypedArray<CameraFeed> CameraServer::get_feeds() { TypedArray<CameraFeed> return_feeds; @@ -148,7 +148,7 @@ TypedArray<CameraFeed> CameraServer::get_feeds() { }; return return_feeds; -}; +} RID CameraServer::feed_texture(int p_id, CameraServer::FeedImage p_texture) { int index = get_feed_index(p_id); @@ -157,12 +157,12 @@ RID CameraServer::feed_texture(int p_id, CameraServer::FeedImage p_texture) { Ref<CameraFeed> feed = get_feed(index); return feed->get_texture(p_texture); -}; +} CameraServer::CameraServer() { singleton = this; -}; +} CameraServer::~CameraServer() { singleton = nullptr; -}; +} diff --git a/servers/camera_server.h b/servers/camera_server.h index e9bcd771d2..6a79b62fbd 100644 --- a/servers/camera_server.h +++ b/servers/camera_server.h @@ -87,7 +87,7 @@ public: static CameraServer *create() { CameraServer *server = create_func ? create_func() : memnew(CameraServer); return server; - }; + } // Right now we identify our feed by it's ID when it's used in the background. // May see if we can change this to purely relying on CameraFeed objects or by name. diff --git a/servers/display_server.cpp b/servers/display_server.cpp index dc5752cf4d..7059e7ed49 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -550,7 +550,7 @@ DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_scr float DisplayServer::screen_get_scale(int p_screen) const { return 1.0f; -}; +} bool DisplayServer::is_touchscreen_available() const { return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse(); diff --git a/servers/display_server.h b/servers/display_server.h index 5726f26792..670afb3646 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -360,6 +360,13 @@ public: virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW); virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const; + // Note: The "internal" current orientation is not necessarily the current orientation and will often be 0 for most platforms. + // + // Some Android GPUs come with a HW-based rotator which means the screen gets rotated for free to + // whatever orientation the device is currently facing. But many Android GPUs emulate it via SW instead, + // which costs performance and power. This value is an optimization that tells Godot's compositor how to + // rotate the render texture before presenting to screen so that Android's compositor doesn't have to. + virtual int screen_get_internal_current_rotation(int p_screen = SCREEN_OF_MAIN_WINDOW) const { return 0; } virtual void screen_set_keep_on(bool p_enable); //disable screensaver virtual bool screen_is_kept_on() const; @@ -369,6 +376,7 @@ public: INVALID_INDICATOR_ID = -1 }; +public: typedef int WindowID; typedef int IndicatorID; diff --git a/servers/display_server_headless.h b/servers/display_server_headless.h index a5277479ca..5f53e76235 100644 --- a/servers/display_server_headless.h +++ b/servers/display_server_headless.h @@ -72,7 +72,7 @@ public: // that don't affect the project's behavior in headless mode. int get_screen_count() const override { return 0; } - int get_primary_screen() const override { return 0; }; + int get_primary_screen() const override { return 0; } Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const override { return Point2i(); } Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const override { return Size2i(); } Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override { return Rect2i(); } @@ -141,7 +141,7 @@ public: void window_request_attention(WindowID p_window = MAIN_WINDOW_ID) override {} void window_move_to_foreground(WindowID p_window = MAIN_WINDOW_ID) override {} - bool window_is_focused(WindowID p_window = MAIN_WINDOW_ID) const override { return true; }; + bool window_is_focused(WindowID p_window = MAIN_WINDOW_ID) const override { return true; } bool window_can_draw(WindowID p_window = MAIN_WINDOW_ID) const override { return false; } diff --git a/servers/navigation_server_2d_dummy.h b/servers/navigation_server_2d_dummy.h index 0664b37ef0..5bc91830e6 100644 --- a/servers/navigation_server_2d_dummy.h +++ b/servers/navigation_server_2d_dummy.h @@ -58,7 +58,7 @@ public: TypedArray<RID> map_get_agents(RID p_map) const override { return TypedArray<RID>(); } TypedArray<RID> map_get_obstacles(RID p_map) const override { return TypedArray<RID>(); } void map_force_update(RID p_map) override {} - Vector2 map_get_random_point(RID p_map, uint32_t p_naviation_layers, bool p_uniformly) const override { return Vector2(); }; + Vector2 map_get_random_point(RID p_map, uint32_t p_naviation_layers, bool p_uniformly) const override { return Vector2(); } uint32_t map_get_iteration_id(RID p_map) const override { return 0; } RID region_create() override { return RID(); } @@ -84,7 +84,7 @@ public: Vector2 region_get_connection_pathway_start(RID p_region, int p_connection_id) const override { return Vector2(); } Vector2 region_get_connection_pathway_end(RID p_region, int p_connection_id) const override { return Vector2(); } Vector2 region_get_closest_point(RID p_region, const Vector2 &p_point) const override { return Vector2(); } - Vector2 region_get_random_point(RID p_region, uint32_t p_navigation_layers, bool p_uniformly) const override { return Vector2(); }; + Vector2 region_get_random_point(RID p_region, uint32_t p_navigation_layers, bool p_uniformly) const override { return Vector2(); } RID link_create() override { return RID(); } void link_set_map(RID p_link, RID p_map) override {} diff --git a/servers/rendering/dummy/rasterizer_dummy.h b/servers/rendering/dummy/rasterizer_dummy.h index 7640afc711..6205193d9a 100644 --- a/servers/rendering/dummy/rasterizer_dummy.h +++ b/servers/rendering/dummy/rasterizer_dummy.h @@ -66,14 +66,14 @@ protected: RasterizerSceneDummy scene; public: - RendererUtilities *get_utilities() override { return &utilities; }; - RendererLightStorage *get_light_storage() override { return &light_storage; }; - RendererMaterialStorage *get_material_storage() override { return &material_storage; }; - RendererMeshStorage *get_mesh_storage() override { return &mesh_storage; }; - RendererParticlesStorage *get_particles_storage() override { return &particles_storage; }; - RendererTextureStorage *get_texture_storage() override { return &texture_storage; }; - RendererGI *get_gi() override { return &gi; }; - RendererFog *get_fog() override { return &fog; }; + RendererUtilities *get_utilities() override { return &utilities; } + RendererLightStorage *get_light_storage() override { return &light_storage; } + RendererMaterialStorage *get_material_storage() override { return &material_storage; } + RendererMeshStorage *get_mesh_storage() override { return &mesh_storage; } + RendererParticlesStorage *get_particles_storage() override { return &particles_storage; } + RendererTextureStorage *get_texture_storage() override { return &texture_storage; } + RendererGI *get_gi() override { return &gi; } + RendererFog *get_fog() override { return &fog; } RendererCanvasRender *get_canvas() override { return &canvas; } RendererSceneRender *get_scene() override { return &scene; } diff --git a/servers/rendering/dummy/storage/material_storage.h b/servers/rendering/dummy/storage/material_storage.h index e4c58474e2..74ae71cba6 100644 --- a/servers/rendering/dummy/storage/material_storage.h +++ b/servers/rendering/dummy/storage/material_storage.h @@ -92,7 +92,7 @@ public: virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override { return RID(); } virtual Variant shader_get_parameter_default(RID p_material, const StringName &p_param) const override { return Variant(); } - virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override { return RS::ShaderNativeSourceCode(); }; + virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override { return RS::ShaderNativeSourceCode(); } /* MATERIAL API */ virtual RID material_allocate() override { return RID(); } diff --git a/servers/rendering/dummy/storage/mesh_storage.h b/servers/rendering/dummy/storage/mesh_storage.h index b0953b5dce..855336c71f 100644 --- a/servers/rendering/dummy/storage/mesh_storage.h +++ b/servers/rendering/dummy/storage/mesh_storage.h @@ -64,7 +64,7 @@ public: /* MESH API */ - bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); }; + bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); } virtual RID mesh_allocate() override; virtual void mesh_initialize(RID p_rid) override; diff --git a/servers/rendering/dummy/storage/texture_storage.h b/servers/rendering/dummy/storage/texture_storage.h index 6735f6bcda..63eb441915 100644 --- a/servers/rendering/dummy/storage/texture_storage.h +++ b/servers/rendering/dummy/storage/texture_storage.h @@ -53,7 +53,7 @@ public: /* Canvas Texture API */ - virtual RID canvas_texture_allocate() override { return RID(); }; + virtual RID canvas_texture_allocate() override { return RID(); } virtual void canvas_texture_initialize(RID p_rid) override {} virtual void canvas_texture_free(RID p_rid) override {} @@ -65,13 +65,13 @@ public: /* Texture API */ - bool owns_texture(RID p_rid) { return texture_owner.owns(p_rid); }; + bool owns_texture(RID p_rid) { return texture_owner.owns(p_rid); } virtual RID texture_allocate() override { DummyTexture *texture = memnew(DummyTexture); ERR_FAIL_NULL_V(texture, RID()); return texture_owner.make_rid(texture); - }; + } virtual void texture_free(RID p_rid) override { // delete the texture @@ -79,13 +79,13 @@ public: ERR_FAIL_NULL(texture); texture_owner.free(p_rid); memdelete(texture); - }; + } virtual void texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) override { DummyTexture *t = texture_owner.get_or_null(p_texture); ERR_FAIL_NULL(t); t->image = p_image->duplicate(); - }; + } virtual void texture_2d_layered_initialize(RID p_texture, const Vector<Ref<Image>> &p_layers, RS::TextureLayeredType p_layered_type) override {} virtual void texture_3d_initialize(RID p_texture, Image::Format, int p_width, int p_height, int p_depth, bool p_mipmaps, const Vector<Ref<Image>> &p_data) override {} virtual void texture_external_initialize(RID p_texture, int p_width, int p_height, uint64_t p_external_buffer) override {} @@ -107,15 +107,15 @@ public: DummyTexture *t = texture_owner.get_or_null(p_texture); ERR_FAIL_NULL_V(t, Ref<Image>()); return t->image; - }; - virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const override { return Ref<Image>(); }; - virtual Vector<Ref<Image>> texture_3d_get(RID p_texture) const override { return Vector<Ref<Image>>(); }; + } + virtual Ref<Image> texture_2d_layer_get(RID p_texture, int p_layer) const override { return Ref<Image>(); } + virtual Vector<Ref<Image>> texture_3d_get(RID p_texture) const override { return Vector<Ref<Image>>(); } - virtual void texture_replace(RID p_texture, RID p_by_texture) override { texture_free(p_by_texture); }; + virtual void texture_replace(RID p_texture, RID p_by_texture) override { texture_free(p_by_texture); } virtual void texture_set_size_override(RID p_texture, int p_width, int p_height) override {} virtual void texture_set_path(RID p_texture, const String &p_path) override {} - virtual String texture_get_path(RID p_texture) const override { return String(); }; + virtual String texture_get_path(RID p_texture) const override { return String(); } virtual Image::Format texture_get_format(RID p_texture) const override { return Image::FORMAT_MAX; } @@ -127,11 +127,11 @@ public: virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) override {} - virtual Size2 texture_size_with_proxy(RID p_proxy) override { return Size2(); }; + virtual Size2 texture_size_with_proxy(RID p_proxy) override { return Size2(); } virtual void texture_rd_initialize(RID p_texture, const RID &p_rd_texture, const RS::TextureLayeredType p_layer_type = RS::TEXTURE_LAYERED_2D_ARRAY) override {} - virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override { return RID(); }; - virtual uint64_t texture_get_native_handle(RID p_texture, bool p_srgb = false) const override { return 0; }; + virtual RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) const override { return RID(); } + virtual uint64_t texture_get_native_handle(RID p_texture, bool p_srgb = false) const override { return 0; } /* DECAL API */ virtual RID decal_allocate() override { return RID(); } diff --git a/servers/rendering/dummy/storage/utilities.h b/servers/rendering/dummy/storage/utilities.h index ae83547afd..4e20dee640 100644 --- a/servers/rendering/dummy/storage/utilities.h +++ b/servers/rendering/dummy/storage/utilities.h @@ -124,7 +124,7 @@ public: virtual RenderingDevice::DeviceType get_video_adapter_type() const override { return RenderingDevice::DeviceType::DEVICE_TYPE_OTHER; } virtual String get_video_adapter_api_version() const override { return String(); } - virtual Size2i get_maximum_viewport_size() const override { return Size2i(); }; + virtual Size2i get_maximum_viewport_size() const override { return Size2i(); } }; } // namespace RendererDummy diff --git a/servers/rendering/renderer_compositor.h b/servers/rendering/renderer_compositor.h index a585c9430b..dbc8f155bf 100644 --- a/servers/rendering/renderer_compositor.h +++ b/servers/rendering/renderer_compositor.h @@ -106,7 +106,7 @@ public: virtual double get_total_time() const = 0; virtual bool can_create_resources_async() const = 0; - static bool is_low_end() { return low_end; }; + static bool is_low_end() { return low_end; } virtual bool is_xr_enabled() const; static RendererCompositor *get_singleton() { return singleton; } diff --git a/servers/rendering/renderer_rd/environment/fog.cpp b/servers/rendering/renderer_rd/environment/fog.cpp index 903d73ff2b..090eab384f 100644 --- a/servers/rendering/renderer_rd/environment/fog.cpp +++ b/servers/rendering/renderer_rd/environment/fog.cpp @@ -157,7 +157,7 @@ RendererRD::MaterialStorage::ShaderData *Fog::_create_fog_shader_func() { RendererRD::MaterialStorage::ShaderData *Fog::_create_fog_shader_funcs() { return Fog::get_singleton()->_create_fog_shader_func(); -}; +} RendererRD::MaterialStorage::MaterialData *Fog::_create_fog_material_func(FogShaderData *p_shader) { FogMaterialData *material_data = memnew(FogMaterialData); @@ -168,7 +168,7 @@ RendererRD::MaterialStorage::MaterialData *Fog::_create_fog_material_func(FogSha RendererRD::MaterialStorage::MaterialData *Fog::_create_fog_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) { return Fog::get_singleton()->_create_fog_material_func(static_cast<FogShaderData *>(p_shader)); -}; +} //////////////////////////////////////////////////////////////////////////////// // FOG VOLUMES INSTANCE diff --git a/servers/rendering/renderer_rd/environment/fog.h b/servers/rendering/renderer_rd/environment/fog.h index 75b9c563f7..23de97a268 100644 --- a/servers/rendering/renderer_rd/environment/fog.h +++ b/servers/rendering/renderer_rd/environment/fog.h @@ -233,7 +233,7 @@ public: /* FOG VOLUMES */ - bool owns_fog_volume(RID p_rid) { return fog_volume_owner.owns(p_rid); }; + bool owns_fog_volume(RID p_rid) { return fog_volume_owner.owns(p_rid); } virtual RID fog_volume_allocate() override; virtual void fog_volume_initialize(RID p_rid) override; @@ -250,7 +250,7 @@ public: /* FOG VOLUMES INSTANCE */ - bool owns_fog_volume_instance(RID p_rid) { return fog_volume_instance_owner.owns(p_rid); }; + bool owns_fog_volume_instance(RID p_rid) { return fog_volume_instance_owner.owns(p_rid); } RID fog_volume_instance_create(RID p_fog_volume); void fog_instance_free(RID p_rid); diff --git a/servers/rendering/renderer_rd/environment/gi.h b/servers/rendering/renderer_rd/environment/gi.h index f6f9ab4f75..f34bbde6f0 100644 --- a/servers/rendering/renderer_rd/environment/gi.h +++ b/servers/rendering/renderer_rd/environment/gi.h @@ -467,7 +467,7 @@ public: /* VOXEL GI API */ - bool owns_voxel_gi(RID p_rid) { return voxel_gi_owner.owns(p_rid); }; + bool owns_voxel_gi(RID p_rid) { return voxel_gi_owner.owns(p_rid); } virtual RID voxel_gi_allocate() override; virtual void voxel_gi_free(RID p_voxel_gi) override; @@ -524,14 +524,14 @@ public: VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_probe); ERR_FAIL_NULL_V(voxel_gi, RID()); return voxel_gi->texture; - }; + } _FORCE_INLINE_ void voxel_gi_instance_set_render_index(RID p_probe, uint32_t p_index) { VoxelGIInstance *voxel_gi = voxel_gi_instance_owner.get_or_null(p_probe); ERR_FAIL_NULL(voxel_gi); voxel_gi->render_index = p_index; - }; + } bool voxel_gi_instance_owns(RID p_rid) const { return voxel_gi_instance_owner.owns(p_rid); diff --git a/servers/rendering/renderer_rd/environment/sky.cpp b/servers/rendering/renderer_rd/environment/sky.cpp index 2087989102..63956a7918 100644 --- a/servers/rendering/renderer_rd/environment/sky.cpp +++ b/servers/rendering/renderer_rd/environment/sky.cpp @@ -701,7 +701,7 @@ RendererRD::MaterialStorage::ShaderData *SkyRD::_create_sky_shader_func() { RendererRD::MaterialStorage::ShaderData *SkyRD::_create_sky_shader_funcs() { // !BAS! Why isn't _create_sky_shader_func not just static too? return static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton)->sky._create_sky_shader_func(); -}; +} RendererRD::MaterialStorage::MaterialData *SkyRD::_create_sky_material_func(SkyShaderData *p_shader) { SkyMaterialData *material_data = memnew(SkyMaterialData); @@ -713,7 +713,7 @@ RendererRD::MaterialStorage::MaterialData *SkyRD::_create_sky_material_func(SkyS RendererRD::MaterialStorage::MaterialData *SkyRD::_create_sky_material_funcs(RendererRD::MaterialStorage::ShaderData *p_shader) { // !BAS! same here, we could just make _create_sky_material_func static? return static_cast<RendererSceneRenderRD *>(RendererSceneRenderRD::singleton)->sky._create_sky_material_func(static_cast<SkyShaderData *>(p_shader)); -}; +} SkyRD::SkyRD() { roughness_layers = GLOBAL_GET("rendering/reflections/sky_reflections/roughness_layers"); diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h index 136514588a..8d79539b3d 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.h @@ -108,10 +108,10 @@ public: uint32_t projector_use_mipmaps : 1; uint32_t use_depth_fog : 1; uint32_t use_lightmap_bicubic_filter : 1; - uint32_t soft_shadow_samples : 4; - uint32_t penumbra_shadow_samples : 4; - uint32_t directional_soft_shadow_samples : 4; - uint32_t directional_penumbra_shadow_samples : 4; + uint32_t soft_shadow_samples : 6; + uint32_t penumbra_shadow_samples : 6; + uint32_t directional_soft_shadow_samples : 6; + uint32_t directional_penumbra_shadow_samples : 6; }; uint32_t packed_0; diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index 6dcaadddd3..6323d7dd6a 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -322,7 +322,12 @@ void SceneShaderForwardMobile::ShaderData::_create_pipeline(PipelineKey p_pipeli specialization_constants.push_back(sc); sc.constant_id = 1; - sc.float_value = p_pipeline_key.shader_specialization.packed_1; + sc.int_value = p_pipeline_key.shader_specialization.packed_1; + sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT; + specialization_constants.push_back(sc); + + sc.constant_id = 2; + sc.float_value = p_pipeline_key.shader_specialization.packed_2; sc.type = RD::PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT; specialization_constants.push_back(sc); diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h index c1095d29dc..a27da6c72d 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.h @@ -74,22 +74,23 @@ public: uint32_t use_depth_fog : 1; uint32_t is_multimesh : 1; uint32_t use_lightmap_bicubic_filter : 1; - uint32_t pad : 2; - uint32_t soft_shadow_samples : 4; - uint32_t penumbra_shadow_samples : 4; - uint32_t directional_soft_shadow_samples : 4; - uint32_t directional_penumbra_shadow_samples : 4; + uint32_t soft_shadow_samples : 6; + uint32_t penumbra_shadow_samples : 6; + uint32_t directional_soft_shadow_samples : 6; }; uint32_t packed_0; }; union { - float luminance_multiplier; - float packed_1; + uint32_t directional_penumbra_shadow_samples : 6; + uint32_t packed_1; }; - uint32_t packed_2; + union { + float luminance_multiplier; + float packed_2; + }; }; struct UbershaderConstants { diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 84ea6a5da2..d04285fbb4 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -66,6 +66,16 @@ void RendererCompositorRD::blit_render_targets_to_screen(DisplayServer::WindowID RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array); RD::get_singleton()->draw_list_bind_uniform_set(draw_list, render_target_descriptors[rd_texture], 0); + // We need to invert the phone rotation. + int screen_rotation_degrees = -DisplayServer::get_singleton()->screen_get_internal_current_rotation(); + float screen_rotation = Math::deg_to_rad((float)screen_rotation_degrees); + + blit.push_constant.rotation_cos = Math::cos(screen_rotation); + blit.push_constant.rotation_sin = Math::sin(screen_rotation); + // Swap width and height when the orientation is not the native one. + if (screen_rotation_degrees % 180 != 0) { + SWAP(screen_size.width, screen_size.height); + } blit.push_constant.src_rect[0] = p_render_targets[i].src_rect.position.x; blit.push_constant.src_rect[1] = p_render_targets[i].src_rect.position.y; blit.push_constant.src_rect[2] = p_render_targets[i].src_rect.size.width; @@ -228,6 +238,10 @@ void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color RD::get_singleton()->draw_list_bind_index_array(draw_list, blit.array); RD::get_singleton()->draw_list_bind_uniform_set(draw_list, uset, 0); + int screen_rotation_degrees = DisplayServer::get_singleton()->screen_get_internal_current_rotation(); + float screen_rotation = Math::deg_to_rad((float)screen_rotation_degrees); + blit.push_constant.rotation_cos = Math::cos(screen_rotation); + blit.push_constant.rotation_sin = Math::sin(screen_rotation); blit.push_constant.src_rect[0] = 0.0; blit.push_constant.src_rect[1] = 0.0; blit.push_constant.src_rect[2] = 1.0; diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.h b/servers/rendering/renderer_rd/renderer_compositor_rd.h index 2547f08715..6821fa737e 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.h +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.h @@ -74,6 +74,10 @@ protected: float src_rect[4]; float dst_rect[4]; + float rotation_sin; + float rotation_cos; + float pad[2]; + float eye_center[2]; float k1; float k2; @@ -103,7 +107,7 @@ protected: static RendererCompositorRD *singleton; public: - RendererUtilities *get_utilities() { return utilities; }; + RendererUtilities *get_utilities() { return utilities; } RendererLightStorage *get_light_storage() { return light_storage; } RendererMaterialStorage *get_material_storage() { return material_storage; } RendererMeshStorage *get_mesh_storage() { return mesh_storage; } diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index b82d50378e..631ad21247 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -78,7 +78,7 @@ protected: //////////////////////////////// - virtual RendererRD::ForwardIDStorage *create_forward_id_storage() { return memnew(RendererRD::ForwardIDStorage); }; + virtual RendererRD::ForwardIDStorage *create_forward_id_storage() { return memnew(RendererRD::ForwardIDStorage); } void _update_vrs(Ref<RenderSceneBuffersRD> p_render_buffers); diff --git a/servers/rendering/renderer_rd/shaders/blit.glsl b/servers/rendering/renderer_rd/shaders/blit.glsl index d451647bec..fe6416f03c 100644 --- a/servers/rendering/renderer_rd/shaders/blit.glsl +++ b/servers/rendering/renderer_rd/shaders/blit.glsl @@ -8,6 +8,10 @@ layout(push_constant, std140) uniform Pos { vec4 src_rect; vec4 dst_rect; + float rotation_sin; + float rotation_cos; + vec2 pad; + vec2 eye_center; float k1; float k2; @@ -15,17 +19,23 @@ layout(push_constant, std140) uniform Pos { float upscale; float aspect_ratio; uint layer; - uint pad1; + bool convert_to_srgb; } data; layout(location = 0) out vec2 uv; void main() { + mat4 swapchain_transform = mat4(1.0); + swapchain_transform[0][0] = data.rotation_cos; + swapchain_transform[0][1] = -data.rotation_sin; + swapchain_transform[1][0] = data.rotation_sin; + swapchain_transform[1][1] = data.rotation_cos; + vec2 base_arr[4] = vec2[](vec2(0.0, 0.0), vec2(0.0, 1.0), vec2(1.0, 1.0), vec2(1.0, 0.0)); uv = data.src_rect.xy + base_arr[gl_VertexIndex] * data.src_rect.zw; vec2 vtx = data.dst_rect.xy + base_arr[gl_VertexIndex] * data.dst_rect.zw; - gl_Position = vec4(vtx * 2.0 - 1.0, 0.0, 1.0); + gl_Position = swapchain_transform * vec4(vtx * 2.0 - 1.0, 0.0, 1.0); } #[fragment] @@ -38,6 +48,10 @@ layout(push_constant, std140) uniform Pos { vec4 src_rect; vec4 dst_rect; + float rotation_sin; + float rotation_cos; + vec2 pad; + vec2 eye_center; float k1; float k2; diff --git a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl index 9f68d59be2..7bfcb2fb12 100644 --- a/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl @@ -107,19 +107,19 @@ bool sc_use_lightmap_bicubic_filter() { } uint sc_soft_shadow_samples() { - return (sc_packed_0() >> 8) & 15U; + return (sc_packed_0() >> 8) & 63U; } uint sc_penumbra_shadow_samples() { - return (sc_packed_0() >> 12) & 15U; + return (sc_packed_0() >> 14) & 63U; } uint sc_directional_soft_shadow_samples() { - return (sc_packed_0() >> 16) & 15U; + return (sc_packed_0() >> 20) & 63U; } uint sc_directional_penumbra_shadow_samples() { - return (sc_packed_0() >> 20) & 15U; + return (sc_packed_0() >> 26) & 63U; } float sc_luminance_multiplier() { diff --git a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl index 495e52a29e..df528973da 100644 --- a/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/forward_mobile/scene_forward_mobile_inc.glsl @@ -22,8 +22,8 @@ layout(push_constant, std430) uniform DrawCall { uint pad; #ifdef UBERSHADER uint sc_packed_0; - float sc_packed_1; - uint sc_packed_2; + uint sc_packed_1; + float sc_packed_2; uint uc_packed_0; #endif } @@ -42,10 +42,14 @@ uint sc_packed_0() { return draw_call.sc_packed_0; } -float sc_packed_1() { +uint sc_packed_1() { return draw_call.sc_packed_1; } +float sc_packed_2() { + return draw_call.sc_packed_2; +} + uint uc_cull_mode() { return (draw_call.uc_packed_0 >> 0) & 3U; } @@ -54,16 +58,21 @@ uint uc_cull_mode() { // Pull the constants from the pipeline's specialization constants. layout(constant_id = 0) const uint pso_sc_packed_0 = 0; -layout(constant_id = 1) const float pso_sc_packed_1 = 2.0; +layout(constant_id = 1) const uint pso_sc_packed_1 = 0; +layout(constant_id = 2) const float pso_sc_packed_2 = 2.0; uint sc_packed_0() { return pso_sc_packed_0; } -float sc_packed_1() { +uint sc_packed_1() { return pso_sc_packed_1; } +float sc_packed_2() { + return pso_sc_packed_2; +} + #endif bool sc_use_light_projector() { @@ -123,23 +132,23 @@ bool sc_use_lightmap_bicubic_filter() { } uint sc_soft_shadow_samples() { - return (sc_packed_0() >> 16) & 15U; + return (sc_packed_0() >> 14) & 63U; } uint sc_penumbra_shadow_samples() { - return (sc_packed_0() >> 20) & 15U; + return (sc_packed_0() >> 20) & 63U; } uint sc_directional_soft_shadow_samples() { - return (sc_packed_0() >> 24) & 15U; + return (sc_packed_0() >> 26) & 63U; } uint sc_directional_penumbra_shadow_samples() { - return (sc_packed_0() >> 28) & 15U; + return (sc_packed_1() >> 0) & 63U; } float sc_luminance_multiplier() { - return sc_packed_1(); + return sc_packed_2(); } /* Set 0: Base Pass (never changes) */ diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp index 3639b5739b..9de37050f0 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.cpp @@ -1049,7 +1049,7 @@ void LightStorage::reflection_probe_free(RID p_rid) { ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_rid); reflection_probe->dependency.deleted_notify(p_rid); reflection_probe_owner.free(p_rid); -}; +} void LightStorage::reflection_probe_set_update_mode(RID p_probe, RS::ReflectionProbeUpdateMode p_mode) { ReflectionProbe *reflection_probe = reflection_probe_owner.get_or_null(p_probe); diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.h b/servers/rendering/renderer_rd/storage_rd/light_storage.h index 80c62a7bc4..1a92c5470d 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.h @@ -590,7 +590,7 @@ public: /* LIGHT INSTANCE API */ - bool owns_light_instance(RID p_rid) { return light_instance_owner.owns(p_rid); }; + bool owns_light_instance(RID p_rid) { return light_instance_owner.owns(p_rid); } virtual RID light_instance_create(RID p_light) override; virtual void light_instance_free(RID p_light) override; @@ -811,7 +811,7 @@ public: /* REFLECTION PROBE */ - bool owns_reflection_probe(RID p_rid) { return reflection_probe_owner.owns(p_rid); }; + bool owns_reflection_probe(RID p_rid) { return reflection_probe_owner.owns(p_rid); } virtual RID reflection_probe_allocate() override; virtual void reflection_probe_initialize(RID p_reflection_probe) override; @@ -953,7 +953,7 @@ public: /* LIGHTMAP */ - bool owns_lightmap(RID p_rid) { return lightmap_owner.owns(p_rid); }; + bool owns_lightmap(RID p_rid) { return lightmap_owner.owns(p_rid); } virtual RID lightmap_allocate() override; virtual void lightmap_initialize(RID p_lightmap) override; @@ -1019,7 +1019,7 @@ public: /* LIGHTMAP INSTANCE */ - bool owns_lightmap_instance(RID p_rid) { return lightmap_instance_owner.owns(p_rid); }; + bool owns_lightmap_instance(RID p_rid) { return lightmap_instance_owner.owns(p_rid); } virtual RID lightmap_instance_create(RID p_lightmap) override; virtual void lightmap_instance_free(RID p_lightmap) override; @@ -1039,7 +1039,7 @@ public: /* SHADOW ATLAS API */ - bool owns_shadow_atlas(RID p_rid) { return shadow_atlas_owner.owns(p_rid); }; + bool owns_shadow_atlas(RID p_rid) { return shadow_atlas_owner.owns(p_rid); } virtual RID shadow_atlas_create() override; virtual void shadow_atlas_free(RID p_atlas) override; diff --git a/servers/rendering/renderer_rd/storage_rd/material_storage.h b/servers/rendering/renderer_rd/storage_rd/material_storage.h index 08c1064dcb..89a8b36853 100644 --- a/servers/rendering/renderer_rd/storage_rd/material_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/material_storage.h @@ -254,7 +254,7 @@ private: MaterialDataRequestFunction material_data_request_func[SHADER_TYPE_MAX]; mutable RID_Owner<Material, true> material_owner; - Material *get_material(RID p_rid) { return material_owner.get_or_null(p_rid); }; + Material *get_material(RID p_rid) { return material_owner.get_or_null(p_rid); } SelfList<Material>::List material_update_list; Mutex material_update_list_mutex; @@ -403,7 +403,7 @@ public: /* SHADER API */ - bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); }; + bool owns_shader(RID p_rid) { return shader_owner.owns(p_rid); } virtual RID shader_allocate() override; virtual void shader_initialize(RID p_shader) override; @@ -423,7 +423,7 @@ public: /* MATERIAL API */ - bool owns_material(RID p_rid) { return material_owner.owns(p_rid); }; + bool owns_material(RID p_rid) { return material_owner.owns(p_rid); } void _material_queue_update(Material *material, bool p_uniform, bool p_texture); void _update_queued_materials(); diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h index 322f3cc6f4..c14c2945bd 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h @@ -351,7 +351,7 @@ public: /* MESH API */ - bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); }; + bool owns_mesh(RID p_rid) { return mesh_owner.owns(p_rid); } virtual RID mesh_allocate() override; virtual void mesh_initialize(RID p_mesh) override; @@ -616,7 +616,7 @@ public: /* MESH INSTANCE API */ - bool owns_mesh_instance(RID p_rid) const { return mesh_instance_owner.owns(p_rid); }; + bool owns_mesh_instance(RID p_rid) const { return mesh_instance_owner.owns(p_rid); } virtual RID mesh_instance_create(RID p_base) override; virtual void mesh_instance_free(RID p_rid) override; @@ -628,7 +628,7 @@ public: /* MULTIMESH API */ - bool owns_multimesh(RID p_rid) { return multimesh_owner.owns(p_rid); }; + bool owns_multimesh(RID p_rid) { return multimesh_owner.owns(p_rid); } virtual RID _multimesh_allocate() override; virtual void _multimesh_initialize(RID p_multimesh) override; @@ -737,7 +737,7 @@ public: /* SKELETON API */ - bool owns_skeleton(RID p_rid) const { return skeleton_owner.owns(p_rid); }; + bool owns_skeleton(RID p_rid) const { return skeleton_owner.owns(p_rid); } virtual RID skeleton_allocate() override; virtual void skeleton_initialize(RID p_skeleton) override; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index 866fdd50ac..538ccbea6c 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -195,7 +195,7 @@ private: // Textures can be created from threads, so this RID_Owner is thread safe. mutable RID_Owner<Texture, true> texture_owner; - Texture *get_texture(RID p_rid) { return texture_owner.get_or_null(p_rid); }; + Texture *get_texture(RID p_rid) { return texture_owner.get_or_null(p_rid); } struct TextureToRDFormat { RD::DataFormat format; @@ -439,7 +439,7 @@ private: }; mutable RID_Owner<RenderTarget> render_target_owner; - RenderTarget *get_render_target(RID p_rid) const { return render_target_owner.get_or_null(p_rid); }; + RenderTarget *get_render_target(RID p_rid) const { return render_target_owner.get_or_null(p_rid); } void _clear_render_target(RenderTarget *rt); void _update_render_target(RenderTarget *rt); @@ -486,7 +486,7 @@ public: /* Canvas Texture API */ - bool owns_canvas_texture(RID p_rid) { return canvas_texture_owner.owns(p_rid); }; + bool owns_canvas_texture(RID p_rid) { return canvas_texture_owner.owns(p_rid); } virtual RID canvas_texture_allocate() override; virtual void canvas_texture_initialize(RID p_rid) override; @@ -502,7 +502,7 @@ public: /* Texture API */ - bool owns_texture(RID p_rid) const { return texture_owner.owns(p_rid); }; + bool owns_texture(RID p_rid) const { return texture_owner.owns(p_rid); } virtual RID texture_allocate() override; virtual void texture_free(RID p_rid) override; @@ -591,7 +591,7 @@ public: void update_decal_atlas(); - bool owns_decal(RID p_rid) const { return decal_owner.owns(p_rid); }; + bool owns_decal(RID p_rid) const { return decal_owner.owns(p_rid); } RID decal_atlas_get_texture() const; RID decal_atlas_get_texture_srgb() const; @@ -731,7 +731,7 @@ public: /* RENDER TARGET API */ - bool owns_render_target(RID p_rid) const { return render_target_owner.owns(p_rid); }; + bool owns_render_target(RID p_rid) const { return render_target_owner.owns(p_rid); } virtual RID render_target_create() override; virtual void render_target_free(RID p_rid) override; diff --git a/servers/rendering/renderer_rd/storage_rd/utilities.h b/servers/rendering/renderer_rd/storage_rd/utilities.h index 2ba3da7515..96508fd3ff 100644 --- a/servers/rendering/renderer_rd/storage_rd/utilities.h +++ b/servers/rendering/renderer_rd/storage_rd/utilities.h @@ -77,8 +77,8 @@ public: /* VISIBILITY NOTIFIER */ - VisibilityNotifier *get_visibility_notifier(RID p_rid) { return visibility_notifier_owner.get_or_null(p_rid); }; - bool owns_visibility_notifier(RID p_rid) const { return visibility_notifier_owner.owns(p_rid); }; + VisibilityNotifier *get_visibility_notifier(RID p_rid) { return visibility_notifier_owner.get_or_null(p_rid); } + bool owns_visibility_notifier(RID p_rid) const { return visibility_notifier_owner.owns(p_rid); } virtual RID visibility_notifier_allocate() override; virtual void visibility_notifier_initialize(RID p_notifier) override; diff --git a/servers/rendering/renderer_scene_occlusion_cull.h b/servers/rendering/renderer_scene_occlusion_cull.h index 0ef92dd9ff..14b97918ec 100644 --- a/servers/rendering/renderer_scene_occlusion_cull.h +++ b/servers/rendering/renderer_scene_occlusion_cull.h @@ -84,7 +84,7 @@ public: Vector3 view = p_cam_inv_transform.xform(corner); if (p_cam_projection.is_orthogonal()) { - min_depth = MIN(min_depth, view.z); + min_depth = MIN(min_depth, -view.z); } Plane vp = Plane(view, 1.0); @@ -234,11 +234,11 @@ public: RendererSceneOcclusionCull() { singleton = this; - }; + } virtual ~RendererSceneOcclusionCull() { singleton = nullptr; - }; + } }; #endif // RENDERER_SCENE_OCCLUSION_CULL_H diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 6eb1386749..b0e29e426b 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -1260,8 +1260,6 @@ Error RenderingDevice::_texture_initialize(RID p_texture, uint32_t p_layer, cons write_ptr = driver->buffer_map(transfer_worker->staging_buffer); ERR_FAIL_NULL_V(write_ptr, ERR_CANT_CREATE); - write_ptr += staging_worker_offset; - if (driver->api_trait_get(RDD::API_TRAIT_HONORS_PIPELINE_BARRIERS)) { // Transition the texture to the optimal layout. RDD::TextureBarrier tb; @@ -1303,11 +1301,12 @@ Error RenderingDevice::_texture_initialize(RID p_texture, uint32_t p_layer, cons if (copy_pass) { const uint8_t *read_ptr_mipmap_layer = read_ptr_mipmap + (tight_mip_size / depth) * z; - _copy_region_block_or_regular(read_ptr_mipmap_layer, write_ptr, 0, 0, width, width, height, block_w, block_h, pitch, pixel_size, block_size); - write_ptr += to_allocate; + uint64_t staging_buffer_offset = staging_worker_offset + staging_local_offset; + uint8_t *write_ptr_mipmap_layer = write_ptr + staging_buffer_offset; + _copy_region_block_or_regular(read_ptr_mipmap_layer, write_ptr_mipmap_layer, 0, 0, width, width, height, block_w, block_h, pitch, pixel_size, block_size); RDD::BufferTextureCopyRegion copy_region; - copy_region.buffer_offset = staging_worker_offset + staging_local_offset; + copy_region.buffer_offset = staging_buffer_offset; copy_region.texture_subresources.aspect = texture->read_aspect_flags; copy_region.texture_subresources.mipmap = mm_i; copy_region.texture_subresources.base_layer = p_layer; @@ -6553,6 +6552,12 @@ void RenderingDevice::finalize() { ERR_FAIL_COND(reverse_dependency_map.size()); } +void RenderingDevice::_set_max_fps(int p_max_fps) { + for (const KeyValue<DisplayServer::WindowID, RDD::SwapChainID> &it : screen_swap_chains) { + driver->swap_chain_set_max_fps(it.value, p_max_fps); + } +} + RenderingDevice *RenderingDevice::create_local_device() { RenderingDevice *rd = memnew(RenderingDevice); rd->initialize(context); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index c440e11cd4..079c50ca47 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -1427,6 +1427,8 @@ public: Error initialize(RenderingContextDriver *p_context, DisplayServer::WindowID p_main_window = DisplayServer::INVALID_WINDOW_ID); void finalize(); + void _set_max_fps(int p_max_fps); + void free(RID p_id); /****************/ diff --git a/servers/rendering/rendering_device_driver.h b/servers/rendering/rendering_device_driver.h index 637d52c060..953401e9bd 100644 --- a/servers/rendering/rendering_device_driver.h +++ b/servers/rendering/rendering_device_driver.h @@ -457,6 +457,10 @@ public: // Retrieve the format used by the swap chain's framebuffers. virtual DataFormat swap_chain_get_format(SwapChainID p_swap_chain) = 0; + // Tells the swapchain the max_fps so it can use the proper frame pacing. + // Android uses this with Swappy library. Some implementations or platforms may ignore this hint. + virtual void swap_chain_set_max_fps(SwapChainID p_swap_chain, int p_max_fps) {} + // Wait until all rendering associated to the swap chain is finished before deleting it. virtual void swap_chain_free(SwapChainID p_swap_chain) = 0; diff --git a/servers/rendering/storage/camera_attributes_storage.h b/servers/rendering/storage/camera_attributes_storage.h index 6fbcd3da7d..afb8ad23cf 100644 --- a/servers/rendering/storage/camera_attributes_storage.h +++ b/servers/rendering/storage/camera_attributes_storage.h @@ -72,8 +72,8 @@ public: RendererCameraAttributes(); ~RendererCameraAttributes(); - CameraAttributes *get_camera_attributes(RID p_rid) { return camera_attributes_owner.get_or_null(p_rid); }; - bool owns_camera_attributes(RID p_rid) { return camera_attributes_owner.owns(p_rid); }; + CameraAttributes *get_camera_attributes(RID p_rid) { return camera_attributes_owner.get_or_null(p_rid); } + bool owns_camera_attributes(RID p_rid) { return camera_attributes_owner.owns(p_rid); } RID camera_attributes_allocate(); void camera_attributes_initialize(RID p_rid); diff --git a/servers/rendering/storage/render_scene_buffers.cpp b/servers/rendering/storage/render_scene_buffers.cpp index 96e6492854..6d18ae2f77 100644 --- a/servers/rendering/storage/render_scene_buffers.cpp +++ b/servers/rendering/storage/render_scene_buffers.cpp @@ -81,7 +81,7 @@ void RenderSceneBuffersExtension::_bind_methods() { void RenderSceneBuffersExtension::configure(const RenderSceneBuffersConfiguration *p_config) { GDVIRTUAL_CALL(_configure, p_config); -}; +} void RenderSceneBuffersExtension::set_fsr_sharpness(float p_fsr_sharpness) { GDVIRTUAL_CALL(_set_fsr_sharpness, p_fsr_sharpness); diff --git a/servers/text/text_server_dummy.h b/servers/text/text_server_dummy.h index 1a945ac221..10fe3b4595 100644 --- a/servers/text/text_server_dummy.h +++ b/servers/text/text_server_dummy.h @@ -88,7 +88,7 @@ public: virtual int64_t font_get_char_from_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_glyph_index) const override { return 0; } virtual bool font_has_char(const RID &p_font_rid, int64_t p_char) const override { return false; } virtual String font_get_supported_chars(const RID &p_font_rid) const override { return String(); } - virtual PackedInt32Array font_get_supported_glyphs(const RID &p_font_rid) const override { return PackedInt32Array(); }; + virtual PackedInt32Array font_get_supported_glyphs(const RID &p_font_rid) const override { return PackedInt32Array(); } virtual void font_draw_glyph(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const override {} virtual void font_draw_glyph_outline(const RID &p_font_rid, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const override {} diff --git a/servers/text_server.h b/servers/text_server.h index 7dd9669818..f448d62cb2 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -544,8 +544,8 @@ public: virtual PackedInt32Array string_get_word_breaks(const String &p_string, const String &p_language = "", int64_t p_chars_per_line = 0) const = 0; virtual PackedInt32Array string_get_character_breaks(const String &p_string, const String &p_language = "") const; - virtual int64_t is_confusable(const String &p_string, const PackedStringArray &p_dict) const { return -1; }; - virtual bool spoof_check(const String &p_string) const { return false; }; + virtual int64_t is_confusable(const String &p_string, const PackedStringArray &p_dict) const { return -1; } + virtual bool spoof_check(const String &p_string) const { return false; } virtual String strip_diacritics(const String &p_string) const; virtual bool is_valid_identifier(const String &p_string) const; diff --git a/servers/xr/xr_interface.cpp b/servers/xr/xr_interface.cpp index 26f315a454..e9d2fc8520 100644 --- a/servers/xr/xr_interface.cpp +++ b/servers/xr/xr_interface.cpp @@ -108,7 +108,7 @@ void XRInterface::_bind_methods() { BIND_ENUM_CONSTANT(XR_ENV_BLEND_MODE_OPAQUE); BIND_ENUM_CONSTANT(XR_ENV_BLEND_MODE_ADDITIVE); BIND_ENUM_CONSTANT(XR_ENV_BLEND_MODE_ALPHA_BLEND); -}; +} bool XRInterface::is_primary() { XRServer *xr_server = XRServer::get_singleton(); @@ -155,7 +155,7 @@ PackedVector3Array XRInterface::get_play_area() const { // Note implementation is responsible for applying our reference frame and world scale to the raw data. // `play_area_changed` should be emitted if play area data is available and either the reference frame or world scale changes. return PackedVector3Array(); -}; +} /** these will only be implemented on AR interfaces, so we want dummies for VR **/ bool XRInterface::get_anchor_detection_is_enabled() const { diff --git a/servers/xr/xr_interface.h b/servers/xr/xr_interface.h index 55495731c5..abd5476fc9 100644 --- a/servers/xr/xr_interface.h +++ b/servers/xr/xr_interface.h @@ -138,7 +138,7 @@ public: virtual RID get_depth_texture(); /* obtain depth output texture (if applicable, used for reprojection) */ virtual RID get_velocity_texture(); /* obtain velocity output texture (if applicable, used for spacewarp) */ virtual void pre_render() {} - virtual bool pre_draw_viewport(RID p_render_target) { return true; }; /* inform XR interface we are about to start our viewport draw process */ + virtual bool pre_draw_viewport(RID p_render_target) { return true; } /* inform XR interface we are about to start our viewport draw process */ virtual Vector<BlitToScreen> post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) = 0; /* inform XR interface we finished our viewport draw process */ virtual void end_frame() {} diff --git a/servers/xr/xr_positional_tracker.cpp b/servers/xr/xr_positional_tracker.cpp index b479237730..225dab272f 100644 --- a/servers/xr/xr_positional_tracker.cpp +++ b/servers/xr/xr_positional_tracker.cpp @@ -61,7 +61,7 @@ void XRPositionalTracker::_bind_methods() { ADD_SIGNAL(MethodInfo("input_float_changed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::FLOAT, "value"))); ADD_SIGNAL(MethodInfo("input_vector2_changed", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::VECTOR2, "vector"))); ADD_SIGNAL(MethodInfo("profile_changed", PropertyInfo(Variant::STRING, "role"))); -}; +} void XRPositionalTracker::set_tracker_profile(const String &p_profile) { if (profile != p_profile) { @@ -77,12 +77,12 @@ String XRPositionalTracker::get_tracker_profile() const { XRPositionalTracker::TrackerHand XRPositionalTracker::get_tracker_hand() const { return tracker_hand; -}; +} void XRPositionalTracker::set_tracker_hand(const XRPositionalTracker::TrackerHand p_hand) { ERR_FAIL_INDEX(p_hand, TRACKER_HAND_MAX); tracker_hand = p_hand; -}; +} bool XRPositionalTracker::has_pose(const StringName &p_action_name) const { return poses.has(p_action_name); diff --git a/servers/xr/xr_tracker.cpp b/servers/xr/xr_tracker.cpp index 0b917a5dc3..b0b2f3f30a 100644 --- a/servers/xr/xr_tracker.cpp +++ b/servers/xr/xr_tracker.cpp @@ -42,24 +42,24 @@ void XRTracker::_bind_methods() { ClassDB::bind_method(D_METHOD("get_tracker_desc"), &XRTracker::get_tracker_desc); ClassDB::bind_method(D_METHOD("set_tracker_desc", "description"), &XRTracker::set_tracker_desc); ADD_PROPERTY(PropertyInfo(Variant::STRING, "description"), "set_tracker_desc", "get_tracker_desc"); -}; +} void XRTracker::set_tracker_type(XRServer::TrackerType p_type) { type = p_type; -}; +} XRServer::TrackerType XRTracker::get_tracker_type() const { return type; -}; +} void XRTracker::set_tracker_name(const StringName &p_name) { // Note: this should not be changed after the tracker is registered with the XRServer! name = p_name; -}; +} StringName XRTracker::get_tracker_name() const { return name; -}; +} void XRTracker::set_tracker_desc(const String &p_desc) { description = p_desc; diff --git a/tests/core/config/test_project_settings.h b/tests/core/config/test_project_settings.h index 0e1058a626..5a000b19a0 100644 --- a/tests/core/config/test_project_settings.h +++ b/tests/core/config/test_project_settings.h @@ -40,7 +40,7 @@ class TestProjectSettingsInternalsAccessor { public: static String &resource_path() { return ProjectSettings::get_singleton()->resource_path; - }; + } }; namespace TestProjectSettings { diff --git a/tests/core/object/test_object.h b/tests/core/object/test_object.h index e703698ec6..55c53e2d03 100644 --- a/tests/core/object/test_object.h +++ b/tests/core/object/test_object.h @@ -95,10 +95,10 @@ public: } bool property_can_revert(const StringName &p_name) const override { return false; - }; + } bool property_get_revert(const StringName &p_name, Variant &r_ret) const override { return false; - }; + } void get_method_list(List<MethodInfo> *p_list) const override { } bool has_method(const StringName &p_method) const override { diff --git a/thirdparty/swappy-frame-pacing/common/gamesdk_common.h b/thirdparty/swappy-frame-pacing/common/gamesdk_common.h new file mode 100644 index 0000000000..d29ac01af3 --- /dev/null +++ b/thirdparty/swappy-frame-pacing/common/gamesdk_common.h @@ -0,0 +1,41 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This is the main interface to the Android Performance Tuner library, also + * known as Tuning Fork. + * + * It is part of the Android Games SDK and produces best results when integrated + * with the Swappy Frame Pacing Library. + * + * See the documentation at + * https://developer.android.com/games/sdk/performance-tuner/custom-engine for + * more information on using this library in a native Android game. + * + */ + +#pragma once + +// There are separate versions for each GameSDK component that use this format: +#define ANDROID_GAMESDK_PACKED_VERSION(MAJOR, MINOR, BUGFIX) \ + ((MAJOR << 16) | (MINOR << 8) | (BUGFIX)) +// Accessors +#define ANDROID_GAMESDK_MAJOR_VERSION(PACKED) ((PACKED) >> 16) +#define ANDROID_GAMESDK_MINOR_VERSION(PACKED) (((PACKED) >> 8) & 0xff) +#define ANDROID_GAMESDK_BUGFIX_VERSION(PACKED) ((PACKED) & 0xff) + +#define AGDK_STRING_VERSION(MAJOR, MINOR, BUGFIX, GIT) \ +#MAJOR "." #MINOR "." #BUGFIX "." #GIT diff --git a/thirdparty/swappy-frame-pacing/swappyVk.h b/thirdparty/swappy-frame-pacing/swappyVk.h new file mode 100644 index 0000000000..020683cbc4 --- /dev/null +++ b/thirdparty/swappy-frame-pacing/swappyVk.h @@ -0,0 +1,420 @@ +/* + * Copyright 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @defgroup swappyVk Swappy for Vulkan + * Vulkan part of Swappy. + * @{ + */ + +#pragma once + +#include "jni.h" +#include "swappy_common.h" + +#ifndef VK_NO_PROTOTYPES +#define VK_NO_PROTOTYPES 1 +#endif +#include <vulkan/vulkan.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Determine any Vulkan device extensions that must be enabled for a new + * VkDevice. + * + * Swappy-for-Vulkan (SwappyVk) benefits from certain Vulkan device extensions + * (e.g. VK_GOOGLE_display_timing). Before the application calls + * vkCreateDevice, SwappyVk needs to look at the list of available extensions + * (returned by vkEnumerateDeviceExtensionProperties) and potentially identify + * one or more extensions that the application must add to: + * + * - VkDeviceCreateInfo::enabledExtensionCount + * - VkDeviceCreateInfo::ppEnabledExtensionNames + * + * before the application calls vkCreateDevice. For each VkPhysicalDevice that + * the application will call vkCreateDevice for, the application must call this + * function, and then must add the identified extension(s) to the list that are + * enabled for the VkDevice. Similar to many Vulkan functions, this function + * can be called twice, once to identify the number of required extensions, and + * again with application-allocated memory that the function can write into. + * + * @param[in] physicalDevice - The VkPhysicalDevice associated with + * the available extensions. + * @param[in] availableExtensionCount - This is the returned value of + * pPropertyCount from vkEnumerateDeviceExtensionProperties. + * @param[in] pAvailableExtensions - This is the returned value of + * pProperties from vkEnumerateDeviceExtensionProperties. + * @param[inout] pRequiredExtensionCount - If pRequiredExtensions is nullptr, + * the function sets this to the number of extensions that are required. If + * pRequiredExtensions is non-nullptr, this is the number of required extensions + * that the function should write into pRequiredExtensions. + * @param[inout] pRequiredExtensions - If non-nullptr, this is + * application-allocated memory into which the function will write the names of + * required extensions. It is a pointer to an array of + * char* strings (i.e. the same as + * VkDeviceCreateInfo::ppEnabledExtensionNames). + */ +void SwappyVk_determineDeviceExtensions( + VkPhysicalDevice physicalDevice, uint32_t availableExtensionCount, + VkExtensionProperties* pAvailableExtensions, + uint32_t* pRequiredExtensionCount, char** pRequiredExtensions); + +/** + * @brief Tell Swappy the queueFamilyIndex used to create a specific VkQueue + * + * Swappy needs to know the queueFamilyIndex used for creating a specific + * VkQueue so it can use it when presenting. + * + * @param[in] device - The VkDevice associated with the queue + * @param[in] queue - A device queue. + * @param[in] queueFamilyIndex - The queue family index used to create the + * VkQueue. + * + */ +void SwappyVk_setQueueFamilyIndex(VkDevice device, VkQueue queue, + uint32_t queueFamilyIndex); + +// TBD: For now, SwappyVk assumes only one VkSwapchainKHR per VkDevice, and that +// applications don't re-create swapchains. Is this long-term sufficient? + +/** + * Internal init function. Do not call directly. + * See SwappyVk_initAndGetRefreshCycleDuration instead. + * @private + */ +bool SwappyVk_initAndGetRefreshCycleDuration_internal( + JNIEnv* env, jobject jactivity, VkPhysicalDevice physicalDevice, + VkDevice device, VkSwapchainKHR swapchain, uint64_t* pRefreshDuration); + +/** + * @brief Initialize SwappyVk for a given device and swapchain, and obtain the + * approximate time duration between vertical-blanking periods. + * + * Uses JNI to query AppVsyncOffset and PresentationDeadline. + * + * If your application presents to more than one swapchain at a time, you must + * call this for each swapchain before calling swappyVkSetSwapInterval() for it. + * + * The duration between vertical-blanking periods (an interval) is expressed as + * the approximate number of nanoseconds between vertical-blanking periods of + * the swapchain’s physical display. + * + * If the application converts this number to a fraction (e.g. 16,666,666 nsec + * to 0.016666666) and divides one by that fraction, it will be the approximate + * refresh rate of the display (e.g. 16,666,666 nanoseconds corresponds to a + * 60Hz display, 11,111,111 nsec corresponds to a 90Hz display). + * + * @param[in] env - JNIEnv that is assumed to be from AttachCurrentThread + * function + * @param[in] jactivity - NativeActivity object handle, used for JNI + * @param[in] physicalDevice - The VkPhysicalDevice associated with the + * swapchain + * @param[in] device - The VkDevice associated with the swapchain + * @param[in] swapchain - The VkSwapchainKHR the application wants Swappy to + * swap + * @param[out] pRefreshDuration - The returned refresh cycle duration + * + * @return bool - true if the value returned by pRefreshDuration is + * valid, otherwise false if an error. + */ +bool SwappyVk_initAndGetRefreshCycleDuration(JNIEnv* env, jobject jactivity, + VkPhysicalDevice physicalDevice, + VkDevice device, + VkSwapchainKHR swapchain, + uint64_t* pRefreshDuration); + +/** + * @brief Tell Swappy which ANativeWindow to use when calling to ANativeWindow_* + * API. + * @param[in] device - The VkDevice associated with the swapchain + * @param[in] swapchain - The VkSwapchainKHR the application wants Swappy to + * swap + * @param[in] window - The ANativeWindow that was used to create the + * VkSwapchainKHR + */ +void SwappyVk_setWindow(VkDevice device, VkSwapchainKHR swapchain, + ANativeWindow* window); + +/** + * @brief Tell Swappy the duration of that each presented image should be + * visible. + * + * If your application presents to more than one swapchain at a time, you must + * call this for each swapchain before presenting to it. + * + * @param[in] device - The VkDevice associated with the swapchain + * @param[in] swapchain - The VkSwapchainKHR the application wants Swappy to + * swap + * @param[in] swap_ns - The duration of that each presented image should be + * visible in nanoseconds + */ +void SwappyVk_setSwapIntervalNS(VkDevice device, VkSwapchainKHR swapchain, + uint64_t swap_ns); + +/** + * @brief Tell Swappy to present one or more images to corresponding swapchains. + * + * Swappy will call vkQueuePresentKHR for your application. Swappy may insert a + * struct to the pNext-chain of VkPresentInfoKHR, or it may insert other Vulkan + * commands in order to attempt to honor the desired swap interval. + * + * @note If your application presents to more than one swapchain at a time, and + * if you use a different swap interval for each swapchain, Swappy will attempt + * to honor the swap interval for each swapchain (being more successful on + * devices that support an underlying presentation-timing extension, such as + * VK_GOOGLE_display_timing). + * + * @param[in] queue - The VkQueue associated with the device and swapchain + * @param[in] pPresentInfo - A pointer to the VkPresentInfoKHR containing the + * information about what image(s) to present on which + * swapchain(s). + */ +VkResult SwappyVk_queuePresent(VkQueue queue, + const VkPresentInfoKHR* pPresentInfo); + +/** + * @brief Destroy the SwappyVk instance associated with a swapchain. + * + * This API is expected to be called before calling vkDestroySwapchainKHR() + * so Swappy can cleanup its internal state. + * + * @param[in] device - The VkDevice associated with SwappyVk + * @param[in] swapchain - The VkSwapchainKHR the application wants Swappy to + * destroy + */ +void SwappyVk_destroySwapchain(VkDevice device, VkSwapchainKHR swapchain); + +/** + * @brief Destroy any swapchains associated with the device and clean up the + * device's resources + * + * This function should be called after SwappyVk_destroySwapchain if you no + * longer need the device. + * + * @param[in] device - The VkDevice associated with SwappyVk + */ +void SwappyVk_destroyDevice(VkDevice device); + +/** + * @brief Enables Auto-Swap-Interval feature for all instances. + * + * By default this feature is enabled. Changing it is completely + * optional for fine-tuning swappy behaviour. + * + * @param[in] enabled - True means enable, false means disable + */ +void SwappyVk_setAutoSwapInterval(bool enabled); + +/** + * @brief Enables Auto-Pipeline-Mode feature for all instances. + * + * By default this feature is enabled. Changing it is completely + * optional for fine-tuning swappy behaviour. + * + * @param[in] enabled - True means enable, false means disable + */ +void SwappyVk_setAutoPipelineMode(bool enabled); + +/** + * @brief Sets the maximal swap duration for all instances. + * + * Sets the maximal duration for Auto-Swap-Interval in milliseconds. + * If SwappyVk is operating in Auto-Swap-Interval and the frame duration is + * longer than the provided duration, SwappyVk will not do any pacing and just + * submit the frame as soon as possible. + * + * @param[in] max_swap_ns - maximal swap duration in milliseconds. + */ +void SwappyVk_setMaxAutoSwapIntervalNS(uint64_t max_swap_ns); + +/** + * @brief The fence timeout parameter can be set for devices with faulty + * drivers. Its default value is 50,000,000. + */ +void SwappyVk_setFenceTimeoutNS(uint64_t fence_timeout_ns); + +/** + * @brief Get the fence timeout parameter, for devices with faulty + * drivers. Its default value is 50,000,000. + */ +uint64_t SwappyVk_getFenceTimeoutNS(); + +/** + * @brief Inject callback functions to be called each frame. + * + * @param[in] tracer - Collection of callback functions + */ +void SwappyVk_injectTracer(const SwappyTracer* tracer); + +/** + * @brief Remove callbacks that were previously added using + * SwappyVk_injectTracer. + * + * Only removes callbacks that were previously added using + * SwappyVK_injectTracer. If SwappyVK_injectTracker was not called with the + * tracer, then there is no effect. + * + * @param[in] tracer - Collection of callback functions + */ +void SwappyVk_uninjectTracer(const SwappyTracer* tracer); + +/** + * @brief A structure enabling you to provide your own Vulkan function wrappers + * by calling ::SwappyVk_setFunctionProvider. + * + * Usage of this functionality is optional. + */ +typedef struct SwappyVkFunctionProvider { + /** + * @brief Callback to initialize the function provider. + * + * This function is called by Swappy before any functions are requested. + * E.g. so you can call dlopen on the Vulkan library. + */ + bool (*init)(); + + /** + * @brief Callback to get the address of a function. + * + * This function is called by Swappy to get the address of a Vulkan + * function. + * @param name The null-terminated name of the function. + */ + void* (*getProcAddr)(const char* name); + + /** + * @brief Callback to close any resources owned by the function provider. + * + * This function is called by Swappy when no more functions will be + * requested, e.g. so you can call dlclose on the Vulkan library. + */ + void (*close)(); +} SwappyVkFunctionProvider; + +/** + * @brief Set the Vulkan function provider. + * + * This enables you to provide an object that will be used to look up Vulkan + * functions, e.g. to hook usage of these functions. + * + * To use this functionality, you *must* call this function before any others. + * + * Usage of this function is entirely optional. If you do not use it, the Vulkan + * functions required by Swappy will be dynamically loaded from libvulkan.so. + * + * @param[in] provider - provider object + */ +void SwappyVk_setFunctionProvider( + const SwappyVkFunctionProvider* pSwappyVkFunctionProvider); + +/** + * @brief Get the swap interval value, in nanoseconds, for a given swapchain. + * + * @param[in] swapchain - the swapchain to query + */ +uint64_t SwappyVk_getSwapIntervalNS(VkSwapchainKHR swapchain); + +/** + * @brief Get the supported refresh periods of this device. Call once with + * out_refreshrates set to nullptr to get the number of supported refresh + * periods, then call again passing that number as allocated_entries and + * an array of size equal to allocated_entries that will be filled with the + * refresh periods. + */ +int SwappyVk_getSupportedRefreshPeriodsNS(uint64_t* out_refreshrates, + int allocated_entries, + VkSwapchainKHR swapchain); +/** + * @brief Check if Swappy is enabled for the specified swapchain. + * + * @return false if SwappyVk_initAndGetRefreshCycleDuration was not + * called for the specified swapchain, true otherwise. + */ +bool SwappyVk_isEnabled(VkSwapchainKHR swapchain, bool* isEnabled); + +/** + * @brief Toggle statistics collection on/off + * + * By default, stats collection is off and there is no overhead related to + * stats. An app can turn on stats collection by calling + * `SwappyVk_enableStats(swapchain, true)`. Then, the app is expected to call + * ::SwappyVk_recordFrameStart for each frame before starting to do any CPU + * related work. Stats will be logged to logcat with a 'FrameStatistics' tag. An + * app can get the stats by calling ::SwappyVk_getStats. + * + * SwappyVk_initAndGetRefreshCycleDuration must have been called successfully + * before for this swapchain, otherwise there is no effect in this call. Frame + * stats are only available if the platform supports VK_GOOGLE_display_timing + * extension. + * + * @param[in] swapchain - The swapchain for which frame stat collection is + * configured. + * @param enabled - Whether to enable/disable frame stat collection. + */ +void SwappyVk_enableStats(VkSwapchainKHR swapchain, bool enabled); + +/** + * @brief Should be called if stats have been enabled with SwappyVk_enableStats. + * + * When stats collection is enabled with SwappyVk_enableStats, the app is + * expected to call this function for each frame before starting to do any CPU + * related work. It is assumed that this function will be called after a + * successful call to vkAcquireNextImageKHR. See ::SwappyVk_enableStats for more + * conditions. + * + * @param[in] queue - The VkQueue associated with the device and swapchain + * @param[in] swapchain - The swapchain where the frame is presented to. + * @param[in] image - The image in swapchain that corresponds to the frame. + + * @see SwappyVk_enableStats. + */ +void SwappyVk_recordFrameStart(VkQueue queue, VkSwapchainKHR swapchain, uint32_t image); + +/** + * @brief Returns the stats collected, if statistics collection was toggled on. + * + * Given that this API uses VkSwapchainKHR and the potential for this call to be + * done on different threads, all calls to ::SwappyVk_getStats + * must be externally synchronized with other SwappyVk calls. Unsynchronized + * calls may lead to undefined behavior. See ::SwappyVk_enableStats for more + * conditions. + * + * @param[in] swapchain - The swapchain for which stats are being queried. + * @param swappyStats - Pointer to a SwappyStats that will be populated with + * the collected stats. Cannot be NULL. + * @see SwappyStats + */ +void SwappyVk_getStats(VkSwapchainKHR swapchain, SwappyStats *swappyStats); + +/** + * @brief Clears the frame statistics collected so far. + * + * All the frame statistics collected are reset to 0, frame statistics are + * collected normally after this call. See ::SwappyVk_enableStats for more + * conditions. + * + * @param[in] swapchain - The swapchain for which stats are being cleared. + */ +void SwappyVk_clearStats(VkSwapchainKHR swapchain); + +#ifdef __cplusplus +} // extern "C" +#endif + +/** @} */ diff --git a/thirdparty/swappy-frame-pacing/swappy_common.h b/thirdparty/swappy-frame-pacing/swappy_common.h new file mode 100644 index 0000000000..b711ca910f --- /dev/null +++ b/thirdparty/swappy-frame-pacing/swappy_common.h @@ -0,0 +1,278 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @defgroup swappy_common Swappy common tools + * Tools to be used with Swappy for OpenGL or Swappy for Vulkan. + * @{ + */ + +#pragma once + +#include <android/native_window.h> +#include <stdint.h> + +#include "common/gamesdk_common.h" + +/** @brief Swap interval for 60fps, in nanoseconds. */ +#define SWAPPY_SWAP_60FPS (16666667L) + +/** @brief Swap interval for 30fps, in nanoseconds. */ +#define SWAPPY_SWAP_30FPS (33333333L) + +/** @brief Swap interval for 20fps, in nanoseconds. */ +#define SWAPPY_SWAP_20FPS (50000000L) + +/** + * The longest duration, in refresh periods, represented by the statistics. + * @see SwappyStats + */ +#define MAX_FRAME_BUCKETS 6 + +/** @cond INTERNAL */ + +#define SWAPPY_SYSTEM_PROP_KEY_DISABLE "swappy.disable" + +// Internal macros to track Swappy version, do not use directly. +#define SWAPPY_MAJOR_VERSION 2 +#define SWAPPY_MINOR_VERSION 0 +#define SWAPPY_BUGFIX_VERSION 0 +#define SWAPPY_PACKED_VERSION \ + ANDROID_GAMESDK_PACKED_VERSION(SWAPPY_MAJOR_VERSION, SWAPPY_MINOR_VERSION, \ + SWAPPY_BUGFIX_VERSION) + +// Internal macros to generate a symbol to track Swappy version, do not use +// directly. +#define SWAPPY_VERSION_CONCAT_NX(PREFIX, MAJOR, MINOR, BUGFIX, GITCOMMIT) \ + PREFIX##_##MAJOR##_##MINOR##_##BUGFIX##_##GITCOMMIT +#define SWAPPY_VERSION_CONCAT(PREFIX, MAJOR, MINOR, BUGFIX, GITCOMMIT) \ + SWAPPY_VERSION_CONCAT_NX(PREFIX, MAJOR, MINOR, BUGFIX, GITCOMMIT) +#define SWAPPY_VERSION_SYMBOL \ + SWAPPY_VERSION_CONCAT(Swappy_version, SWAPPY_MAJOR_VERSION, \ + SWAPPY_MINOR_VERSION, SWAPPY_BUGFIX_VERSION, \ + AGDK_GIT_COMMIT) + +// Define this to 1 to enable all logging from Swappy, by default it is +// disabled in a release build and enabled in a debug build. +#ifndef ENABLE_SWAPPY_LOGGING +#define ENABLE_SWAPPY_LOGGING 0 +#endif +/** @endcond */ + +/** @brief Id of a thread returned by an external thread manager. */ +typedef uint64_t SwappyThreadId; + +/** + * @brief A structure enabling you to set how Swappy starts and joins threads by + * calling + * ::Swappy_setThreadFunctions. + * + * Usage of this functionality is optional. + */ +typedef struct SwappyThreadFunctions { + /** @brief Thread start callback. + * + * This function is called by Swappy to start thread_func on a new thread. + * @param user_data A value to be passed the thread function. + * If the thread was started, this function should set the thread_id and + * return 0. If the thread was not started, this function should return a + * non-zero value. + */ + int (*start)(SwappyThreadId* thread_id, void* (*thread_func)(void*), + void* user_data); + + /** @brief Thread join callback. + * + * This function is called by Swappy to join the thread with given id. + */ + void (*join)(SwappyThreadId thread_id); + + /** @brief Thread joinable callback. + * + * This function is called by Swappy to discover whether the thread with the + * given id is joinable. + */ + bool (*joinable)(SwappyThreadId thread_id); +} SwappyThreadFunctions; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Return the version of the Swappy library at runtime. + */ +uint32_t Swappy_version(); + +/** + * @brief Call this before any other functions in order to use a custom thread + * manager. + * + * Usage of this function is entirely optional. Swappy uses std::thread by + * default. + * + */ +void Swappy_setThreadFunctions(const SwappyThreadFunctions* thread_functions); + +/** + * @brief Return the full version of the Swappy library at runtime, e.g. + * "1.9.0_8a85ab7c46" + */ +const char* Swappy_versionString(); + +/** + * @brief Swappy frame statistics, collected if toggled on with + * ::SwappyGL_enableStats or ::SwappyVk_enableStats. + */ +typedef struct SwappyStats { + /** @brief Total frames swapped by swappy */ + uint64_t totalFrames; + + /** @brief Histogram of the number of screen refreshes a frame waited in the + * compositor queue after rendering was completed. + * + * For example: + * if a frame waited 2 refresh periods in the compositor queue after + * rendering was done, the frame will be counted in idleFrames[2] + */ + uint64_t idleFrames[MAX_FRAME_BUCKETS]; + + /** @brief Histogram of the number of screen refreshes passed between the + * requested presentation time and the actual present time. + * + * For example: + * if a frame was presented 2 refresh periods after the requested + * timestamp swappy set, the frame will be counted in lateFrames[2] + */ + uint64_t lateFrames[MAX_FRAME_BUCKETS]; + + /** @brief Histogram of the number of screen refreshes passed between two + * consecutive frames + * + * For example: + * if frame N was presented 2 refresh periods after frame N-1 + * frame N will be counted in offsetFromPreviousFrame[2] + */ + uint64_t offsetFromPreviousFrame[MAX_FRAME_BUCKETS]; + + /** @brief Histogram of the number of screen refreshes passed between the + * call to Swappy_recordFrameStart and the actual present time. + * + * For example: + * if a frame was presented 2 refresh periods after the call to + * `Swappy_recordFrameStart` the frame will be counted in latencyFrames[2] + */ + uint64_t latencyFrames[MAX_FRAME_BUCKETS]; +} SwappyStats; + + +#ifdef __cplusplus +} // extern "C" +#endif + +/** + * Pointer to a function that can be attached to SwappyTracer::preWait + * @param userData Pointer to arbitrary data, see SwappyTracer::userData. + */ +typedef void (*SwappyPreWaitCallback)(void*); + +/** + * Pointer to a function that can be attached to SwappyTracer::postWait. + * @param userData Pointer to arbitrary data, see SwappyTracer::userData. + * @param cpu_time_ns Time for CPU processing of this frame in nanoseconds. + * @param gpu_time_ns Time for GPU processing of previous frame in nanoseconds. + */ +typedef void (*SwappyPostWaitCallback)(void*, int64_t cpu_time_ns, + int64_t gpu_time_ns); + +/** + * Pointer to a function that can be attached to SwappyTracer::preSwapBuffers. + * @param userData Pointer to arbitrary data, see SwappyTracer::userData. + */ +typedef void (*SwappyPreSwapBuffersCallback)(void*); + +/** + * Pointer to a function that can be attached to SwappyTracer::postSwapBuffers. + * @param userData Pointer to arbitrary data, see SwappyTracer::userData. + * @param desiredPresentationTimeMillis The target time, in milliseconds, at + * which the frame would be presented on screen. + */ +typedef void (*SwappyPostSwapBuffersCallback)( + void*, int64_t desiredPresentationTimeMillis); + +/** + * Pointer to a function that can be attached to SwappyTracer::startFrame. + * @param userData Pointer to arbitrary data, see SwappyTracer::userData. + * @param desiredPresentationTimeMillis The time, in milliseconds, at which the + * frame is scheduled to be presented. + */ +typedef void (*SwappyStartFrameCallback)(void*, int currentFrame, + int64_t desiredPresentationTimeMillis); + +/** + * Pointer to a function that can be attached to + * SwappyTracer::swapIntervalChanged. Call ::SwappyGL_getSwapIntervalNS or + * ::SwappyVk_getSwapIntervalNS to get the latest swapInterval. + * @param userData Pointer to arbitrary data, see SwappyTracer::userData. + */ +typedef void (*SwappySwapIntervalChangedCallback)(void*); + +/** + * @brief Collection of callbacks to be called each frame to trace execution. + * + * Injection of these is optional. + */ +typedef struct SwappyTracer { + /** + * Callback called before waiting to queue the frame to the composer. + */ + SwappyPreWaitCallback preWait; + + /** + * Callback called after wait to queue the frame to the composer is done. + */ + SwappyPostWaitCallback postWait; + + /** + * Callback called before calling the function to queue the frame to the + * composer. + */ + SwappyPreSwapBuffersCallback preSwapBuffers; + + /** + * Callback called after calling the function to queue the frame to the + * composer. + */ + SwappyPostSwapBuffersCallback postSwapBuffers; + + /** + * Callback called at the start of a frame. + */ + SwappyStartFrameCallback startFrame; + + /** + * Pointer to some arbitrary data that will be passed as the first argument + * of callbacks. + */ + void* userData; + + /** + * Callback called when the swap interval was changed. + */ + SwappySwapIntervalChangedCallback swapIntervalChanged; +} SwappyTracer; + +/** @} */ |