summaryrefslogtreecommitdiff
path: root/platform/android/java/lib/src
diff options
context:
space:
mode:
authorFredia Huya-Kouadio <fhuya@meta.com>2023-02-06 10:09:25 -0800
committerFredia Huya-Kouadio <fhuya@meta.com>2023-02-06 10:13:02 -0800
commit21e18c1c418d614b44d015cca429b9509c00a376 (patch)
treee0e26e45bf6e7f623eb368fbe7be000dd4cd5be6 /platform/android/java/lib/src
parent034fd15b8a0970eac3eb656a8c4e0e1f4877d571 (diff)
Improve logic to detect whether vulkan is used for rendering
Diffstat (limited to 'platform/android/java/lib/src')
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.java17
1 files changed, 13 insertions, 4 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 6296ee2c22..307fa7bae1 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
@@ -275,16 +275,16 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
return false;
}
- final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method");
- if (renderer.equals("gl_compatibility")) {
- mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
- } else {
+ if (usesVulkan()) {
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);
+ } else {
+ // Fallback to openGl
+ mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
}
View view = mRenderView.getView();
@@ -323,6 +323,15 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
}
/**
+ * Returns true if `Vulkan` is used for rendering.
+ */
+ private boolean usesVulkan() {
+ final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method");
+ final String renderingDevice = GodotLib.getGlobal("rendering/rendering_device/driver");
+ return ("forward_plus".equals(renderer) || "mobile".equals(renderer)) && "vulkan".equals(renderingDevice);
+ }
+
+ /**
* Returns true if the device meets the base requirements for Vulkan support, false otherwise.
*/
private boolean meetsVulkanRequirements(@Nullable PackageManager packageManager) {