Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
/drivers/vulkan/ @godotengine/rendering

## OS
/drivers/apple*/ @godotengine/macos
/drivers/apple/ @godotengine/macos
/drivers/apple_embedded/ @godotengine/ios
/drivers/unix/ @godotengine/linux-bsd
/drivers/windows/ @godotengine/windows

Expand Down Expand Up @@ -177,6 +178,7 @@
/modules/openxr/ @godotengine/xr
/modules/openxr/doc_classes/ @godotengine/xr @godotengine/documentation
/modules/openxr/editor/ @godotengine/xr @godotengine/editor
/modules/visionos_xr/ @godotengine/xr
/modules/webxr/ @godotengine/xr
/modules/webxr/doc_classes/ @godotengine/xr @godotengine/documentation

Expand Down Expand Up @@ -217,6 +219,8 @@
/platform/linuxbsd/doc_classes/ @godotengine/linux-bsd @godotengine/documentation
/platform/macos/ @godotengine/macos
/platform/macos/doc_classes/ @godotengine/macos @godotengine/documentation
/platform/tvos/ @godotengine/ios
/platform/tvos/doc_classes/ @godotengine/ios @godotengine/documentation
/platform/visionos/ @godotengine/xr
/platform/visionos/doc_classes/ @godotengine/xr @godotengine/documentation
/platform/web/ @godotengine/web
Expand Down
4 changes: 2 additions & 2 deletions .github/changed_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ clangd:
- "!editor/shader/shader_baker/shader_baker_export_plugin_platform_{d3d12,metal}.{h,cpp}"
- "!modules/camera/camera_{android,macos,win}.{h,cpp}"
- "!modules/openxr/extensions/platform/openxr_{android,metal}_extension.{h,cpp}"
- "!platform/{android,ios,macos,visionos,web,windows}/**"
- "platform/{android,ios,macos,visionos,web,windows}/{api,export}/*.{h,hpp,hxx,hh,c,cpp,cxx,cc}"
- "!platform/{android,ios,macos,tvos,visionos,web,windows}/**"
- "platform/{android,ios,macos,tvos,visionos,web,windows}/{api,export}/*.{h,hpp,hxx,hh,c,cpp,cxx,cc}"
2 changes: 1 addition & 1 deletion core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ bool OS::has_feature(const String &p_feature) {
}
#endif

