From 21e18c1c418d614b44d015cca429b9509c00a376 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Mon, 6 Feb 2023 10:09:25 -0800 Subject: Improve logic to detect whether vulkan is used for rendering --- .../java/lib/src/org/godotengine/godot/Godot.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'platform/android/java/lib/src') 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(); @@ -322,6 +322,15 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC return true; } + /** + * 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. */ -- cgit v1.2.3