diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-02-05 17:16:13 -0800 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-02-05 18:47:38 -0800 |
commit | 034fd15b8a0970eac3eb656a8c4e0e1f4877d571 (patch) | |
tree | dd9cb60c18a86d74d4dc4b40fcb8846c38d0a69f /platform/android/export | |
parent | b0598dcdb7cd96e2614b687a57a64ce12245e19e (diff) |
Improve vulkan capability detection on Android
- Add runtime check and abort when the device doesn't meet the requirements for vulkan support
- Add filters to the AndroidManifest when exporting with a vulkan renderer
Diffstat (limited to 'platform/android/export')
-rw-r--r-- | platform/android/export/export_plugin.cpp | 23 | ||||
-rw-r--r-- | platform/android/export/gradle_export_util.cpp | 6 |
2 files changed, 29 insertions, 0 deletions
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index c02acbee83..8cc2b1eb97 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -252,6 +252,7 @@ static const char *APK_ASSETS_DIRECTORY = "res://android/build/assets"; static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/installTime/src/main/assets"; static const int DEFAULT_MIN_SDK_VERSION = 21; // Should match the value in 'platform/android/java/app/config.gradle#minSdk' +static const int VULKAN_MIN_SDK_VERSION = 24; static const int DEFAULT_TARGET_SDK_VERSION = 32; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk' #ifndef ANDROID_ENABLED @@ -1056,6 +1057,15 @@ 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) { + // Require vulkan hardware level 1 support + feature_names.push_back("android.hardware.vulkan.level"); + feature_required_list.push_back(true); + feature_versions.push_back(1); + } + if (feature_names.size() > 0) { ofs += 24; // skip over end tag @@ -2373,6 +2383,19 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit err += "\n"; } + 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) { + // 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"; + } + r_error = err; return valid; } diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index 5e71116c10..7eb595f48d 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -273,6 +273,12 @@ String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) { manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"true\" />\n"; } } + + String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile"); + bool has_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile"; + if (has_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; } |