#if defined(IOS_SIMULATOR) || defined(VISIONOS_SIMULATOR)
#if defined(IOS_SIMULATOR) || defined(TVOS_SIMULATOR) || defined(VISIONOS_SIMULATOR)
if (p_feature == "simulator") {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/EditorExportPlatformAppleEmbedded.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorExportPlatformAppleEmbedded" inherits="EditorExportPlatform" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Base class for the Apple embedded platform exporters (iOS and visionOS).
Base class for the Apple embedded platform exporters (iOS, tvOS, and visionOS).
</brief_description>
<description>
The base class for Apple embedded platform exporters. These include iOS and visionOS, but not macOS. See the classes inheriting from this one for more details.
The base class for Apple embedded platform exporters. These include iOS, tvOS, and visionOS, but not macOS. See the classes inheriting from this one for more details.
</description>
<tutorials>
<link title="Exporting for iOS">$DOCS_URL/tutorials/export/exporting_for_ios.html</link>
Expand Down
3 changes: 3 additions & 0 deletions doc/classes/RenderingDevice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,9 @@
<constant name="SUPPORTS_HDR_OUTPUT" value="13" enum="Features">
Support for high dynamic range (HDR) output.
</constant>
<constant name="SUPPORTS_RASTERIZATION_RATE_MAP" value="14" enum="Features">
Support for rasterization rate maps. The current implementation targets Metal on Apple platforms. This allows for foveated rendering, which is used by the visionOS XR module.
</constant>
<constant name="LIMIT_MAX_BOUND_UNIFORM_SETS" value="0" enum="Limit">
Maximum number of uniform sets that can be bound at a given time.
</constant>
Expand Down
3 changes: 3 additions & 0 deletions doc/classes/XRInterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,8 @@
<constant name="XR_VRS_TEXTURE_FORMAT_FRAGMENT_DENSITY_MAP" value="2" enum="VRSTextureFormat">
The texture format is the same as expected by the Vulkan [code]VK_EXT_fragment_density_map[/code] extension.
</constant>
<constant name="XR_VRS_TEXTURE_FORMAT_RASTERIZATION_RATE_MAP" value="3" enum="VRSTextureFormat">
The texture contains a Metal [code]rasterizationRateMap[/code], used for foveated rendering on Apple platforms. It's not a real texture, but instead an opaque wrapper for an [code]MTLRasterizationRateMap[/code] object.
</constant>
</constants>
</class>
6 changes: 3 additions & 3 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ if env["xaudio2"]:
SConscript("xaudio2/SCsub")

# Shared Apple platform drivers
if env["platform"] in ["macos", "ios", "visionos"]:
if env["platform"] in ["macos", "ios", "tvos", "visionos"]:
SConscript("apple/SCsub")
SConscript("coreaudio/SCsub")
if env["platform"] in ["ios", "visionos"]:
if env["platform"] in ["ios", "tvos", "visionos"]:
SConscript("apple_embedded/SCsub")

# Accessibility
Expand Down Expand Up @@ -61,7 +61,7 @@ if env["metal"]:
SConscript("metal/SCsub")

# Input drivers
if env["sdl"] and env["platform"] in ["linuxbsd", "macos", "windows", "ios", "visionos"]:
if env["sdl"] and env["platform"] in ["linuxbsd", "macos", "windows", "ios", "tvos", "visionos"]:
# TODO: Evaluate support for Android and Web.
SConscript("sdl/SCsub")

Expand Down
2 changes: 1 addition & 1 deletion drivers/apple_embedded/apple_embedded.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#import "apple_embedded.h"

#include "core/object/class_db.h"
#import "drivers/apple_embedded/app_delegate_service.h"
#import "drivers/apple_embedded/godot_app_delegate_service_apple_embedded.h"
#import "drivers/apple_embedded/godot_view_controller.h"

#import <CoreHaptics/CoreHaptics.h>
Expand Down
3 changes: 1 addition & 2 deletions drivers/apple_embedded/bridging_header_apple_embedded.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#pragma once

// IWYU pragma: begin_exports.
#import "drivers/apple_embedded/app_delegate_service.h"
#import "drivers/apple_embedded/godot_app_delegate.h"
#import "drivers/apple_embedded/godot_app_delegate_service_apple_embedded.h"
#import "drivers/apple_embedded/godot_view_apple_embedded.h"
#import "drivers/apple_embedded/godot_view_controller.h"
// IWYU pragma: end_exports.
19 changes: 17 additions & 2 deletions drivers/apple_embedded/display_server_apple_embedded.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "core/input/input.h"
#include "core/io/file_access_pack.h"
#include "core/os/os.h"
#import "drivers/apple_embedded/app_delegate_service.h"
#import "drivers/apple_embedded/apple_embedded.h"
#import "drivers/apple_embedded/godot_app_delegate_service_apple_embedded.h"
#import "drivers/apple_embedded/godot_keyboard_input_view.h"
#import "drivers/apple_embedded/godot_view_apple_embedded.h"
#import "drivers/apple_embedded/godot_view_controller.h"
Expand Down Expand Up @@ -66,6 +66,15 @@

bool has_made_render_compositor_current = false;

#if !defined(GLES3_ENABLED) && defined(METAL_ENABLED)
if (rendering_driver == "opengl3") {
WARN_PRINT("OpenGL 3 is not supported on this platform, switching to Metal.");
rendering_driver = "metal";
OS::get_singleton()->set_current_rendering_method("mobile", OS::RENDERING_SOURCE_FALLBACK);
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver, OS::RENDERING_SOURCE_FALLBACK);
}
#endif

