From 6374d9d29b75c4a922d39ca2e8554402fafd0469 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Tue, 11 Jul 2023 14:22:59 -0400 Subject: [PATCH] Fix visionOS build errors and warnings where possible. - Remove visionOS from multi-platform builds because it requires Xcode 15+ and will abort a multi-platform build. - Define TARGET_OS_XR for older SDK's. - A number of SDK deprecation warnings remain when building for visionOS. These cannot be removed without significant refactoring. - Build visionOS dependencies for Release build by default. - Fix local variable initialization warning (unrelated). --- Common/MVKCommonEnvironment.h | 3 + Docs/Whats_New.md | 1 + .../ExternalDependencies-xrOS.xcscheme | 2 +- Makefile | 10 +-- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 2 +- README.md | 70 +++++++++++-------- fetchDependencies | 13 ++-- 7 files changed, 62 insertions(+), 39 deletions(-) diff --git a/Common/MVKCommonEnvironment.h b/Common/MVKCommonEnvironment.h index d75396b8b..a14ba91d0 100644 --- a/Common/MVKCommonEnvironment.h +++ b/Common/MVKCommonEnvironment.h @@ -63,6 +63,9 @@ extern "C" { #endif /** Building for visionOS. */ +#ifndef TARGET_OS_XR +# define TARGET_OS_XR 0 // Older SDK's don't define TARGET_OS_XR +#endif #ifndef MVK_VISIONOS # define MVK_VISIONOS TARGET_OS_XR #endif diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 5131889b8..755cb806a 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -26,6 +26,7 @@ Released TBD - `VK_EXT_shader_subgroup_ballot` - `VK_EXT_shader_subgroup_vote` - Add support for `VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN`. +- Support building MoltenVK for visionOS. - Ensure non-dispatch compute commands don't interfere with compute encoding state used by dispatch commands. - Support `VK_PRESENT_MODE_IMMEDIATE_KHR` if `VkPresentTimeGOOGLE::desiredPresentTime` is zero. - Support maximizing the concurrent executing compilation tasks via `MVKConfiguration::shouldMaximizeConcurrentCompilation` diff --git a/ExternalDependencies.xcodeproj/xcshareddata/xcschemes/ExternalDependencies-xrOS.xcscheme b/ExternalDependencies.xcodeproj/xcshareddata/xcschemes/ExternalDependencies-xrOS.xcscheme index 288332c83..27214297a 100644 --- a/ExternalDependencies.xcodeproj/xcshareddata/xcschemes/ExternalDependencies-xrOS.xcscheme +++ b/ExternalDependencies.xcodeproj/xcshareddata/xcschemes/ExternalDependencies-xrOS.xcscheme @@ -30,7 +30,7 @@ shouldAutocreateTestPlan = "YES"> pPipelineCreationFeedback; // n.b. Do *NOT* use mvkClear(). diff --git a/README.md b/README.md index 8349a8caa..e44e34a61 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Table of Contents ----------------- - [Introduction to **MoltenVK**](#intro) -- [Developing Vulkan Applications on *macOS, iOS, and tvOS*](#developing_vulkan) +- [Developing Vulkan Applications on *macOS, iOS, tvOS, and visionOS*](#developing_vulkan) - [Using the *Vulkan SDK*](#sdk) - [Using MoltenVK Directly](#download) - [Fetching **MoltenVK** Source Code](#install) @@ -38,19 +38,20 @@ Introduction to MoltenVK **MoltenVK** is a layered implementation of [*Vulkan 1.2*](https://www.khronos.org/vulkan) graphics and compute functionality, that is built on Apple's [*Metal*](https://developer.apple.com/metal) -graphics and compute framework on *macOS*, *iOS*, and *tvOS*. **MoltenVK** allows you to use *Vulkan* -graphics and compute functionality to develop modern, cross-platform, high-performance graphical -games and applications, and to run them across many platforms, including *macOS*, *iOS*, *tvOS*, -*Simulators*, and *Mac Catalyst* on *macOS 11.0+*, and all *Apple* architectures, including *Apple Silicon*. +graphics and compute framework on *macOS*, *iOS*, *tvOS*, and *visionOS*. **MoltenVK** allows +you to use *Vulkan* graphics and compute functionality to develop modern, cross-platform, +high-performance graphical games and applications, and to run them across many platforms, +including *macOS*, *iOS*, *tvOS*, *visionOS*, *Simulators*, and *Mac Catalyst* on *macOS 11.0+*, +and all *Apple* architectures, including *Apple Silicon*. *Metal* uses a different shading language, the *Metal Shading Language (MSL)*, than *Vulkan*, which uses *SPIR-V*. **MoltenVK** automatically converts your *SPIR-V* shaders to their *MSL* equivalents. -To provide *Vulkan* capability to the *macOS*, *iOS*, and *tvOS* platforms, **MoltenVK** uses *Apple's* -publicly available API's, including *Metal*. **MoltenVK** does **_not_** use any private or -undocumented API calls or features, so your app will be compatible with all standard distribution -channels, including *Apple's App Store*. +To provide *Vulkan* capability to the *macOS*, *iOS*, *tvOS*, and *visionOS* platforms, +**MoltenVK** uses *Apple's* publicly available API's, including *Metal*. **MoltenVK** +does **_not_** use any private or undocumented API calls or features, so your app will +be compatible with all standard distribution channels, including *Apple's App Store*. The **MoltenVK** runtime package contains two products: @@ -67,8 +68,8 @@ The **MoltenVK** runtime package contains two products: -Developing *Vulkan* Applications for *macOS, iOS, and tvOS* ---------------------------------------------------------- +Developing *Vulkan* Applications for *macOS, iOS, tvOS, and visionOS* +--------------------------------------------------------------------- ### Using the *Vulkan SDK* @@ -96,10 +97,10 @@ extension in the *Vulkan* specification for more information about the use of th ### Using MoltenVK Directly -If you are developing a *Vulkan* application for *iOS* or *tvOS*, or are developing a -*Vulkan* application for *macOS* and want to use a different version or build of the -**MoltenVK** runtime library than provided in the *macOS Vulkan SDK*, you can access -a pre-built MoltenVK binary library from the **MoltenVK** repository, by +If you are developing a *Vulkan* application for *iOS*, *tvOS*, or *visionOS*, or are +developing a *Vulkan* application for *macOS* and want to use a different version or +build of the **MoltenVK** runtime library than provided in the *macOS Vulkan SDK*, +you can access a pre-built MoltenVK binary library from the **MoltenVK** repository, by [selecting a repository commit from the list](https://github.com/KhronosGroup/MoltenVK/actions), and downloading the associated **MoltenVK** runtime library artifact. @@ -148,14 +149,21 @@ for which to build the external libraries. The platform choices include: --maccat --tvos --tvossim + --visionos + --visionossim + +The `visionos` and `visionossim` selections require Xcode 15+. You can specify multiple of these selections. The result is a single `XCFramework` for each external dependency library, with each `XCFramework` containing binaries for each of the requested platforms. -The `--all` selection is the same as entering all of the other platform choices, -and will result in a single `XCFramework` for each external dependency library, -with each `XCFramework` containing binaries for all supported platforms and simulators. +The `--all` selection is the same as entering all of the other platform choices, except +`--visionos` and `--visionossim`, and will result in a single `XCFramework` for each +external dependency library, with each `XCFramework` containing binaries for all supported +platforms and simulators. The `--visionos` and `--visionossim` selections must be invoked +with a separate invocation of `fetchDependencies`, because those selections require +Xcode 15+, and will cause a multi-platform build on older versions of Xcode to abort. Running `fetchDependencies` repeatedly with different platforms will accumulate targets in the `XCFramework`. @@ -196,11 +204,11 @@ _Xcode_ version. If you require support for earlier OS versions, modify the `MAC build setting of `iOS 11.0` or greater, or a minimum **tvOS Deployment Target** (aka `TVOS_DEPLOYMENT_TARGET `) build setting of `tvOS 11.0` or greater. -Once built, the **MoltenVK** libraries can be run on *macOS*, *iOS* or *tvOS* devices that support *Metal*, -or on the *Xcode* *iOS Simulator* or *tvOS Simulator*. +Once built, the **MoltenVK** libraries can be run on *macOS*, *iOS*, *tvOS*, or *visionOS* devices +that support *Metal*,or on the *Xcode* *iOS Simulator*, *tvOS Simulator*, or *visionOS Simulator*. -- At runtime, **MoltenVK** requires at least *macOS 10.11*, *iOS 9*, or *tvOS 9* - (or *iOS 11* or *tvOS 11* if using `IOSurfaces`). +- At runtime, **MoltenVK** requires at least *macOS 10.11*, *iOS 9.0*, *tvOS 9.0*, + or *visionOS 1.0* (or *iOS 11* or *tvOS 11* if using `IOSurfaces`). - Information on *macOS* devices that are compatible with *Metal* can be found in [this article](http://www.idownloadblog.com/2015/06/22/how-to-find-mac-el-capitan-metal-compatible). - Information on *iOS* devices that are compatible with *Metal* can be found in @@ -220,6 +228,7 @@ platforms, or just one platform (in **_Release_** configuration): - **MoltenVK Package (macOS only)** - **MoltenVK Package (iOS only)** - **MoltenVK Package (tvOS only)** +- **MoltenVK Package (visionOS only)** _(requires Xcode 15+)_ Each of these`MoltenVKPackaging.xcodeproj` *Xcode* project *Schemes* puts the resulting packages in the `Package` directory, creating it if necessary. This directory contains separate `Release` and `Debug` @@ -254,6 +263,8 @@ from the command line. The following `make` targets are provided: make maccat make tvos make tvossim + make visionos + make visionossim make all-debug make macos-debug @@ -262,12 +273,15 @@ from the command line. The following `make` targets are provided: make maccat-debug make tvos-debug make tvossim-debug + make visionos-debug + make visionossim-debug make clean make install - Running `make` repeatedly with different targets will accumulate binaries for these different targets. -- The `all` target executes all platform targets. +- The `all` target executes all platform targets, except `visionos` and `visionossim`, as these require + Xcode 15+, and will abort a multi-platform build on older versions of Xcode. - The `all` target is the default target. Running `make` with no arguments is the same as running `make all`. - The `*-debug` targets build the binaries using the **_Debug_** configuration. - The `install` target will copy the most recently built `MoltenVK.xcframework` into the @@ -346,14 +360,14 @@ the contents of that directory out of this **MoltenVK** repository into your own ------------------------------------ **MoltenVK** is designed to be an implementation of a *Vulkan 1.2* subset that runs on *macOS*, *iOS*, -and *tvOS* platforms by mapping *Vulkan* capability to native *Metal* capability. +*tvOS*, and *visionOS* platforms by mapping *Vulkan* capability to native *Metal* capability. The fundamental design and development goal of **MoltenVK** is to provide this capability in a way that is both maximally compliant with the *Vulkan 1.2* specification, and maximally performant. -Such compliance and performance is inherently affected by the capability available through *Metal*, as the -native graphics driver on *macOS*, *iOS*, and *tvOS* platforms. *Vulkan* compliance may fall into one of -the following categories: +Such compliance and performance is inherently affected by the capability available through *Metal*, +as the native graphics driver on *macOS*, *iOS*, *tvOS*, and *visionOS* platforms. *Vulkan* +compliance may fall into one of the following categories: - Direct mapping between *Vulkan* capabilities and *Metal* capabilities. Within **MoltenVK**, the vast majority of *Vulkan* capability is the result of this type of direct mapping. @@ -376,7 +390,7 @@ be implemented or worked around. [*Khronos Vulkan Portability Initiative*](https://www.khronos.org/vulkan/portability-initiative), whose intention is to provide specifications, resources, and tools to allow developers to understand and design their *Vulkan* apps for maximum cross-platform compatibility and portability, including on platforms, such as -*macOS*, *iOS*, and *tvOS*, where a native *Vulkan* driver is not available. +*macOS*, *iOS*, *tvOS*, and *visionOS*, where a native *Vulkan* driver is not available. diff --git a/fetchDependencies b/fetchDependencies index 04e065fe1..a340348be 100755 --- a/fetchDependencies +++ b/fetchDependencies @@ -4,7 +4,8 @@ # # fetchDependencies - Retrieves the correct versions of all dependencies # -# macOS usage: ./fetchDependencies [--macos] [--ios] [--iossim] [--tvos] [--tvossim] [--all] [--none] +# macOS usage: ./fetchDependencies [--macos] [--ios] [--iossim] [--tvos] [--tvossim] +# [--visionos] [--visionossim] [--all] [--none] # [-v] [--debug] [--build-spirv-tools] # [--v-headers-root path] [--spirv-cross-root path] [--glslang-root path] # @@ -33,9 +34,11 @@ # Build the external libraries for the visionOS Simulator platform. # # --all -# Equivalent to specifying [--macos --ios --iossim --maccat --tvos --tvossim --visionos --visionossim]. +# Equivalent to specifying [--macos --ios --iossim --maccat --tvos --tvossim]. # Results in one XCFramework for each external library, each containing # binaries for all supported platforms. +# Currently excludes --visionos and --visionossim targets because those +# require Xcode 15+ and will abort a multi-platform build. # # --none # Don't build the external libraries for any platform (this is the default). @@ -150,14 +153,14 @@ while (( "$#" )); do shift 1 ;; --all) + BLD_MACOS="Y" BLD_IOS="Y" BLD_IOS_SIM="Y" BLD_MAC_CAT="Y" BLD_TVOS="Y" BLD_TVOS_SIM="Y" - BLD_VISIONOS="Y" - BLD_VISIONOS_SIM="Y" - BLD_MACOS="Y" +# BLD_VISIONOS="Y" # Requires Xcode 15+ +# BLD_VISIONOS_SIM="Y" # Requires Xcode 15+ shift 1 ;; --none)