From 034fd15b8a0970eac3eb656a8c4e0e1f4877d571 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Sun, 5 Feb 2023 17:16:13 -0800 Subject: 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 --- platform/android/export/export_plugin.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'platform/android/export/export_plugin.cpp') 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 &p Vector feature_required_list; Vector 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