#if defined(RD_ENABLED)
rendering_context = nullptr;
rendering_device = nullptr;
Expand Down Expand Up @@ -668,7 +677,7 @@
if (@available(iOS 16.0, *)) {
[GDTAppDelegateService.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
}
#if !defined(VISIONOS_ENABLED)
#if !defined(VISIONOS_ENABLED) && !defined(TVOS_ENABLED)
else {
[UIViewController attemptRotationToDeviceOrientation];
}
Expand Down Expand Up @@ -772,13 +781,19 @@ _FORCE_INLINE_ int _convert_utf32_offset_to_utf16(const String &p_existing_text,
}

void DisplayServerAppleEmbedded::clipboard_set(const String &p_text) {
#ifndef TVOS_ENABLED
[UIPasteboard generalPasteboard].string = [NSString stringWithUTF8String:p_text.utf8().get_data()];
#endif
}

String DisplayServerAppleEmbedded::clipboard_get() const {
#ifndef TVOS_ENABLED
NSString *text = [UIPasteboard generalPasteboard].string;

return String::utf8([text UTF8String]);
#else
return String();
#endif
}

void DisplayServerAppleEmbedded::screen_set_keep_on(bool p_enable) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* godot_app_delegate.h */
/* godot_app_delegate_apple_embedded.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -34,7 +34,7 @@

typedef NSObject<UIApplicationDelegate, UIWindowSceneDelegate> GDTAppDelegateServiceProtocol;

@interface GDTApplicationDelegate : NSObject <UIApplicationDelegate, UIWindowSceneDelegate>
@interface GDTAppDelegate : NSObject <UIApplicationDelegate, UIWindowSceneDelegate>

@property(class, readonly, strong) NSArray<GDTAppDelegateServiceProtocol *> *services;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* godot_app_delegate.mm */
/* godot_app_delegate_apple_embedded.mm */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#import "godot_app_delegate.h"
#import "godot_app_delegate_apple_embedded.h"

#include "core/typedefs.h"
#import "drivers/apple_embedded/app_delegate_service.h"
#import "drivers/apple_embedded/godot_app_delegate_service_apple_embedded.h"

@implementation GDTApplicationDelegate
@implementation GDTAppDelegate

static NSMutableArray<GDTAppDelegateServiceProtocol *> *services = nil;

Expand All @@ -43,7 +43,7 @@ @implementation GDTApplicationDelegate

+ (void)load {
services = [NSMutableArray new];
[services addObject:[GDTAppDelegateService new]];
// Add the specific GDTAppDelegateService subclass in each inheriting platform
}

+ (void)addService:(GDTAppDelegateServiceProtocol *)service {
Expand Down Expand Up @@ -113,7 +113,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options API_AVAILABLE(ios(13.0), tvos(13.0), visionos(1.0)) {
UISceneConfiguration *config = [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
config.delegateClass = [GDTApplicationDelegate class];
config.delegateClass = [GDTAppDelegate class];
return config;
}

Expand Down Expand Up @@ -409,6 +409,8 @@ - (void)application:(UIApplication *)application didFailToContinueUserActivityWi
}
}

#ifndef TVOS_ENABLED

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler {
for (GDTAppDelegateServiceProtocol *service in services) {
if (![service respondsToSelector:_cmd]) {
Expand All @@ -419,6 +421,8 @@ - (void)application:(UIApplication *)application performActionForShortcutItem:(U
}
}

#endif

// MARK: WatchKit

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *replyInfo))reply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* app_delegate_service.h */
/* godot_app_delegate_service_apple_embedded.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -36,6 +36,6 @@

@interface GDTAppDelegateService : NSObject <UIApplicationDelegate, UIWindowSceneDelegate>

@property(strong, class, nonatomic) GDTViewController *viewController;
@property(weak, class, nonatomic, nullable) GDTViewController *viewController;

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* app_delegate_service.mm */
/* godot_app_delegate_service_apple_embedded.mm */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#import "app_delegate_service.h"
#import "godot_app_delegate_service_apple_embedded.h"

#include "core/config/project_settings.h"
#include "core/os/main_loop.h"
Expand Down Expand Up @@ -59,14 +59,14 @@ @implementation GDTAppDelegateService
SESSION_CATEGORY_SOLO_AMBIENT
};

static GDTViewController *mainViewController = nil;
static __weak GDTViewController *_viewController = nil;

+ (GDTViewController *)viewController {
return mainViewController;
return _viewController;
}

+ (void)setViewController:(GDTViewController *)viewController {
mainViewController = viewController;
_viewController = viewController;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
Expand Down Expand Up @@ -111,7 +111,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
category = AVAudioSessionCategoryMultiRoute;
} else if (sessionCategorySetting == SESSION_CATEGORY_PLAY_AND_RECORD) {
category = AVAudioSessionCategoryPlayAndRecord;
#ifndef TVOS_ENABLED
options |= AVAudioSessionCategoryOptionDefaultToSpeaker;
#endif
options |= AVAudioSessionCategoryOptionAllowBluetoothA2DP;
options |= AVAudioSessionCategoryOptionAllowAirPlay;
} else if (sessionCategorySetting == SESSION_CATEGORY_PLAYBACK) {
Expand Down
49 changes: 49 additions & 0 deletions drivers/apple_embedded/godot_renderer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**************************************************************************/
/* godot_renderer.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#pragma once

#import <Foundation/Foundation.h>

inline void safeDispatchSyncToMain(void (^block)(void)) {
if ([NSThread isMainThread]) {
block();
} else {
dispatch_sync(dispatch_get_main_queue(), block);
}
}

@interface GDTRenderer : NSObject

@property(assign, readonly, nonatomic) BOOL hasFinishedSetup;

- (BOOL)setUp;

@end
Loading
Loading