diff options
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/detect.py | 19 | ||||
-rw-r--r-- | platform/ios/display_server_ios.h | 4 | ||||
-rw-r--r-- | platform/ios/display_server_ios.mm | 26 | ||||
-rw-r--r-- | platform/ios/doc_classes/EditorExportPlatformIOS.xml | 6 | ||||
-rw-r--r-- | platform/ios/export/export_plugin.cpp | 10 | ||||
-rw-r--r-- | platform/ios/godot_app_delegate.h | 2 | ||||
-rw-r--r-- | platform/ios/godot_app_delegate.m | 4 | ||||
-rw-r--r-- | platform/ios/godot_view.mm | 6 | ||||
-rw-r--r-- | platform/ios/main.m | 2 | ||||
-rw-r--r-- | platform/ios/rendering_context_driver_vulkan_ios.mm | 2 |
10 files changed, 68 insertions, 13 deletions
diff --git a/platform/ios/detect.py b/platform/ios/detect.py index 53b367a0a7..989a7f21f3 100644 --- a/platform/ios/detect.py +++ b/platform/ios/detect.py @@ -51,7 +51,8 @@ def get_flags(): "arch": "arm64", "target": "template_debug", "use_volk": False, - "supported": ["mono"], + "metal": True, + "supported": ["metal", "mono"], "builtin_pcre2_with_jit": False, } @@ -154,8 +155,22 @@ def configure(env: "SConsEnvironment"): env.Prepend(CPPPATH=["#platform/ios"]) env.Append(CPPDEFINES=["IOS_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) + if env["metal"] and env["arch"] != "arm64": + # Only supported on arm64, so skip it for x86_64 builds. + env["metal"] = False + + if env["metal"]: + env.AppendUnique(CPPDEFINES=["METAL_ENABLED", "RD_ENABLED"]) + env.Prepend( + CPPPATH=[ + "$IOS_SDK_PATH/System/Library/Frameworks/Metal.framework/Headers", + "$IOS_SDK_PATH/System/Library/Frameworks/QuartzCore.framework/Headers", + ] + ) + env.Prepend(CPPPATH=["#thirdparty/spirv-cross"]) + if env["vulkan"]: - env.Append(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"]) + env.AppendUnique(CPPDEFINES=["VULKAN_ENABLED", "RD_ENABLED"]) if env["opengl3"]: env.Append(CPPDEFINES=["GLES3_ENABLED", "GLES_SILENCE_DEPRECATION"]) diff --git a/platform/ios/display_server_ios.h b/platform/ios/display_server_ios.h index 4dded5aa29..bbb758074d 100644 --- a/platform/ios/display_server_ios.h +++ b/platform/ios/display_server_ios.h @@ -47,6 +47,10 @@ #include <vulkan/vulkan.h> #endif #endif // VULKAN_ENABLED + +#if defined(METAL_ENABLED) +#include "drivers/metal/rendering_context_driver_metal.h" +#endif // METAL_ENABLED #endif // RD_ENABLED #if defined(GLES3_ENABLED) diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm index 802fbefc0d..5a027e0196 100644 --- a/platform/ios/display_server_ios.mm +++ b/platform/ios/display_server_ios.mm @@ -73,6 +73,13 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode #ifdef VULKAN_ENABLED RenderingContextDriverVulkanIOS::WindowPlatformData vulkan; #endif +#ifdef METAL_ENABLED +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" + // Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer". + RenderingContextDriverMetal::WindowPlatformData metal; +#pragma clang diagnostic pop +#endif } wpd; #if defined(VULKAN_ENABLED) @@ -85,7 +92,19 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode rendering_context = memnew(RenderingContextDriverVulkanIOS); } #endif - +#ifdef METAL_ENABLED + if (rendering_driver == "metal") { + if (@available(iOS 14.0, *)) { + layer = [AppDelegate.viewController.godotView initializeRenderingForDriver:@"metal"]; + wpd.metal.layer = (CAMetalLayer *)layer; + rendering_context = memnew(RenderingContextDriverMetal); + } else { + OS::get_singleton()->alert("Metal is only supported on iOS 14.0 and later."); + r_error = ERR_UNAVAILABLE; + return; + } + } +#endif if (rendering_context) { if (rendering_context->initialize() != OK) { ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver)); @@ -172,6 +191,11 @@ Vector<String> DisplayServerIOS::get_rendering_drivers_func() { #if defined(VULKAN_ENABLED) drivers.push_back("vulkan"); #endif +#if defined(METAL_ENABLED) + if (@available(ios 14.0, *)) { + drivers.push_back("metal"); + } +#endif #if defined(GLES3_ENABLED) drivers.push_back("opengl3"); #endif diff --git a/platform/ios/doc_classes/EditorExportPlatformIOS.xml b/platform/ios/doc_classes/EditorExportPlatformIOS.xml index 87994ef22b..1d4a944dc4 100644 --- a/platform/ios/doc_classes/EditorExportPlatformIOS.xml +++ b/platform/ios/doc_classes/EditorExportPlatformIOS.xml @@ -151,16 +151,16 @@ Indicates whether your app uses advertising data for tracking. </member> <member name="privacy/collected_data/audio_data/collected" type="bool" setter="" getter=""> - Indicates whether your app collects audio data data. + Indicates whether your app collects audio data. </member> <member name="privacy/collected_data/audio_data/collection_purposes" type="int" setter="" getter=""> The reasons your app collects audio data. See [url=https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_data_use_in_privacy_manifests]Describing data use in privacy manifests[/url]. </member> <member name="privacy/collected_data/audio_data/linked_to_user" type="bool" setter="" getter=""> - Indicates whether your app links audio data data to the user's identity. + Indicates whether your app links audio data to the user's identity. </member> <member name="privacy/collected_data/audio_data/used_for_tracking" type="bool" setter="" getter=""> - Indicates whether your app uses audio data data for tracking. + Indicates whether your app uses audio data for tracking. </member> <member name="privacy/collected_data/browsing_history/collected" type="bool" setter="" getter=""> Indicates whether your app collects browsing history. diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 5b65c8b485..e4b5392c4e 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -282,6 +282,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/short_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "Leave empty to use project version"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/version", PROPERTY_HINT_PLACEHOLDER_TEXT, "Leave empty to use project version"), "")); + // TODO(sgc): set to iOS 14.0 for Metal r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/min_ios_version"), "12.0")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/additional_plist_content", PROPERTY_HINT_MULTILINE_TEXT), "")); @@ -1628,7 +1629,7 @@ Error EditorExportPlatformIOS::_copy_asset(const Ref<EditorExportPreset> &p_pres asset_path = asset_path.path_join(framework_name); destination_dir = p_out_dir.path_join(asset_path); - destination = destination_dir.path_join(file_name); + destination = destination_dir; // Convert to framework and copy. Error err = _convert_to_framework(p_asset, destination, p_preset->get("application/bundle_identifier")); @@ -2656,6 +2657,13 @@ bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExp } } + if (GLOBAL_GET("rendering/rendering_device/driver.ios") == "metal") { + float version = p_preset->get("application/min_ios_version").operator String().to_float(); + if (version < 14.0) { + err += TTR("Metal renderer require iOS 14+.") + "\n"; + } + } + if (!err.is_empty()) { r_error = err; } diff --git a/platform/ios/godot_app_delegate.h b/platform/ios/godot_app_delegate.h index a9bfcbb0b2..85dc6bb390 100644 --- a/platform/ios/godot_app_delegate.h +++ b/platform/ios/godot_app_delegate.h @@ -32,7 +32,7 @@ typedef NSObject<UIApplicationDelegate> ApplicationDelegateService; -@interface GodotApplicalitionDelegate : NSObject <UIApplicationDelegate> +@interface GodotApplicationDelegate : NSObject <UIApplicationDelegate> @property(class, readonly, strong) NSArray<ApplicationDelegateService *> *services; diff --git a/platform/ios/godot_app_delegate.m b/platform/ios/godot_app_delegate.m index 74e8705bc3..53e53cd0c6 100644 --- a/platform/ios/godot_app_delegate.m +++ b/platform/ios/godot_app_delegate.m @@ -32,11 +32,11 @@ #import "app_delegate.h" -@interface GodotApplicalitionDelegate () +@interface GodotApplicationDelegate () @end -@implementation GodotApplicalitionDelegate +@implementation GodotApplicationDelegate static NSMutableArray<ApplicationDelegateService *> *services = nil; diff --git a/platform/ios/godot_view.mm b/platform/ios/godot_view.mm index 1dddc9306e..552c4c262c 100644 --- a/platform/ios/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -71,7 +71,7 @@ static const float earth_gravity = 9.80665; CALayer<DisplayLayer> *layer; - if ([driverName isEqualToString:@"vulkan"]) { + if ([driverName isEqualToString:@"vulkan"] || [driverName isEqualToString:@"metal"]) { #if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR if (@available(iOS 13, *)) { layer = [GodotMetalLayer layer]; @@ -441,6 +441,9 @@ static const float earth_gravity = 9.80665; UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationUnknown; +#if __IPHONE_OS_VERSION_MAX_ALLOWED < 140000 + interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; +#else if (@available(iOS 13, *)) { interfaceOrientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation; #if !defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR @@ -448,6 +451,7 @@ static const float earth_gravity = 9.80665; interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation]; #endif } +#endif switch (interfaceOrientation) { case UIInterfaceOrientationLandscapeLeft: { diff --git a/platform/ios/main.m b/platform/ios/main.m index 33b1034d98..89a00c9ae9 100644 --- a/platform/ios/main.m +++ b/platform/ios/main.m @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) { gargv = argv; @autoreleasepool { - NSString *className = NSStringFromClass([GodotApplicalitionDelegate class]); + NSString *className = NSStringFromClass([GodotApplicationDelegate class]); UIApplicationMain(argc, argv, nil, className); } return 0; diff --git a/platform/ios/rendering_context_driver_vulkan_ios.mm b/platform/ios/rendering_context_driver_vulkan_ios.mm index 6a6af1bc41..8747bfd76a 100644 --- a/platform/ios/rendering_context_driver_vulkan_ios.mm +++ b/platform/ios/rendering_context_driver_vulkan_ios.mm @@ -50,7 +50,7 @@ RenderingContextDriver::SurfaceID RenderingContextDriverVulkanIOS::surface_creat create_info.pLayer = *wpd->layer_ptr; VkSurfaceKHR vk_surface = VK_NULL_HANDLE; - VkResult err = vkCreateMetalSurfaceEXT(instance_get(), &create_info, nullptr, &vk_surface); + VkResult err = vkCreateMetalSurfaceEXT(instance_get(), &create_info, get_allocation_callbacks(VK_OBJECT_TYPE_SURFACE_KHR), &vk_surface); ERR_FAIL_COND_V(err != VK_SUCCESS, SurfaceID()); Surface *surface = memnew(Surface); |