Skip to content

Commit fa54b32

Browse files
committed
Introduce 'visionos' platform derived from 'apple_embedded'
1 parent 9408956 commit fa54b32

File tree

66 files changed

+2589
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2589
-21
lines changed

core/os/os.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ bool OS::has_feature(const String &p_feature) {
585585
}
586586
#endif
587587

588-
#if defined(IOS_SIMULATOR)
588+
#if defined(IOS_SIMULATOR) || defined(VISIONOS_SIMULATOR)
589589
if (p_feature == "simulator") {
590590
return true;
591591
}

doc/classes/EditorExportPlatformAppleEmbedded.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<class name="EditorExportPlatformAppleEmbedded" inherits="EditorExportPlatform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
4-
Base class for the Apple embedded platform exporters (iOS).
4+
Base class for the Apple embedded platform exporters (iOS and visionOS).
55
</brief_description>
66
<description>
7-
The base class for Apple embedded platform exporters. These include iOS, but not macOS. See the classes inheriting from this one for more details.
7+
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.
88
</description>
99
<tutorials>
1010
<link title="Exporting for iOS">$DOCS_URL/tutorials/export/exporting_for_ios.html</link>

doc/classes/ProjectSettings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,9 @@
900900
<member name="display/display_server/driver.macos" type="String" setter="" getter="">
901901
MacOS override for [member display/display_server/driver].
902902
</member>
903+
<member name="display/display_server/driver.visionos" type="String" setter="" getter="">
904+
visionOS override for [member display/display_server/driver].
905+
</member>
903906
<member name="display/display_server/driver.windows" type="String" setter="" getter="">
904907
Windows override for [member display/display_server/driver].
905908
</member>
@@ -3163,6 +3166,11 @@
31633166
- [code]metal[/code] (default), Metal from native drivers, only supported on Apple Silicon Macs. On Intel Macs, it will automatically fall back to [code]vulkan[/code] as Metal support is not implemented.
31643167
- [code]vulkan[/code], Vulkan over Metal via MoltenVK, supported on both Apple Silicon and Intel Macs.
31653168
</member>
3169+
<member name="rendering/rendering_device/driver.visionos" type="String" setter="" getter="" default="&quot;metal&quot;">
3170+
visionOS override for [member rendering/rendering_device/driver].
3171+
Only one option is supported:
3172+
- [code]metal[/code] (default), Metal from native drivers.
3173+
</member>
31663174
<member name="rendering/rendering_device/driver.windows" type="String" setter="" getter="" default="&quot;vulkan&quot;">
31673175
Windows override for [member rendering/rendering_device/driver].
31683176
Two options are supported:

drivers/SCsub

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ if env["xaudio2"]:
2626
SConscript("xaudio2/SCsub")
2727

2828
# Shared Apple platform drivers
29-
if env["platform"] in ["macos", "ios"]:
29+
if env["platform"] in ["macos", "ios", "visionos"]:
3030
SConscript("apple/SCsub")
3131
SConscript("coreaudio/SCsub")
32-
if env["platform"] in ["ios"]:
32+
if env["platform"] in ["ios", "visionos"]:
3333
SConscript("apple_embedded/SCsub")
3434

3535
# Accessibility
@@ -38,7 +38,7 @@ if env["accesskit"] and env["platform"] in ["macos", "windows", "linuxbsd"]:
3838

3939
# Midi drivers
4040
SConscript("alsamidi/SCsub")
41-
if env["platform"] in ["macos", "ios"]:
41+
if env["platform"] in ["macos"]:
4242
SConscript("coremidi/SCsub")
4343
SConscript("winmidi/SCsub")
4444

drivers/apple_embedded/app_delegate_service.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
7171
// TODO: logo screen is not displayed while shaders are compiling
7272
// DummyViewController(Splash/LoadingViewController) -> setup -> GodotViewController
7373

74+
#if !defined(VISIONOS_ENABLED)
7475
// Create a full-screen window
7576
CGRect windowBounds = [[UIScreen mainScreen] bounds];
7677
self.window = [[UIWindow alloc] initWithFrame:windowBounds];
78+
#else
79+
self.window = [[UIWindow alloc] init];
80+
#endif
7781

