You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Improve vulkan capability detection on Android
- Add runtime check and abort when the device doesn't meet the requirements for vulkan support - Add filters to the AndroidManifest when exporting with a vulkan renderer
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user