From 306a2ad3865198335974c319f27baa5c4f443186 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Mon, 27 Feb 2023 07:02:37 -0800 Subject: [PATCH] Add feature check to require min Vulkan api version 1.0 on Android --- platform/android/export/export_plugin.cpp | 5 +++++ platform/android/export/gradle_export_util.cpp | 1 + .../java/lib/src/org/godotengine/godot/Godot.java | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 641258a26ce..3153b9ee24a 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1068,6 +1068,11 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref &p feature_names.push_back("android.hardware.vulkan.level"); feature_required_list.push_back(true); feature_versions.push_back(1); + + // Require vulkan version 1.0 + feature_names.push_back("android.hardware.vulkan.version"); + feature_required_list.push_back(true); + feature_versions.push_back(0x400003); // Encoded value for api version 1.0 } if (feature_names.size() > 0) { diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index 61f8c5574b1..23ace18f4fb 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -276,6 +276,7 @@ String _get_xr_features_tag(const Ref &p_preset, bool p_uses if (p_uses_vulkan) { manifest_xr_features += " \n"; + manifest_xr_features += " \n"; } return manifest_xr_features; } 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 a03da7292bf..2b48c33f1ba 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -278,7 +278,8 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC if (usesVulkan()) { if (!meetsVulkanRequirements(activity.getPackageManager())) { - Log.w(TAG, "Missing requirements for vulkan support!"); + alert(R.string.error_missing_vulkan_requirements_message, R.string.text_error_title, this::forceQuit); + return false; } mRenderView = new GodotVulkanRenderView(activity, this); } else { @@ -338,7 +339,17 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC return false; } - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && packageManager.hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_LEVEL, 1); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + if (!packageManager.hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_LEVEL, 1)) { + // Optional requirements.. log as warning if missing + Log.w(TAG, "The vulkan hardware level does not meet the minimum requirement: 1"); + } + + // Check for api version 1.0 + return packageManager.hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_VERSION, 0x400003); + } + + return false; } public void setKeepScreenOn(final boolean p_enabled) {