diff options
29 files changed, 163 insertions, 118 deletions
diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index ed4ef01012..666b10d016 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -19,13 +19,6 @@ jobs: steps: - uses: actions/checkout@v3 - # Azure repositories are not reliable, we need to prevent azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories - run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list - sudo apt-get update - - name: Set up Java 11 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index bfda7c72f8..46a9228616 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -74,16 +74,13 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Linux dependencies - shell: bash + # Need newer mesa for lavapipe to work properly. + - name: Linux dependencies for tests + if: ${{ matrix.proj-test }} run: | - # Azure repositories are not reliable, we need to prevent azure giving us packages. - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo add-apt-repository ppa:kisak/kisak-mesa sudo apt-get update - # The actual dependencies - sudo apt-get install build-essential pkg-config libgl1-mesa-dev libglu-dev \ - xvfb wget unzip llvm + sudo apt-get install -qq mesa-vulkan-drivers - name: Setup Godot build cache uses: ./.github/actions/godot-cache @@ -138,16 +135,6 @@ jobs: ${{ matrix.bin }} --doctool --headless 2>&1 > /dev/null || true git diff --color --exit-code && ! git ls-files --others --exclude-standard | sed -e 's/^/New doc file missing in PR: /' | grep 'xml$' - # Download, unzip and setup SwiftShader library - # See https://github.com/godotengine/regression-test-project/releases/tag/_ci-deps for details - - name: Download SwiftShader - if: ${{ matrix.tests }} - run: | - wget https://github.com/godotengine/regression-test-project/releases/download/_ci-deps/swiftshader-ubuntu20.04-20211002.zip - unzip swiftshader-ubuntu20.04-20211002.zip - curr="$(pwd)/libvk_swiftshader.so" - sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json - # Test 3.x -> 4.x project converter - name: Test project converter if: ${{ matrix.proj-conv }} @@ -155,7 +142,7 @@ jobs: mkdir converter_test cd converter_test touch project.godot - ../${{ matrix.bin }} --headless --audio-driver Dummy --validate-conversion-3to4 + ../${{ matrix.bin }} --headless --validate-conversion-3to4 cd .. rm converter_test -rf @@ -171,7 +158,7 @@ jobs: - name: Open and close editor (Vulkan) if: ${{ matrix.proj-test }} run: | - VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true + xvfb-run ${{ matrix.bin }} --audio-driver Dummy --editor --quit --path test_project 2>&1 | tee sanitizers_log.txt || true misc/scripts/check_ci_log.py sanitizers_log.txt - name: Open and close editor (GLES3) @@ -184,7 +171,7 @@ jobs: - name: Run project if: ${{ matrix.proj-test }} run: | - VK_ICD_FILENAMES=$(pwd)/vk_swiftshader_icd.json DRI_PRIME=0 xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true + xvfb-run ${{ matrix.bin }} 40 --audio-driver Dummy --path test_project 2>&1 | tee sanitizers_log.txt || true misc/scripts/check_ci_log.py sanitizers_log.txt # Checkout godot-cpp diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index eece270dd9..a3722e19ce 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -13,17 +13,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 - # Azure repositories are not reliable, we need to prevent Azure giving us packages. - - name: Make apt sources.list use the default Ubuntu repositories + - name: Install dependencies run: | - sudo rm -f /etc/apt/sources.list.d/* - sudo cp -f misc/ci/sources.list /etc/apt/sources.list wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" sudo apt-get update - - - name: Install dependencies - run: | sudo apt-get install -qq dos2unix clang-format-15 libxml2-utils python3-pip moreutils sudo update-alternatives --remove-all clang-format || true sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100 diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h index 876a09beff..9593afc2fb 100644 --- a/core/extension/gdextension_interface.h +++ b/core/extension/gdextension_interface.h @@ -37,7 +37,6 @@ #include <stddef.h> #include <stdint.h> -#include <stdio.h> #ifndef __cplusplus typedef uint32_t char32_t; diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 2e1adb9167..d156c35343 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -225,6 +225,9 @@ void Array::assign(const Array &p_array) { _p->array = p_array._p->array; return; } + if (typed.type == Variant::OBJECT || source_typed.type == Variant::OBJECT) { + ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", Variant::get_type_name(source_typed.type), Variant::get_type_name(typed.type))); + } Vector<Variant> array; array.resize(size); diff --git a/core/variant/container_type_validate.h b/core/variant/container_type_validate.h index 796b66dc77..ad679db9d0 100644 --- a/core/variant/container_type_validate.h +++ b/core/variant/container_type_validate.h @@ -41,34 +41,26 @@ struct ContainerTypeValidate { const char *where = "container"; _FORCE_INLINE_ bool can_reference(const ContainerTypeValidate &p_type) const { - if (type == p_type.type) { - if (type != Variant::OBJECT) { - return true; //nothing else to check - } - } else { + if (type != p_type.type) { return false; + } else if (type != Variant::OBJECT) { + return true; } - //both are object - - if ((class_name != StringName()) != (p_type.class_name != StringName())) { - return false; //both need to have class or none - } - - if (class_name != p_type.class_name) { - if (!ClassDB::is_parent_class(p_type.class_name, class_name)) { - return false; - } - } - - if (script.is_null() != p_type.script.is_null()) { + if (class_name == StringName()) { + return true; + } else if (p_type.class_name == StringName()) { + return false; + } else if (class_name != p_type.class_name && !ClassDB::is_parent_class(p_type.class_name, class_name)) { return false; } - if (script != p_type.script) { - if (!p_type.script->inherits_script(script)) { - return false; - } + if (script.is_null()) { + return true; + } else if (p_type.script.is_null()) { + return false; + } else if (script != p_type.script && !p_type.script->inherits_script(script)) { + return false; } return true; diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c9eae77b53..33bba90c70 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -4593,7 +4593,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_ } break; case Variant::PACKED_STRING_ARRAY: { EditorPropertyArray *editor = memnew(EditorPropertyArray); - editor->setup(Variant::PACKED_STRING_ARRAY); + editor->setup(Variant::PACKED_STRING_ARRAY, p_hint_text); return editor; } break; case Variant::PACKED_VECTOR2_ARRAY: { diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index b96ac9dbcb..24cfa7ad7b 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -574,7 +574,7 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint // The format of p_hint_string is: // subType/subTypeHint:nextSubtype ... etc. - if (array_type == Variant::ARRAY && !p_hint_string.is_empty()) { + if (!p_hint_string.is_empty()) { int hint_subtype_separator = p_hint_string.find(":"); if (hint_subtype_separator >= 0) { String subtype_string = p_hint_string.substr(0, hint_subtype_separator); diff --git a/misc/ci/sources.list b/misc/ci/sources.list deleted file mode 100644 index 4d8f94f35c..0000000000 --- a/misc/ci/sources.list +++ /dev/null @@ -1,4 +0,0 @@ -deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse -deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index cafc7328e0..cd1dcf9a78 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2471,30 +2471,27 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) { return; } - GDScriptParser::DataType awaiting_type; - if (p_await->to_await->type == GDScriptParser::Node::CALL) { reduce_call(static_cast<GDScriptParser::CallNode *>(p_await->to_await), true); - awaiting_type = p_await->to_await->get_datatype(); } else { reduce_expression(p_await->to_await); } - if (p_await->to_await->is_constant) { + GDScriptParser::DataType await_type = p_await->to_await->get_datatype(); + // We cannot infer the type of the result of waiting for a signal. + if (await_type.is_hard_type() && await_type.kind == GDScriptParser::DataType::BUILTIN && await_type.builtin_type == Variant::SIGNAL) { + await_type.kind = GDScriptParser::DataType::VARIANT; + await_type.type_source = GDScriptParser::DataType::UNDETECTED; + } else if (p_await->to_await->is_constant) { p_await->is_constant = p_await->to_await->is_constant; p_await->reduced_value = p_await->to_await->reduced_value; - - awaiting_type = p_await->to_await->get_datatype(); - } else { - awaiting_type.kind = GDScriptParser::DataType::VARIANT; - awaiting_type.type_source = GDScriptParser::DataType::UNDETECTED; } - - p_await->set_datatype(awaiting_type); + await_type.is_coroutine = false; + p_await->set_datatype(await_type); #ifdef DEBUG_ENABLED - awaiting_type = p_await->to_await->get_datatype(); - if (!(awaiting_type.has_no_type() || awaiting_type.is_coroutine || awaiting_type.builtin_type == Variant::SIGNAL)) { + GDScriptParser::DataType to_await_type = p_await->to_await->get_datatype(); + if (!(to_await_type.has_no_type() || to_await_type.is_coroutine || to_await_type.builtin_type == Variant::SIGNAL)) { parser->push_warning(p_await, GDScriptWarning::REDUNDANT_AWAIT); } #endif diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 4e7d278aab..8cfd48b52b 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -977,7 +977,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, } break; case GDScriptParser::ClassNode::Member::SIGNAL: - if (p_only_functions || outer) { + if (p_only_functions || outer || p_static) { continue; } option = ScriptLanguage::CodeCompletionOption(member.signal->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); @@ -1033,6 +1033,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location); r_result.insert(option.display, option); } + + List<MethodInfo> signals; + scr->get_script_signal_list(&signals); + for (const MethodInfo &E : signals) { + int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); + r_result.insert(option.display, option); + } } HashMap<StringName, Variant> constants; scr->get_constants(&constants); @@ -1041,14 +1049,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base ScriptLanguage::CodeCompletionOption option(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT, location); r_result.insert(option.display, option); } - - List<MethodInfo> signals; - scr->get_script_signal_list(&signals); - for (const MethodInfo &E : signals) { - int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name); - ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); - r_result.insert(option.display, option); - } } List<MethodInfo> methods; @@ -1093,14 +1093,6 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base r_result.insert(option.display, option); } - List<MethodInfo> signals; - ClassDB::get_signal_list(type, &signals); - for (const MethodInfo &E : signals) { - int location = p_recursion_depth + _get_signal_location(type, StringName(E.name)); - ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); - r_result.insert(option.display, option); - } - if (!base_type.is_meta_type || Engine::get_singleton()->has_singleton(type)) { List<PropertyInfo> pinfo; ClassDB::get_property_list(type, &pinfo); @@ -1115,6 +1107,14 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER, location); r_result.insert(option.display, option); } + + List<MethodInfo> signals; + ClassDB::get_signal_list(type, &signals); + for (const MethodInfo &E : signals) { + int location = p_recursion_depth + _get_signal_location(type, StringName(E.name)); + ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL, location); + r_result.insert(option.display, option); + } } } @@ -2031,6 +2031,7 @@ static bool _guess_identifier_type(GDScriptParser::CompletionContext &p_context, r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; r_type.type.script_path = script; r_type.type.class_type = parser->get_parser()->get_tree(); + r_type.type.is_meta_type = true; r_type.type.is_constant = false; r_type.type.kind = GDScriptParser::DataType::CLASS; r_type.value = Variant(); @@ -2142,6 +2143,7 @@ static bool _guess_identifier_type_from_base(GDScriptParser::CompletionContext & r_type.type.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; r_type.type.kind = GDScriptParser::DataType::CLASS; r_type.type.class_type = member.m_class; + r_type.type.is_meta_type = true; return true; case GDScriptParser::ClassNode::Member::GROUP: return false; // No-op, but silences warnings. diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 2ec7f77201..0a1a64cb59 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3619,7 +3619,7 @@ bool GDScriptParser::icon_annotation(const AnnotationNode *p_annotation, Node *p bool GDScriptParser::onready_annotation(const AnnotationNode *p_annotation, Node *p_node) { ERR_FAIL_COND_V_MSG(p_node->type != Node::VARIABLE, false, R"("@onready" annotation can only be applied to class variables.)"); - if (head && !ClassDB::is_parent_class(head->get_datatype().native_type, SNAME("Node"))) { + if (current_class && !ClassDB::is_parent_class(current_class->get_datatype().native_type, SNAME("Node"))) { push_error(R"("@onready" can only be used in classes that inherit "Node".)", p_annotation); } @@ -3697,6 +3697,13 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node variable->export_info.type = Variant::DICTIONARY; return true; + } else if (export_type.builtin_type == Variant::PACKED_STRING_ARRAY) { + String hint_prefix = itos(Variant::STRING) + "/" + itos(variable->export_info.hint); + variable->export_info.hint = PROPERTY_HINT_TYPE_STRING; + variable->export_info.hint_string = hint_prefix + ":" + variable->export_info.hint_string; + variable->export_info.type = Variant::PACKED_STRING_ARRAY; + + return true; } } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd new file mode 100644 index 0000000000..c787d9e50e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.gd @@ -0,0 +1,4 @@ +signal my_signal() + +func test(): + var _a := await my_signal diff --git a/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out new file mode 100644 index 0000000000..8f8744ad7e --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/await_signal_no_infer.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot infer the type of "_a" variable because the value doesn't have a set type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd new file mode 100644 index 0000000000..1639bbbd52 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.gd @@ -0,0 +1,7 @@ +extends Node + +class Inner extends RefCounted: + @onready var nope = 0 + +func test(): + print("Cannot use @onready without a Node base") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out new file mode 100644 index 0000000000..8088d28329 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/onready_within_non_node_inner_class.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +"@onready" can only be used in classes that inherit "Node". diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd new file mode 100644 index 0000000000..9d8cfc7f99 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.gd @@ -0,0 +1,15 @@ +func coroutine() -> int: + @warning_ignore("redundant_await") + await 0 + return 1 + +func not_coroutine() -> int: + return 2 + +func test(): + var a := await coroutine() + @warning_ignore("redundant_await") + var b := await not_coroutine() + @warning_ignore("redundant_await") + var c := await 3 + prints(a, b, c) diff --git a/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out new file mode 100644 index 0000000000..2920e2ce9c --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/await_type_inference.out @@ -0,0 +1,2 @@ +GDTEST_OK +1 2 3 diff --git a/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd new file mode 100644 index 0000000000..1ac03c2181 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.gd @@ -0,0 +1,7 @@ +extends RefCounted + +func test(): + print("ok") + +class Inner extends Node: + @onready var okay = 0 diff --git a/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out new file mode 100644 index 0000000000..1b47ed10dc --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/onready_on_inner_class_with_non_node_outer.out @@ -0,0 +1,2 @@ +GDTEST_OK +ok diff --git a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd index e1e6134fd4..092ae49d00 100644 --- a/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd +++ b/modules/gdscript/tests/scripts/analyzer/features/typed_array_usage.gd @@ -201,4 +201,10 @@ func test(): assert(typed_enums.get_typed_builtin() == TYPE_INT) + var a := A.new() + var typed_natives: Array[RefCounted] = [a] + var typed_scripts = Array(typed_natives, TYPE_OBJECT, "RefCounted", A) + assert(typed_scripts[0] == a) + + print('ok') diff --git a/modules/gltf/editor/editor_import_blend_runner.cpp b/modules/gltf/editor/editor_import_blend_runner.cpp index c203a91834..659a60e6a1 100644 --- a/modules/gltf/editor/editor_import_blend_runner.cpp +++ b/modules/gltf/editor/editor_import_blend_runner.cpp @@ -181,7 +181,18 @@ Error EditorImportBlendRunner::start_blender(const String &p_python_script, bool Error EditorImportBlendRunner::do_import(const Dictionary &p_options) { if (is_using_rpc()) { - return do_import_rpc(p_options); + Error err = do_import_rpc(p_options); + if (err != OK) { + // Retry without using RPC (slow, but better than the import failing completely). + if (err == ERR_CONNECTION_ERROR) { + // Disable RPC if the connection could not be established. + print_error(vformat("Failed to connect to Blender via RPC, switching to direct imports of .blend files. Check your proxy and firewall settings, then RPC can be re-enabled by changing the editor setting `filesystem/import/blender/rpc_port` to %d.", rpc_port)); + EditorSettings::get_singleton()->set_manually("filesystem/import/blender/rpc_port", 0); + rpc_port = 0; + } + err = do_import_direct(p_options); + } + return err; } else { return do_import_direct(p_options); } diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 8cc2b1eb97..0b66654617 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -800,6 +800,12 @@ bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1; } +bool EditorExportPlatformAndroid::_uses_vulkan() { + String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile"); + bool uses_vulkan = (current_renderer == "forward_plus" || current_renderer == "mobile") && GLOBAL_GET("rendering/rendering_device/driver.android") == "vulkan"; + return uses_vulkan; +} + void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, Vector<String> &r_permissions) { const char **aperms = android_perms; while (*aperms) { @@ -854,7 +860,7 @@ void EditorExportPlatformAndroid::_write_tmp_manifest(const Ref<EditorExportPres } } - manifest_text += _get_xr_features_tag(p_preset); + manifest_text += _get_xr_features_tag(p_preset, _uses_vulkan()); manifest_text += _get_application_tag(p_preset, _has_read_write_storage_permission(perms)); manifest_text += "</manifest>\n"; String manifest_path = vformat("res://android/build/src/%s/AndroidManifest.xml", (p_debug ? "debug" : "release")); @@ -1057,9 +1063,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p Vector<bool> feature_required_list; Vector<int> feature_versions; - String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile"); - bool has_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile"; - if (has_vulkan) { + if (_uses_vulkan()) { // Require vulkan hardware level 1 support feature_names.push_back("android.hardware.vulkan.level"); feature_required_list.push_back(true); @@ -2384,13 +2388,12 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit } String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile"); - bool uses_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile"; if (current_renderer == "forward_plus") { // Warning only, so don't override `valid`. err += vformat(TTR("The \"%s\" renderer is designed for Desktop devices, and is not suitable for Android devices."), current_renderer); err += "\n"; } - if (uses_vulkan && min_sdk_int < VULKAN_MIN_SDK_VERSION) { + if (_uses_vulkan() && min_sdk_int < VULKAN_MIN_SDK_VERSION) { // Warning only, so don't override `valid`. err += vformat(TTR("\"Min SDK\" should be greater or equal to %d for the \"%s\" renderer."), VULKAN_MIN_SDK_VERSION, current_renderer); err += "\n"; diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index bff769fcba..ad1f383d27 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -172,6 +172,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { static Vector<ABI> get_enabled_abis(const Ref<EditorExportPreset> &p_preset); + static bool _uses_vulkan(); + public: typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key); diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index 7eb595f48d..671df89608 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -254,7 +254,7 @@ String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset) { return manifest_screen_sizes; } -String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) { +String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan) { String manifest_xr_features; int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode")); bool uses_xr = xr_mode_index == XR_MODE_OPENXR; @@ -274,9 +274,7 @@ String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) { } } - String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile"); - bool has_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile"; - if (has_vulkan) { + if (p_uses_vulkan) { manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"android.hardware.vulkan.level\" android:required=\"true\" android:version=\"1\" />\n"; } return manifest_xr_features; diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index fe5888e11c..da6d1170bd 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -116,7 +116,7 @@ String _get_gles_tag(); String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset); -String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset); +String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan); String _get_activity_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_xr); diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 6296ee2c22..307fa7bae1 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -275,16 +275,16 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC return false; } - final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method"); - if (renderer.equals("gl_compatibility")) { - mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl); - } else { + if (usesVulkan()) { if (!meetsVulkanRequirements(activity.getPackageManager())) { Log.e(TAG, "Missing requirements for vulkan support! Aborting..."); alert(R.string.error_missing_vulkan_requirements_message, R.string.text_error_title, this::forceQuit); return false; } mRenderView = new GodotVulkanRenderView(activity, this); + } else { + // Fallback to openGl + mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl); } View view = mRenderView.getView(); @@ -323,6 +323,15 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC } /** + * Returns true if `Vulkan` is used for rendering. + */ + private boolean usesVulkan() { + final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method"); + final String renderingDevice = GodotLib.getGlobal("rendering/rendering_device/driver"); + return ("forward_plus".equals(renderer) || "mobile".equals(renderer)) && "vulkan".equals(renderingDevice); + } + + /** * Returns true if the device meets the base requirements for Vulkan support, false otherwise. */ private boolean meetsVulkanRequirements(@Nullable PackageManager packageManager) { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2e25d685d6..8087ac6250 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -857,7 +857,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double HashMap<int, TrackNodeCache::PlayingAudioStreamInfo> &map = aa->playing_streams; // Find stream. int idx = -1; - if (p_seeked) { + if (p_seeked || p_started) { idx = a->track_find_key(i, p_time); // Discard previous stream when seeking. if (map.has(idx)) { @@ -866,12 +866,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double } } else { List<int> to_play; - if (p_started) { - int first_key = a->track_find_key(i, p_prev_time, Animation::FIND_MODE_EXACT); - if (first_key >= 0) { - to_play.push_back(first_key); - } - } + a->track_get_key_indices_in_range(i, p_time, p_delta, &to_play, p_looped_flag); if (to_play.size()) { idx = to_play.back()->get(); @@ -888,6 +883,10 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double double end_ofs = a->audio_track_get_key_end_offset(i, idx); double len = stream->get_length(); + if (p_seeked || p_started) { + start_ofs += p_time - a->track_get_key_time(i, idx); + } + if (aa->object->call(SNAME("get_stream")) != aa->audio_stream) { aa->object->call(SNAME("set_stream"), aa->audio_stream); aa->audio_stream_playback.unref(); @@ -1286,6 +1285,8 @@ void AnimationPlayer::_animation_process(double p_delta) { _animation_update_transforms(); if (end_reached) { + _clear_audio_streams(); + _stop_playing_caches(false); if (queued.size()) { String old = playback.assigned; play(queued.front()->get()); diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index dd5bf31c66..8b1a5e3aac 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -1546,6 +1546,10 @@ void AnimationTree::_process_graph(double p_delta) { double end_ofs = a->audio_track_get_key_end_offset(i, idx); double len = stream->get_length(); + if (seeked) { + start_ofs += time - a->track_get_key_time(i, idx); + } + if (t->object->call(SNAME("get_stream")) != t->audio_stream) { t->object->call(SNAME("set_stream"), t->audio_stream); t->audio_stream_playback.unref(); |