Skip to content
Open
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
5 changes: 4 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
Comment thread
rsanchezsaez marked this conversation as resolved.
/drivers/unix/ @godotengine/linux-bsd
/drivers/windows/ @godotengine/windows

Expand Down Expand Up @@ -177,6 +178,8 @@
/modules/openxr/ @godotengine/xr
/modules/openxr/doc_classes/ @godotengine/xr @godotengine/documentation
/modules/openxr/editor/ @godotengine/xr @godotengine/editor
/modules/visionos_xr/ @godotengine/xr
Comment thread
rsanchezsaez marked this conversation as resolved.
/modules/visionos_xr/doc_classes/ @godotengine/xr @godotengine/documentation
/modules/webxr/ @godotengine/xr
/modules/webxr/doc_classes/ @godotengine/xr @godotengine/documentation

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>
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.
2 changes: 1 addition & 1 deletion 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
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
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
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
107 changes: 107 additions & 0 deletions drivers/apple_embedded/godot_renderer.mm
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

This is mostly code copied from godot_view_renderer.mm

Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/**************************************************************************/
/* godot_renderer.mm */
/**************************************************************************/
/* 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. */
/**************************************************************************/

#import "godot_renderer.h"

#include "core/config/project_settings.h"
#import "drivers/apple_embedded/display_server_apple_embedded.h"
#import "drivers/apple_embedded/os_apple_embedded.h"
#include "main/main.h"

@interface GDTRenderer ()

@property(assign, nonatomic) BOOL hasCalledProjectDataSetUp;
@property(assign, nonatomic) BOOL hasStartedMain;
@property(assign, nonatomic) BOOL hasFinishedSetUp;

@end

@implementation GDTRenderer

- (BOOL)setUp {
if (self.hasFinishedSetUp) {
return NO;
}

if (!OS::get_singleton()) {
exit(0);
}

if (!self.hasCalledProjectDataSetUp) {
[self setUpProjectData];
}

if (!self.hasStartedMain) {
[self startMain];
}

self.hasFinishedSetUp = YES;

return NO;
}

- (void)setUpProjectData {
self.hasCalledProjectDataSetUp = YES;
safeDispatchSyncToMain(^{
Main::setup2();

// this might be necessary before here
NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
for (NSString *key in dict) {
NSObject *value = [dict objectForKey:key];
String ukey = String::utf8([key UTF8String]);

// we need a NSObject to Variant conversor

if ([value isKindOfClass:[NSString class]]) {
NSString *str = (NSString *)value;
String uval = String::utf8([str UTF8String]);

ProjectSettings::get_singleton()->set("Info.plist/" + ukey, uval);

} else if ([value isKindOfClass:[NSNumber class]]) {
NSNumber *n = (NSNumber *)value;
double dval = [n doubleValue];

ProjectSettings::get_singleton()->set("Info.plist/" + ukey, dval);
}
// do stuff
}
});
}

- (void)startMain {
self.hasStartedMain = YES;
safeDispatchSyncToMain(^{
OS_AppleEmbedded::get_singleton()->start();
});
}

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**************************************************************************/
/* app.swift */
/* godot_swiftui_view_controller.swift */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
Expand Down Expand Up @@ -45,10 +45,7 @@ struct GodotSwiftUIViewController: UIViewControllerRepresentable {

}

@main
struct SwiftUIApp: App {
@UIApplicationDelegateAdaptor(GDTApplicationDelegate.self) var appDelegate

struct GodotWindowScene: Scene {
var body: some Scene {
WindowGroup {
GodotSwiftUIViewController()
Expand Down
6 changes: 3 additions & 3 deletions drivers/apple_embedded/godot_view_apple_embedded.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
class String;

@class GDTView;
@class GDTViewRenderer;
@protocol GDTDisplayLayer;
@protocol GDTViewRendererProtocol;

@protocol GDTViewDelegate

Expand All @@ -46,8 +46,8 @@ class String;

@interface GDTView : UIView

@property(assign, nonatomic) id<GDTViewRendererProtocol> renderer;
@property(assign, nonatomic) id<GDTViewDelegate> delegate;
@property(weak, nonatomic) GDTViewRenderer *renderer;
@property(weak, nonatomic) id<GDTViewDelegate> delegate;

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

Expand Down
6 changes: 3 additions & 3 deletions drivers/apple_embedded/godot_view_apple_embedded.mm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ - (void)stopRendering {

self.isActive = NO;

print_verbose("Stop animation!");
print_verbose("Stop rendering");

if (self.useCADisplayLink) {
[self.displayLink invalidate];
Expand All @@ -199,7 +199,7 @@ - (void)startRendering {

self.isActive = YES;

print_verbose("Start animation!");
print_verbose("Start rendering");

if (self.useCADisplayLink) {
self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView)];
Expand Down Expand Up @@ -237,7 +237,7 @@ - (void)drawView {
return;
}

if ([self.renderer setupView:self]) {
if ([self.renderer setUp]) {
return;
}

Expand Down
Loading
Loading