7882
int err = apple_embedded_main(gargc, gargv);
7983

drivers/apple_embedded/display_server_apple_embedded.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,12 @@
643643
screen_orientation = p_orientation;
644644
if (@available(iOS 16.0, *)) {
645645
[GDTAppDelegateService.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
646-
} else {
646+
}
647+
#if !defined(VISIONOS_ENABLED)
648+
else {
647649
[UIViewController attemptRotationToDeviceOrientation];
648650
}
651+
#endif
649652
}
650653

651654
DisplayServer::ScreenOrientation DisplayServerAppleEmbedded::screen_get_orientation(int p_screen) const {

drivers/apple_embedded/godot_view_apple_embedded.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ - (void)dealloc {
117117
}
118118

119119
- (void)godot_commonInit {
120+
#if !defined(VISIONOS_ENABLED)
120121
self.contentScaleFactor = [UIScreen mainScreen].scale;
122+
#endif
121123

122124
if (@available(iOS 17.0, *)) {
123125
[self registerForTraitChanges:@[ [UITraitUserInterfaceStyle class] ] withTarget:self action:@selector(traitCollectionDidChangeWithView:previousTraitCollection:)];
@@ -148,7 +150,9 @@ - (void)system_theme_changed {
148150

149151
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
150152
if (@available(iOS 13.0, *)) {
153+
#if !defined(VISIONOS_ENABLED)
151154
[super traitCollectionDidChange:previousTraitCollection];
155+
#endif
152156
[self traitCollectionDidChangeWithView:self
153157
previousTraitCollection:previousTraitCollection];
154158
}
@@ -419,6 +423,7 @@ - (void)handleMotion {
419423

420424
UIInterfaceOrientation interfaceOrientation = UIInterfaceOrientationUnknown;
421425

426+
#if !defined(VISIONOS_ENABLED)
422427
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 140000
423428
interfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
424429
#else
@@ -430,6 +435,9 @@ - (void)handleMotion {
430435
#endif
431436
}
432437
#endif
438+
#else
439+
interfaceOrientation = [UIApplication sharedApplication].delegate.window.windowScene.interfaceOrientation;
440+
#endif
433441

434442
switch (interfaceOrientation) {
435443
case UIInterfaceOrientationLandscapeLeft: {

drivers/apple_embedded/view_controller.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ - (void)observeKeyboard {
187187
}
188188

189189
- (void)displayLoadingOverlay {
190+
#if !defined(VISIONOS_ENABLED)
190191
NSBundle *bundle = [NSBundle mainBundle];
191192
NSString *storyboardName = @"Launch Screen";
192193

@@ -202,6 +203,7 @@ - (void)displayLoadingOverlay {
202203
self.godotLoadingOverlay.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
203204

204205
[self.view addSubview:self.godotLoadingOverlay];
206+
#endif
205207
}
206208

207209
- (BOOL)godotViewFinishedSetup:(GDTView *)view {

drivers/metal/metal_device_properties.mm

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050

5151
#import "metal_device_properties.h"
5252

53+
#include "servers/rendering/renderer_rd/effects/metal_fx.h"
54+
5355
#import <Metal/Metal.h>
5456
#import <MetalFX/MetalFX.h>
5557
#import <spirv_cross.hpp>
@@ -63,7 +65,7 @@
6365
#define MTLGPUFamilyApple9 (MTLGPUFamily)1009
6466
#endif
6567

66-
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
68+
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), visionos(1.0))
6769
MTLGPUFamily &operator--(MTLGPUFamily &p_family) {
6870
p_family = static_cast<MTLGPUFamily>(static_cast<int>(p_family) - 1);
6971
if (p_family < MTLGPUFamilyApple1) {
@@ -126,7 +128,11 @@
126128

127129
if (@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
128130
features.metal_fx_spatial = [MTLFXSpatialScalerDescriptor supportsDevice:p_device];
131+
#ifdef METAL_MFXTEMPORAL_ENABLED
129132
features.metal_fx_temporal = [MTLFXTemporalScalerDescriptor supportsDevice:p_device];
133+
#else
134+
features.metal_fx_temporal = false;
135+
#endif
130136
}
131137

132138
MTLCompileOptions *opts = [MTLCompileOptions new];
@@ -136,7 +142,7 @@
136142
features.mslVersion = SPIRV_CROSS_NAMESPACE::CompilerMSL::Options::make_msl_version(m_maj, m_min)
137143

138144
switch (features.mslVersionEnum) {
139-
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000 || __TV_OS_VERSION_MAX_ALLOWED >= 180000
145+
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000 || __TV_OS_VERSION_MAX_ALLOWED >= 180000 || __VISION_OS_VERSION_MAX_ALLOWED >= 20000
140146
case MTLLanguageVersion3_2:
141147
setMSLVersion(3, 2);
142148
break;
@@ -170,7 +176,7 @@
170176
case MTLLanguageVersion1_1:
171177
setMSLVersion(1, 1);
172178
break;
173-
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
179+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST && !TARGET_OS_VISION
174180
case MTLLanguageVersion1_0:
175181
setMSLVersion(1, 0);
176182
break;
@@ -324,6 +330,7 @@
324330

325331
limits.maxDrawIndexedIndexValue = std::numeric_limits<uint32_t>::max() - 1;
326332

333+
#ifdef METAL_MFXTEMPORAL_ENABLED
327334
if (@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)) {
328335
limits.temporalScalerInputContentMinScale = (double)[MTLFXTemporalScalerDescriptor supportedInputContentMinScaleForDevice:p_device];
329336
limits.temporalScalerInputContentMaxScale = (double)[MTLFXTemporalScalerDescriptor supportedInputContentMaxScaleForDevice:p_device];
@@ -332,6 +339,11 @@
332339
limits.temporalScalerInputContentMinScale = 1.0;
333340
limits.temporalScalerInputContentMaxScale = 3.0;
334341
}
342+
#else
343+
// Defaults taken from macOS 14+
344+
limits.temporalScalerInputContentMinScale = 1.0;
345+
limits.temporalScalerInputContentMaxScale = 3.0;
346+
#endif
335347
}
336348

337349
MetalDeviceProperties::MetalDeviceProperties(id<MTLDevice> p_device) {

drivers/metal/pixel_formats.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ void clear(T *p_val, size_t p_count = 1) {
114114
}
115115

116116
bool PixelFormats::isPVRTCFormat(MTLPixelFormat p_format) {
117+
#if defined(VISIONOS_ENABLED)
118+
return false;
119+
#else
117120
switch (p_format) {
118121
case MTLPixelFormatPVRTC_RGBA_2BPP:
119122
case MTLPixelFormatPVRTC_RGBA_2BPP_sRGB:
@@ -127,6 +130,7 @@ void clear(T *p_val, size_t p_count = 1) {
127130
default:
128131
return false;
129132
}
133+
#endif
130134
}
131135

132136
MTLFormatType PixelFormats::getFormatType(DataFormat p_format) {
@@ -668,11 +672,13 @@ void clear(T *p_val, size_t p_count = 1) {
668672
addMTLPixelFormatDesc(RGBA32Sint, Color128, RWC);
669673
addMTLPixelFormatDesc(RGBA32Float, Color128, All);
670674

675+
#if !defined(VISIONOS_ENABLED)
671676
// Compressed pixel formats
672677
addMTLPixelFormatDesc(PVRTC_RGBA_2BPP, PVRTC_RGBA_2BPP, RF);
673678
addMTLPixelFormatDescSRGB(PVRTC_RGBA_2BPP_sRGB, PVRTC_RGBA_2BPP, RF, PVRTC_RGBA_2BPP);
674679
addMTLPixelFormatDesc(PVRTC_RGBA_4BPP, PVRTC_RGBA_4BPP, RF);
675680
addMTLPixelFormatDescSRGB(PVRTC_RGBA_4BPP_sRGB, PVRTC_RGBA_4BPP, RF, PVRTC_RGBA_4BPP);
681+
#endif
676682

677683
addMTLPixelFormatDesc(ETC2_RGB8, ETC2_RGB8, RF);
678684
addMTLPixelFormatDescSRGB(ETC2_RGB8_sRGB, ETC2_RGB8, RF, ETC2_RGB8);

drivers/metal/rendering_device_driver_metal.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,11 @@ _FORCE_INLINE_ MTLSize mipmapLevelSizeFromSize(MTLSize p_size, NSUInteger p_leve
290290
// Usage.
291291

292292
MTLResourceOptions options = 0;
293+
#if defined(VISIONOS_ENABLED)
294+
const bool supports_memoryless = true;
295+
#else
293296
const bool supports_memoryless = (*device_properties).features.highestFamily >= MTLGPUFamilyApple2 && (*device_properties).features.highestFamily < MTLGPUFamilyMac1;
297+
#endif
294298
if (supports_memoryless && p_format.usage_bits & TEXTURE_USAGE_TRANSIENT_BIT) {
295299
options = MTLResourceStorageModeMemoryless | MTLResourceHazardTrackingModeTracked;
296300
desc.storageMode = MTLStorageModeMemoryless;
@@ -2493,7 +2497,11 @@ void deserialize(BufReader &p_reader) {
24932497
cd->name = binary_data.shader_name;
24942498
cd->stage = shader_data.stage;
24952499
options.preserveInvariance = shader_data.is_position_invariant;
2500+
#if defined(VISIONOS_ENABLED)
2501+
options.mathMode = MTLMathModeFast;
2502+
#else
24962503
options.fastMathEnabled = YES;
2504+
#endif
24972505
MDLibrary *library = [MDLibrary newLibraryWithCacheEntry:cd
24982506
device:device
24992507
source:source

editor/export/macho.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class MachO : public RefCounted {
111111
PLATFORM_TVOSSIMULATOR = 8,
112112
PLATFORM_WATCHOSSIMULATOR = 9,
113113
PLATFORM_DRIVERKIT = 10,
114+
PLATFORM_VISIONOS = 11,
115+
PLATFORM_VISIONOSSIMULATOR = 12,
114116
};
115117

116118
struct LoadCommandHeader {

main/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
21912191
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.linuxbsd", PROPERTY_HINT_ENUM, "vulkan"), "vulkan");
21922192
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.android", PROPERTY_HINT_ENUM, "vulkan"), "vulkan");
21932193
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.ios", PROPERTY_HINT_ENUM, "metal,vulkan"), "metal");
2194+
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.visionos", PROPERTY_HINT_ENUM, "metal"), "metal");
21942195
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", PROPERTY_HINT_ENUM, "metal,vulkan"), "metal");
21952196

21962197
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_vulkan", true);
@@ -2672,6 +2673,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
26722673
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.linuxbsd", PROPERTY_HINT_ENUM_SUGGESTION, "default,x11,wayland,headless"), "default");
26732674
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.android", PROPERTY_HINT_ENUM_SUGGESTION, "default,android,headless"), "default");
26742675
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.ios", PROPERTY_HINT_ENUM_SUGGESTION, "default,iOS,headless"), "default");
2676+
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.visionos", PROPERTY_HINT_ENUM_SUGGESTION, "default,visionOS,headless"), "default");
26752677
GLOBAL_DEF_NOVAL(PropertyInfo(Variant::STRING, "display/display_server/driver.macos", PROPERTY_HINT_ENUM_SUGGESTION, "default,macos,headless"), "default");
26762678

26772679
GLOBAL_DEF_RST_NOVAL("audio/driver/driver", AudioDriverManager::get_driver(0)->get_name());

methods.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,14 @@ def detect_darwin_sdk_path(platform, env):
636636
sdk_name = "iphonesimulator"
637637
var_name = "IOS_SDK_PATH"
638638

639+
elif platform == "visionos":
640+
sdk_name = "xros"
641+
var_name = "VISIONOS_SDK_PATH"
642+
643+
elif platform == "visionossimulator":
644+
sdk_name = "xrsimulator"
645+
var_name = "VISIONOS_SDK_PATH"
646+
639647
else:
640648
raise Exception("Invalid platform argument passed to detect_darwin_sdk_path")
641649

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyAccessedAPITypes</key>
6+
$priv_api_types
7+
$priv_tracking
8+
$priv_collection
9+
</dict>
10+
</plist>

misc/dist/visionos_xcode/data.pck

Whitespace-only changes.

0 commit comments

Comments
 (0)