diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-06 15:40:15 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-06 15:40:15 +0100 |
commit | 491c8ff4ee1cb20f09fe3d5a551e4889ae5390fa (patch) | |
tree | dfe99d320b4df0d1c5e66f7a4104f52cedc836d5 /platform/android/java/lib/src | |
parent | 074113b97d420d593a3ce29572cb667c2dadfaa2 (diff) | |
parent | 034fd15b8a0970eac3eb656a8c4e0e1f4877d571 (diff) |
Merge pull request #72780 from m4gr3d/add_vulkan_filter_when_necessary
Improve vulkan capability detection on Android
Diffstat (limited to 'platform/android/java/lib/src')
-rw-r--r-- | platform/android/java/lib/src/org/godotengine/godot/Godot.java | 20 |
1 files changed, 18 insertions, 2 deletions
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 50263bc392..6296ee2c22 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) { |