Improve logic to detect whether vulkan is used for rendering
This commit is contained in:
parent
034fd15b8a
commit
21e18c1c41
@ -800,6 +800,12 @@ bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const
|
|||||||
return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1;
|
return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditorExportPlatformAndroid::_uses_vulkan() {
|
||||||
|
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
|
||||||
|
bool uses_vulkan = (current_renderer == "forward_plus" || current_renderer == "mobile") && GLOBAL_GET("rendering/rendering_device/driver.android") == "vulkan";
|
||||||
|
return uses_vulkan;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, Vector<String> &r_permissions) {
|
void EditorExportPlatformAndroid::_get_permissions(const Ref<EditorExportPreset> &p_preset, bool p_give_internet, Vector<String> &r_permissions) {
|
||||||
const char **aperms = android_perms;
|
const char **aperms = android_perms;
|
||||||
while (*aperms) {
|
while (*aperms) {
|
||||||
@ -854,7 +860,7 @@ void EditorExportPlatformAndroid::_write_tmp_manifest(const Ref<EditorExportPres
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest_text += _get_xr_features_tag(p_preset);
|
manifest_text += _get_xr_features_tag(p_preset, _uses_vulkan());
|
||||||
manifest_text += _get_application_tag(p_preset, _has_read_write_storage_permission(perms));
|
manifest_text += _get_application_tag(p_preset, _has_read_write_storage_permission(perms));
|
||||||
manifest_text += "</manifest>\n";
|
manifest_text += "</manifest>\n";
|
||||||
String manifest_path = vformat("res://android/build/src/%s/AndroidManifest.xml", (p_debug ? "debug" : "release"));
|
String manifest_path = vformat("res://android/build/src/%s/AndroidManifest.xml", (p_debug ? "debug" : "release"));
|
||||||
@ -1057,9 +1063,7 @@ void EditorExportPlatformAndroid::_fix_manifest(const Ref<EditorExportPreset> &p
|
|||||||
Vector<bool> feature_required_list;
|
Vector<bool> feature_required_list;
|
||||||
Vector<int> feature_versions;
|
Vector<int> feature_versions;
|
||||||
|
|
||||||
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
|
if (_uses_vulkan()) {
|
||||||
bool has_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile";
|
|
||||||
if (has_vulkan) {
|
|
||||||
// Require vulkan hardware level 1 support
|
// Require vulkan hardware level 1 support
|
||||||
feature_names.push_back("android.hardware.vulkan.level");
|
feature_names.push_back("android.hardware.vulkan.level");
|
||||||
feature_required_list.push_back(true);
|
feature_required_list.push_back(true);
|
||||||
@ -2384,13 +2388,12 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
|
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
|
||||||
bool uses_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile";
|
|
||||||
if (current_renderer == "forward_plus") {
|
if (current_renderer == "forward_plus") {
|
||||||
// Warning only, so don't override `valid`.
|
// Warning only, so don't override `valid`.
|
||||||
err += vformat(TTR("The \"%s\" renderer is designed for Desktop devices, and is not suitable for Android devices."), current_renderer);
|
err += vformat(TTR("The \"%s\" renderer is designed for Desktop devices, and is not suitable for Android devices."), current_renderer);
|
||||||
err += "\n";
|
err += "\n";
|
||||||
}
|
}
|
||||||
if (uses_vulkan && min_sdk_int < VULKAN_MIN_SDK_VERSION) {
|
if (_uses_vulkan() && min_sdk_int < VULKAN_MIN_SDK_VERSION) {
|
||||||
// Warning only, so don't override `valid`.
|
// Warning only, so don't override `valid`.
|
||||||
err += vformat(TTR("\"Min SDK\" should be greater or equal to %d for the \"%s\" renderer."), VULKAN_MIN_SDK_VERSION, current_renderer);
|
err += vformat(TTR("\"Min SDK\" should be greater or equal to %d for the \"%s\" renderer."), VULKAN_MIN_SDK_VERSION, current_renderer);
|
||||||
err += "\n";
|
err += "\n";
|
||||||
|
@ -172,6 +172,8 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
|
|||||||
|
|
||||||
static Vector<ABI> get_enabled_abis(const Ref<EditorExportPreset> &p_preset);
|
static Vector<ABI> get_enabled_abis(const Ref<EditorExportPreset> &p_preset);
|
||||||
|
|
||||||
|
static bool _uses_vulkan();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
|
typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key);
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset) {
|
|||||||
return manifest_screen_sizes;
|
return manifest_screen_sizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) {
|
String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan) {
|
||||||
String manifest_xr_features;
|
String manifest_xr_features;
|
||||||
int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode"));
|
int xr_mode_index = (int)(p_preset->get("xr_features/xr_mode"));
|
||||||
bool uses_xr = xr_mode_index == XR_MODE_OPENXR;
|
bool uses_xr = xr_mode_index == XR_MODE_OPENXR;
|
||||||
@ -274,9 +274,7 @@ String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String current_renderer = GLOBAL_GET("rendering/renderer/rendering_method.mobile");
|
if (p_uses_vulkan) {
|
||||||
bool has_vulkan = current_renderer == "forward_plus" || current_renderer == "mobile";
|
|
||||||
if (has_vulkan) {
|
|
||||||
manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"android.hardware.vulkan.level\" android:required=\"true\" android:version=\"1\" />\n";
|
manifest_xr_features += " <uses-feature tools:node=\"replace\" android:name=\"android.hardware.vulkan.level\" android:required=\"true\" android:version=\"1\" />\n";
|
||||||
}
|
}
|
||||||
return manifest_xr_features;
|
return manifest_xr_features;
|
||||||
|
@ -116,7 +116,7 @@ String _get_gles_tag();
|
|||||||
|
|
||||||
String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset);
|
String _get_screen_sizes_tag(const Ref<EditorExportPreset> &p_preset);
|
||||||
|
|
||||||
String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset);
|
String _get_xr_features_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_vulkan);
|
||||||
|
|
||||||
String _get_activity_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_xr);
|
String _get_activity_tag(const Ref<EditorExportPreset> &p_preset, bool p_uses_xr);
|
||||||
|
|
||||||
|
@ -275,16 +275,16 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String renderer = GodotLib.getGlobal("rendering/renderer/rendering_method");
|
if (usesVulkan()) {
|
||||||
if (renderer.equals("gl_compatibility")) {
|
|
||||||
mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
|
|
||||||
} else {
|
|
||||||
if (!meetsVulkanRequirements(activity.getPackageManager())) {
|
if (!meetsVulkanRequirements(activity.getPackageManager())) {
|
||||||
Log.e(TAG, "Missing requirements for vulkan support! Aborting...");
|
Log.e(TAG, "Missing requirements for vulkan support! Aborting...");
|
||||||
alert(R.string.error_missing_vulkan_requirements_message, R.string.text_error_title, this::forceQuit);
|
alert(R.string.error_missing_vulkan_requirements_message, R.string.text_error_title, this::forceQuit);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mRenderView = new GodotVulkanRenderView(activity, this);
|
mRenderView = new GodotVulkanRenderView(activity, this);
|
||||||
|
} else {
|
||||||
|
// Fallback to openGl
|
||||||
|
mRenderView = new GodotGLRenderView(activity, this, xrMode, use_debug_opengl);
|
||||||
}
|
}
|
||||||
|
|
||||||
View view = mRenderView.getView();
|
View view = mRenderView.getView();
|
||||||
@ -322,6 +322,15 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
|||||||
return true;
|
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.
|
* Returns true if the device meets the base requirements for Vulkan support, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user