diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index c02acbee839..8cc2b1eb976 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 &p_preset) { manifest_xr_features += " \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 += " \n"; + } return manifest_xr_features; } diff --git a/platform/android/java/lib/res/values/strings.xml b/platform/android/java/lib/res/values/strings.xml index 7efac4ce716..f76f597140e 100644 --- a/platform/android/java/lib/res/values/strings.xml +++ b/platform/android/java/lib/res/values/strings.xml @@ -14,6 +14,7 @@ Cancel Verification Error! Unable to setup the Godot Engine! Aborting… + This device does not meet the requirements for Vulkan support! Aborting… 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 50263bc3929..6296ee2c22d 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -258,13 +258,13 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC */ @Keep private boolean onVideoInit() { - final Activity activity = getActivity(); + final Activity activity = requireActivity(); containerLayout = new FrameLayout(activity); containerLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // GodotEditText layout GodotEditText editText = new GodotEditText(activity); - editText.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, + editText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int)getResources().getDimension(R.dimen.text_edit_height))); // ...add to FrameLayout containerLayout.addView(editText); @@ -279,6 +279,11 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC if (renderer.equals("gl_compatibility")) { mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl); } else { + 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); } @@ -317,6 +322,17 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC return true; } + /** + * Returns true if the device meets the base requirements for Vulkan support, false otherwise. + */ + private boolean meetsVulkanRequirements(@Nullable PackageManager packageManager) { + if (packageManager == null) { + return false; + } + + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && packageManager.hasSystemFeature(PackageManager.FEATURE_VULKAN_HARDWARE_LEVEL, 1); + } + public void setKeepScreenOn(final boolean p_enabled) { runOnUiThread(() -> { if (p_enabled) {