2017-11-17 11:14:29 -05:00
< a class = "site-logo" href = "https://github.com/KhronosGroup/MoltenVK" title = "MoltenVK" >
< img src = "Docs/images/MoltenVK-Logo-Banner.png" alt = "MoltenVK" style = "width:256px;height:auto" >
< / a >
MoltenVK
========
2024-01-04 14:51:53 -05:00
Copyright (c) 2015-2024 [The Brenwill Workshop Ltd. ](http://www.brenwill.com )
2017-11-17 11:14:29 -05:00
2021-01-09 00:13:44 +03:00
[comment]: # "This document is written in Markdown (http://en.wikipedia.org/wiki/Markdown) format."
[comment]: # "For best results, use a Markdown reader."
2017-11-17 11:14:29 -05:00
2021-01-21 14:49:24 -05:00

2017-11-17 11:14:29 -05:00
Table of Contents
-----------------
2019-02-08 19:36:52 -05:00
- [Introduction to **MoltenVK** ](#intro )
2023-07-11 14:22:59 -04:00
- [Developing Vulkan Applications on *macOS, iOS, tvOS, and visionOS* ](#developing_vulkan )
2023-05-08 18:14:22 -04:00
- [Using the *Vulkan SDK* ](#sdk )
- [Using MoltenVK Directly ](#download )
2019-02-08 19:36:52 -05:00
- [Fetching **MoltenVK** Source Code ](#install )
2017-11-17 11:14:29 -05:00
- [Building **MoltenVK** ](#building )
2024-01-25 10:42:26 -05:00
- [Building from the Command Line ](#command_line_build )
- [Hiding _Vulkan_ API Symbols ](#hiding_vulkan_symbols )
- [Accessing _Metal_ Private API calls ](#metal_private_api )
2021-03-03 16:43:11 -05:00
- [Running **MoltenVK** Demo Applications ](#demos )
2017-11-17 11:14:29 -05:00
- [Using **MoltenVK** in Your Application ](#using )
2018-03-06 16:51:05 -05:00
- [**MoltenVK** and *Vulkan* Compliance ](#compliance )
2021-02-12 10:46:57 -05:00
- [Getting Support ](#support )
2018-03-06 16:51:05 -05:00
- [Contributing to **MoltenVK** Development ](#contributing )
2017-11-17 11:14:29 -05:00
< a name = "intro" > < / a >
2019-02-08 19:36:52 -05:00
Introduction to MoltenVK
------------------------
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
**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* , *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+* ,
2023-07-11 14:22:59 -04:00
and all *Apple* architectures, including *Apple Silicon* .
2018-07-23 20:12:57 -04:00
2023-12-18 11:00:35 -05:00
*Metal* uses a different shading language, the *Metal Shading Language (MSL)* , than
*Vulkan*, which uses *SPIR-V* . **MoltenVK** automatically converts your *SPIR-V* shaders
2018-07-23 20:12:57 -04:00
to their *MSL* equivalents.
2023-12-18 11:00:35 -05:00
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
2023-07-11 14:22:59 -04:00
be compatible with all standard distribution channels, including *Apple's App Store* .
2018-07-23 20:12:57 -04:00
2019-02-08 19:36:52 -05:00
The **MoltenVK** runtime package contains two products:
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
- **MoltenVK** is a implementation of an almost-complete subset of the
2022-09-26 11:25:49 -04:00
[*Vulkan 1.2* ](https://www.khronos.org/vulkan ) graphics and compute API.
2017-11-17 11:14:29 -05:00
- **MoltenVKShaderConverter** converts *SPIR-V* shader code to *Metal Shading Language (MSL)*
2018-07-23 20:12:57 -04:00
shader code, and converts *GLSL* shader source code to *SPIR-V* shader code and/or
2023-12-18 11:00:35 -05:00
*Metal Shading Language (MSL)* shader code. The converter is embedded in the **MoltenVK**
runtime to automatically convert *SPIR-V* shaders to their *MSL* equivalents. In addition,
both the *SPIR-V* and *GLSL* converters are packaged into a stand-alone command-line
2020-09-01 14:39:46 -04:00
`MoltenVKShaderConverter` *macOS* tool for converting shaders at development time from the command line.
2017-11-17 11:14:29 -05:00
2023-05-08 18:14:22 -04:00
< a name = "developing_vulkan" > < / a >
2023-07-11 14:22:59 -04:00
Developing *Vulkan* Applications for *macOS, iOS, tvOS, and visionOS*
---------------------------------------------------------------------
2023-05-08 18:14:22 -04:00
< a name = "sdk" > < / a >
### Using the *Vulkan SDK*
2023-12-18 11:00:35 -05:00
The recommended method for developing a *Vulkan* application for *macOS* is to use the
2023-05-08 18:14:22 -04:00
[*Vulkan SDK* ](https://vulkan.lunarg.com/sdk/home ).
2023-12-18 11:00:35 -05:00
The *Vulkan SDK* includes a **MoltenVK** runtime library for *macOS* . *Vulkan* is a layered
architecture that allows applications to add additional functionality without modifying the
2023-05-08 18:14:22 -04:00
application itself. The *Validation Layers* included in the *Vulkan SDK* are an essential debugging
2023-12-18 11:00:35 -05:00
tool for application developers because they identify inappropriate use of the *Vulkan API* .
2023-05-08 18:14:22 -04:00
If you are developing a *Vulkan* application for *macOS* , it is highly recommended that you use the
[*Vulkan SDK* ](https://vulkan.lunarg.com/sdk/home ) and the **MoltenVK** library included in it.
2023-12-18 11:00:35 -05:00
Refer to the *Vulkan SDK [Getting Started](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html)*
2023-05-08 18:14:22 -04:00
document for more info.
2023-12-18 11:00:35 -05:00
Because **MoltenVK** supports the `VK_KHR_portability_subset` extension, when using the
*Vulkan Loader* from the *Vulkan SDK* to run **MoltenVK** on *macOS* , the *Vulkan Loader*
will only include **MoltenVK** `VkPhysicalDevices` in the list returned by
`vkEnumeratePhysicalDevices()` if the `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR`
flag is enabled in `vkCreateInstance()` . See the description of the `VK_KHR_portability_enumeration`
extension in the *Vulkan* specification for more information about the use of the
2023-05-08 18:14:22 -04:00
`VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` flag.
< a name = "download" > < / a >
### Using MoltenVK Directly
2023-12-18 11:00:35 -05:00
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* ,
2023-07-11 14:22:59 -04:00
you can access a pre-built MoltenVK binary library from the **MoltenVK** repository, by
2023-05-08 18:14:22 -04:00
[selecting a repository commit from the list ](https://github.com/KhronosGroup/MoltenVK/actions ),
and downloading the associated **MoltenVK** runtime library artifact.
Finally, if you want a customized build of **MoltenVK** , you can follow the [instructions below ](#install )
to create a **MoltenVK** runtime library by fetching and building the **MoltenVK** source code.
To learn how to integrate the **MoltenVK** runtime library into a game or application,
2023-12-18 11:00:35 -05:00
see the [`MoltenVK_Runtime_UserGuide.md ` ](Docs/MoltenVK_Runtime_UserGuide.md )
document in the `Docs` directory.
2023-05-08 18:14:22 -04:00
2017-11-17 11:14:29 -05:00
< a name = "install" > < / a >
2019-02-08 19:36:52 -05:00
Fetching **MoltenVK** Source Code
---------------------------------
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
To fetch **MoltenVK** source code, clone this `MoltenVK` repository, and then run the
`fetchDependencies` script to retrieve and build several external open-source libraries
2019-02-08 19:36:52 -05:00
on which **MoltenVK** relies:
2017-11-17 11:14:29 -05:00
2018-03-06 14:07:06 -05:00
1. Ensure you have `cmake` and `python3` installed:
2017-11-17 11:14:29 -05:00
2018-03-06 14:07:06 -05:00
brew install cmake
2019-06-16 12:00:22 -04:00
brew install python3
2017-11-17 11:14:29 -05:00
2018-04-09 14:26:02 -04:00
For faster dependency builds, you can also optionally install `ninja` :
2018-04-04 20:48:21 +02:00
brew install ninja
2018-03-12 10:02:13 -04:00
2. Clone the `MoltenVK` repository:
2018-03-01 21:39:39 -05:00
2018-03-12 10:02:13 -04:00
git clone https://github.com/KhronosGroup/MoltenVK.git
2018-03-01 21:39:39 -05:00
2018-03-12 10:02:13 -04:00
3. Retrieve and build the external libraries:
2017-11-17 11:14:29 -05:00
2018-03-30 22:16:27 -04:00
cd MoltenVK
2020-06-17 19:10:33 -04:00
./fetchDependencies [platform...]
2023-12-18 11:00:35 -05:00
When running the `fetchDependencies` script, you must specify one or more platforms
for which to build the external libraries. The platform choices include:
2020-06-17 19:10:33 -04:00
2023-12-18 11:00:35 -05:00
--all
--macos
--ios
--iossim
--maccat
--tvos
2020-09-01 14:39:46 -04:00
--tvossim
2020-06-17 19:10:33 -04:00
2023-12-18 11:00:35 -05:00
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.
2020-09-01 14:39:46 -04:00
2023-12-18 11:00:35 -05:00
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.
2020-09-01 14:39:46 -04:00
2023-12-18 11:00:35 -05:00
Running `fetchDependencies` repeatedly with different platforms will accumulate targets
2023-10-23 20:04:04 -04:00
in the `XCFramework` , if the `--keep-cache` option is used on each invocation.
2017-11-17 11:14:29 -05:00
2018-03-12 10:02:13 -04:00
For more information about the external open-source libraries used by **MoltenVK** ,
2018-03-30 22:16:27 -04:00
see the [`ExternalRevisions/README.md` ](ExternalRevisions/README.md ) document.
2017-11-17 11:14:29 -05:00
< a name = "building" > < / a >
Building **MoltenVK**
-------------------
2023-12-18 11:00:35 -05:00
During building, **MoltenVK** references the latest *Apple SDK* frameworks. To access these frameworks,
2019-02-13 14:34:55 -05:00
and to avoid build errors, be sure to use the latest publicly available version of *Xcode* .
2018-03-01 19:42:15 -05:00
2023-12-18 11:00:35 -05:00
> ***Note:*** *Xcode 14* introduced a new static linkage model that is not compatible with previous
versions of *Xcode* . If you link to a `MoltenVK.xcframework` that was built with *Xcode 14* or later,
also use *Xcode 14* or later to link it to your app or game.
2022-11-15 18:48:36 -05:00
>
2023-12-18 11:00:35 -05:00
> If you need to use *Xcode 13* or earlier to link `MoltenVK.xcframework` to your app or game,
first build **MoltenVK** with *Xcode 13* or earlier.
2022-11-15 18:48:36 -05:00
>
2023-12-18 11:00:35 -05:00
> Or, if you want to use *Xcode 14* or later to build **MoltenVK**, in order to be able to use the
latest *Metal* capabilities, but need to use *Xcode 13* or earlier to link `MoltenVK.xcframework`
to your app or game, first add the value `-fno-objc-msgsend-selector-stubs` to the `OTHER_CFLAGS`
*Xcode* build setting in the `MoltenVK.xcodeproj` and `MoltenVKShaderConverter.xcodeproj` *Xcode*
projects, build **MoltenVK** with *Xcode 14* or later, and then link `MoltenVK.xcframework`
2022-11-15 18:48:36 -05:00
to your app or game using *Xcode 13* or earlier.
2023-12-18 11:00:35 -05:00
**MoltenVK** can be built to support at least *macOS 10.11* , *iOS 9* , or *tvOS 9* , but the default
_Xcode_ build settings in the included _Xcode_ projects are set to a minimum deployment target of
*macOS 10.13*, *iOS 11* , and *tvOS 11* , which are the oldest OS versions supported by the current
_Xcode_ version. If you require support for earlier OS versions, modify the `MACOSX_DEPLOYMENT_TARGET` ,
Support Xcode 14, macOS 13, and iOS/tvOS 16.
- Update minimum Xcode deployment targets to macOS 10.13, iOS 11, and tvOS 11,
to avoid Xcode build warnings.
- Add support for MTLLanguageVersion3_0 enumeration.
- Build efficiencies:
- Build scripts create_dylib.sh and gen_moltenvk_rev_hdr.sh
only run if build dependencies require it.
- Packaging and copy_to_staging.sh scripts are too complex to define dependencies,
and are fast, so configured to run every time, to avoid build warning.
- Replace use of deprecated sprintf() with snprintf().
- Replace use of deprecated kIOMasterPortDefault with kIOMainPortDefault.
- Support old-style GPU debug capture only if building for earlier minimum
deployment targets, to avoid deprecation warning.
- Update minimum Xcode deployment targets of Cube demo to macOS 10.14, iOS 12,
and tvOS 12, to avoid Xcode build warning regarding MTLSharedEvent in .
- Update README.md document regarding minimum Xcode deployment targets.
2022-07-06 18:15:10 -04:00
`IPHONEOS_DEPLOYMENT_TARGET` , or `TVOS_DEPLOYMENT_TARGET` build settings in _Xcode_ before building **MoltenVK** .
2023-12-18 11:00:35 -05:00
>***Note:*** To support `IOSurfaces` on *iOS* or *tvOS* , **MoltenVK** , and any app that uses
**MoltenVK**, must be built with a minimum **iOS Deployment Target** (aka `IPHONEOS_DEPLOYMENT_TARGET ` )
build setting of `iOS 11.0` or greater, or a minimum **tvOS Deployment Target** (aka `TVOS_DEPLOYMENT_TARGET ` )
2020-06-23 23:06:08 -04:00
build setting of `tvOS 11.0` or greater.
2019-02-13 14:34:55 -05:00
2023-12-18 11:00:35 -05:00
Once built, the **MoltenVK** libraries can be run on *macOS* , *iOS* , *tvOS* , or *visionOS* devices
2023-07-11 14:22:59 -04:00
that support *Metal* ,or on the *Xcode* *iOS Simulator* , *tvOS Simulator* , or *visionOS Simulator* .
2018-03-01 19:42:15 -05:00
2023-12-18 11:00:35 -05:00
- At runtime, **MoltenVK** requires at least *macOS 10.11* , *iOS 9.0* , *tvOS 9.0* ,
2023-07-11 14:22:59 -04:00
or *visionOS 1.0* (or *iOS 11* or *tvOS 11* if using `IOSurfaces` ).
2023-12-18 11:00:35 -05:00
- Information on *macOS* devices that are compatible with *Metal* can be found in
2018-03-01 19:42:15 -05:00
[this article ](http://www.idownloadblog.com/2015/06/22/how-to-find-mac-el-capitan-metal-compatible ).
2023-12-18 11:00:35 -05:00
- Information on *iOS* devices that are compatible with *Metal* can be found in
2018-03-01 19:42:15 -05:00
[this article ](https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/HardwareGPUInformation/HardwareGPUInformation.html ).
2023-12-18 11:00:35 -05:00
The `MoltenVKPackaging.xcodeproj` *Xcode* project contains targets and schemes to build
and package the entire **MoltenVK** runtime distribution package, or to build individual
2017-11-17 11:14:29 -05:00
**MoltenVK** or **MoltenVKShaderConverter** components.
2023-12-18 11:00:35 -05:00
To build a **MoltenVK** runtime distribution package, suitable for testing and integrating into an app,
2018-09-16 14:46:01 -04:00
open `MoltenVKPackaging.xcodeproj` in *Xcode* , and use one of the following *Xcode Schemes* , depending
2023-12-18 11:00:35 -05:00
on whether you want a **_Release_** or **_Debug_** configuration, and whether you want to build for all
2020-06-19 15:05:43 -04:00
platforms, or just one platform (in **_Release_** configuration):
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
- **MoltenVK Package**
- **MoltenVK Package (Debug)**
- **MoltenVK Package (macOS only)**
2018-10-30 23:16:12 -04:00
- **MoltenVK Package (iOS only)**
2020-06-19 15:05:43 -04:00
- **MoltenVK Package (tvOS only)**
2023-07-11 14:22:59 -04:00
- **MoltenVK Package (visionOS only)** _(requires Xcode 15+)_
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
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`
2018-10-30 23:16:12 -04:00
directories, holding the most recent **_Release_** and **_Debug_** builds, respectively.
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
A separate `Latest` directory links to the most recent build, regardless of whether it was a **_Release_**
or **_Debug_** build. Effectively, the `Package/Latest` directory points to whichever of the `Package/Release`
2017-11-17 11:14:29 -05:00
or `Package/Debug` directories was most recently updated.
2023-12-18 11:00:35 -05:00
With this packaging structure, you can follow the [instructions below ](#using ) to link your application
to the **MoltenVK** libraries and frameworks in the `Package/Latest` directory, to provide the flexibility
2019-02-18 22:19:37 +00:00
to test your app with either a **_Debug_** build, or a higher-performance **_Release_** build.
2017-11-17 11:14:29 -05:00
2024-01-25 10:42:26 -05:00
< a name = "command_line_build" > < / a >
2018-03-30 13:03:37 -04:00
### Building from the Command Line
If you prefer to build **MoltenVK** from the command line, or to include the activity in a larger build script,
2023-12-18 11:00:35 -05:00
you can do so by executing a command similar to the following command within the `MoltenVK` repository folder,
and identifying one of the *Xcode Schemes* from the list above. For example, the following command will build
2020-06-23 16:08:00 -04:00
**MoltenVK** in the **_Debug_** configuration for *macOS* only:
2018-03-30 13:03:37 -04:00
2020-06-23 16:08:00 -04:00
xcodebuild build -quiet -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package (macOS only)" -configuration "Debug"
2018-03-30 13:03:37 -04:00
2023-12-18 11:00:35 -05:00
Alternately, you can use the basic `Makefile` in the `MoltenVK` repository folder to build **MoltenVK**
2020-06-23 16:08:00 -04:00
from the command line. The following `make` targets are provided:
2018-10-30 23:16:12 -04:00
make
make all
make macos
make ios
2020-09-01 14:39:46 -04:00
make iossim
2020-11-30 18:52:34 -05:00
make maccat
2020-06-19 15:05:43 -04:00
make tvos
2020-09-01 14:39:46 -04:00
make tvossim
2020-06-23 16:08:00 -04:00
make all-debug
make macos-debug
make ios-debug
2020-09-01 14:39:46 -04:00
make iossim-debug
2020-11-30 18:52:34 -05:00
make maccat-debug
2020-06-23 16:08:00 -04:00
make tvos-debug
2020-09-01 14:39:46 -04:00
make tvossim-debug
2020-06-23 16:08:00 -04:00
2018-10-30 23:16:12 -04:00
make clean
2019-03-22 19:36:21 -04:00
make install
2018-10-30 23:16:12 -04:00
2020-09-01 14:39:46 -04:00
- Running `make` repeatedly with different targets will accumulate binaries for these different targets.
2023-12-02 19:20:31 -05:00
- The `all` target executes all platform targets.
2020-06-23 16:08:00 -04:00
- 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.
2023-12-18 11:00:35 -05:00
- The `install` target will copy the most recently built `MoltenVK.xcframework` into the
`/Library/Frameworks` folder of your computer. Since `/Library/Frameworks` is protected,
2020-06-23 16:08:00 -04:00
you will generally need to run it as `sudo make install` and enter your password.
2020-09-01 14:39:46 -04:00
The `install` target just installs the built framework, it does not first build the framework.
2020-06-23 16:08:00 -04:00
You will first need to at least run `make macos` first.
2019-03-22 19:36:21 -04:00
2023-12-18 11:00:35 -05:00
The `make` targets all require that *Xcode* is installed on your system.
2018-10-30 23:16:12 -04:00
2023-12-18 11:00:35 -05:00
Building from the command line creates the same `Package` folder structure described above when
2020-04-02 21:11:14 -04:00
building from within *Xcode* .
2018-03-30 13:03:37 -04:00
2023-12-18 11:00:35 -05:00
When building from the command line, you can set any of the build settings documented
in the `MoltenVK_Configuration_Parameters.md` file, by passing them in the command line,
2022-10-09 16:32:26 -04:00
as in the following examples:
make MVK_CONFIG_LOG_LEVEL=0
or
2023-05-01 17:30:21 -04:00
make macos MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS=2
2022-10-09 16:32:26 -04:00
...etc.
2017-11-17 11:14:29 -05:00
2024-01-25 10:42:26 -05:00
< a name = "hiding_vulkan_symbols" > < / a >
### Hiding _Vulkan_ API Symbols
You can optionally build **MoltenVK** with the _Vulkan_ API static call symbols (`vk*` ) hidden, to avoid
2024-01-10 17:16:33 -05:00
library linking conflicts when statically bound to a _Vulkan_ loader that also exports identical symbols.
2021-11-17 18:22:33 -05:00
2024-01-10 17:16:33 -05:00
To do so, when building **MoltenVK** , set the build setting `MVK_HIDE_VULKAN_SYMBOLS=1` .
2024-01-25 10:42:26 -05:00
This build setting can be set in the `MoltenVK.xcodeproj` *Xcode* project, or it can be
included in any of the `make` command-line build commands [mentioned above ](#command_line_build ).
2021-11-17 18:22:33 -05:00
2024-01-10 17:16:33 -05:00
With `MVK_HIDE_VULKAN_SYMBOLS=1` , the _Vulkan_ `vkGetInstanceProcAddr()` call remains
statically bound, to provide the application with the ability to retrieve the remaining
_Vulkan_ API calls as function pointers.
2019-05-28 17:19:43 -04:00
2024-01-25 10:42:26 -05:00
< a name = "metal_private_api" > < / a >
### Accessing _Metal_ Private API calls
2023-12-29 04:42:17 -07:00
You can optionally build **MoltenVK** with access to private _Metal_ API calls, also known
as "Service Provider Interfaces" (SPIs). Doing so will allow **MoltenVK** to extend its
functionality by using certain private _Metal_ API calls, but it will also disqualify the
app from being distributed via _Apple_ App Stores.
2024-01-25 10:42:26 -05:00
To do so, when building **MoltenVK** , set the build setting `MVK_USE_METAL_PRIVATE_API=1` .
This build setting can be set in the `MoltenVK.xcodeproj` *Xcode* project, or it can be
included in any of the `make` command-line build commands [mentioned above ](#command_line_build ).
Functionality added with `MVK_USE_METAL_PRIVATE_API` enabled includes:
- `VkPhysicalDeviceFeatures::wideLines`
2018-10-04 16:18:05 -05:00
- `VkPhysicalDeviceFeatures::logicOp`
2018-10-31 12:24:36 -05:00
- `VkPhysicalDevicePortabilitySubsetFeaturesKHR::samplerMipLodBias`
2024-01-25 10:42:26 -05:00
2018-03-06 14:07:06 -05:00
< a name = "demos" > < / a >
2021-03-03 16:43:11 -05:00
Running **MoltenVK** Demo Applications
--------------------------------------
2018-03-06 14:07:06 -05:00
2023-12-18 11:00:35 -05:00
Once you have compiled and built the **MoltenVK** runtime distribution package from this **MoltenVK** repository,
as described in the [Building **MoltenVK** ](#building ) section, you can explore how **MoltenVK** provides *Vulkan*
2021-03-03 16:43:11 -05:00
support on *macOS* , *iOS* , and *tvOS* by investigating and running the demo application that is included in **MoltenVK** .
2018-03-06 14:07:06 -05:00
2021-03-03 16:43:11 -05:00
The **MoltenVK** _Cube_ demo app is located in the `Demos` folder. The demo app is available as an *Xcode* project.
To review and run the included demo app, open the `Demos/Demos.xcworkspace` workspace in *Xcode* .
2018-03-06 14:07:06 -05:00
2023-12-18 11:00:35 -05:00
Please read the [`Demos/README.md` ](Demos/README.md ) document for a description and instructions for running the
2021-03-03 16:43:11 -05:00
included *Cube* demo app, and for external links to more sophisticated demo applications that can be run on **MoltenVK** .
2018-03-06 14:07:06 -05:00
2017-11-17 11:14:29 -05:00
< a name = "using" > < / a >
Using **MoltenVK** in Your Application
--------------------------------------
2023-12-18 11:00:35 -05:00
Once you have compiled and built the **MoltenVK** runtime distribution package from this **MoltenVK** repository,
as described in the [Building **MoltenVK** ](#building ) section, follow the instructions in the Installation
section of the [`Docs/MoltenVK_Runtime_UserGuide.md` ](Docs/MoltenVK_Runtime_UserGuide.md#install ) document
2019-02-18 22:19:37 +00:00
in the `Docs` directory, to link the **MoltenVK** libraries and frameworks to your application.
2017-11-17 11:14:29 -05:00
2023-12-18 11:00:35 -05:00
The runtime distribution package in the `Package/Latest` directory is a stand-alone package, and you can copy
2017-11-17 11:14:29 -05:00
the contents of that directory out of this **MoltenVK** repository into your own application building environment.
2018-03-06 16:51:05 -05:00
< a name = "compliance" > < / a >
**MoltenVK** and *Vulkan* Compliance
------------------------------------
2023-12-18 11:00:35 -05:00
**MoltenVK** is designed to be an implementation of a *Vulkan 1.2* subset that runs on *macOS* , *iOS* ,
2023-07-11 14:22:59 -04:00
*tvOS*, and *visionOS* platforms by mapping *Vulkan* capability to native *Metal* capability.
2018-03-06 16:51:05 -05:00
2023-12-18 11:00:35 -05:00
The fundamental design and development goal of **MoltenVK** is to provide this capability in a way that
2022-09-26 11:25:49 -04:00
is both maximally compliant with the *Vulkan 1.2* specification, and maximally performant.
2018-03-06 16:51:05 -05:00
2023-12-18 11:00:35 -05:00
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*
2023-07-11 14:22:59 -04:00
compliance may fall into one of the following categories:
2018-03-06 16:51:05 -05:00
2020-06-23 23:06:08 -04:00
- Direct mapping between *Vulkan* capabilities and *Metal* capabilities. Within **MoltenVK** , the vast
2023-12-18 11:00:35 -05:00
majority of *Vulkan* capability is the result of this type of direct mapping.
2020-06-23 23:06:08 -04:00
- Synthesized compliance through alternate implementation. A small amount of capability is provided using
2018-03-06 16:51:05 -05:00
this mechanism, such as via an extra render or compute shader stage.
- Non-compliance. This appears where the capabilities of *Vulkan* and *Metal* are sufficiently different, that
2023-12-18 11:00:35 -05:00
there is no practical, or reasonably performant, mechanism to implement a *Vulkan* capability in *Metal* .
Because of design differences between *Vulkan* and *Metal* , a very small amount of capability falls into this
category, and at present **MoltenVK** is **_not_** fully compliant with the *Vulkan* specification. A list of
known limitations is documented in the [`MoltenVK_Runtime_UserGuide.md` ](Docs/MoltenVK_Runtime_UserGuide.md#limitations )
2018-03-06 16:51:05 -05:00
document in the `Docs` directory.
2023-12-18 11:00:35 -05:00
The **MoltenVK** development team welcomes you to [post Issues ](https://github.com/KhronosGroup/MoltenVK/issues )
of non-compliance, and engage in discussions about how compliance can be improved, and non-compliant features can
2018-03-06 16:51:05 -05:00
be implemented or worked around.
2023-12-18 11:00:35 -05:00
**MoltenVK** is a key component of the
[*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* , *tvOS* , and *visionOS* , where a native *Vulkan* driver is not available.
2018-03-06 16:51:05 -05:00
2021-02-12 10:46:57 -05:00
< a name = "support" > < / a >
2019-02-08 19:36:52 -05:00
2021-02-12 10:46:57 -05:00
Getting Support
2019-02-08 19:36:52 -05:00
----------------
2023-12-18 11:00:35 -05:00
- If you have a question about using **MoltenVK** , you can ask it in
[*MoltenVK Discussions* ](https://github.com/KhronosGroup/MoltenVK/discussions ).
2021-02-12 10:46:57 -05:00
This forum is monitored by **MoltenVK** contributors and users.
2023-12-18 11:00:35 -05:00
- If you encounter an issue with the behavior of **MoltenVK** , or want to request an enhancement,
2021-02-12 10:46:57 -05:00
you can report it in the [*MoltenVK Issues List* ](https://github.com/KhronosGroup/MoltenVK/issues ).
2019-09-25 15:41:40 -05:00
2023-12-18 11:00:35 -05:00
- If you encounter an issue with the *Vulkan SDK* , including the *Validation Layers* , you can report it in the
2019-02-08 19:36:52 -05:00
[*Vulkan SDK Issues List* ](https://vulkan.lunarg.com/issue/home ).
2019-09-25 15:41:40 -05:00
- If you explore **MoltenVK** and determine that it does not meet your requirements at this time, we would appreciate
2023-12-18 11:00:35 -05:00
hearing why that is so, in [*MoltenVK Discussions* ](https://github.com/KhronosGroup/MoltenVK/discussions ).
The goal of **MoltenVK** is to increase the value of *Vulkan* as a true cross-platform ecosystem, by providing
2019-09-25 15:41:40 -05:00
*Vulkan* on *Apple* platforms. Hearing why this is currently not working for you will help us in that goal.
2019-02-08 19:36:52 -05:00
2018-03-06 16:51:05 -05:00
< a name = "contributing" > < / a >
Contributing to **MoltenVK** Development
----------------------------------------
2023-12-18 11:00:35 -05:00
As a public open-source project, **MoltenVK** benefits from code contributions from a wide range of developers,
2018-03-06 16:51:05 -05:00
and we encourage you to get involved and contribute code to this **MoltenVK** repository.
2023-12-18 11:00:35 -05:00
To contribute your code, submit a [Pull Request ](https://github.com/KhronosGroup/MoltenVK/pulls )
to this repository. The first time you do this, you will be asked to agree to the **MoltenVK**
2018-03-06 16:51:05 -05:00
[Contributor License Agreement ](https://cla-assistant.io/KhronosGroup/MoltenVK ).
### Licensing
2023-12-18 11:00:35 -05:00
**MoltenVK** is licensed under the Apache 2.0 license. All new source code files should include a
copyright header at the top, containing your authorship copyright and the Apache 2.0 licensing stub.
2018-03-06 16:51:05 -05:00
You may copy the text from an existing source code file as a template.
The Apache 2.0 license guarantees that code in the **MoltenVK** repository is free of Intellectual Property
2023-12-18 11:00:35 -05:00
encumbrances. In submitting code to this repository, you are agreeing that the code is free of any Intellectual
Property claims.
2018-03-06 16:51:05 -05:00
2020-10-02 12:22:32 -04:00
### *Vulkan* Validation
2023-12-18 11:00:35 -05:00
Despite running on top of *Metal* , **MoltenVK** operates as a *Vulkan* core layer. As such, as per the
error handling guidelines of the [*Vulkan* specification ](https://www.khronos.org/registry/vulkan/specs/1.2/html/vkspec.html#fundamentals-errors ), **MoltenVK** should not perform *Vulkan* validation. When adding functionality
2020-10-02 12:22:32 -04:00
to **MoltenVK** , avoid adding unnecessary validation code.
2023-12-18 11:00:35 -05:00
Validation and error generation **_is_** appropriate within **MoltenVK** in cases where **MoltenVK** deviates
from behavior defined by the *Vulkan* specification. This most commonly occurs when required behavior cannot
2020-10-02 12:22:32 -04:00
be mapped to functionality available within *Metal* . In that situation, it is important to provide feedback to
the application developer to that effect, by performing the necessary validation, and reporting an error.
2023-12-18 11:00:35 -05:00
Currently, there is some excess *Vulkan* validation and error reporting code within **MoltenVK** , added before
this guideline was introduced. You are encouraged to remove such code if you encounter it while performing other
**MoltenVK** development. Do not remove validation and error reporting code that is covering a deviation in
2020-10-02 12:38:30 -04:00
behavior from the *Vulkan* specification.
2020-10-02 12:22:32 -04:00
2019-07-17 18:24:07 -04:00
### Memory Management
2023-12-18 11:00:35 -05:00
*Metal*, and other *Objective-C* objects in *Apple's SDK* frameworks, use reference counting for memory management.
As a contributor to **MoltenVK** , when instantiating *Objective-C* objects, it is important that you do not rely on
the app providing *autorelease pools* to do memory management for you. Because many *Vulkan* games and apps may be
2022-10-18 12:41:13 -04:00
ported from other platforms, they will often not automatically include autorelease pools in their threading models.
2023-12-18 11:00:35 -05:00
As a contributor to **MoltenVK** , avoid the use of the *Metal* `autorelease` method, or any object *Metal* creation
methods that imply internal use of `autorelease` , (eg- `[NSString stringWithFormat: ]` , etc). Instead, favor object
creation methods that return a retained object (eg- `[[NSString alloc] initWithFormat: ]` , etc), and manually track
2022-10-18 12:41:13 -04:00
and release those objects. If you need to use autoreleased objects, wrap your code in an `@autoreleasepool {...}` block.
2019-07-17 18:24:07 -04:00
2018-03-06 16:51:05 -05:00
### Code Formatting
2018-05-24 13:21:31 +08:00
When contributing code, please honour the code formatting style found in existing **MoltenVK** source code.
2018-03-06 16:51:05 -05:00
In future, this will formally be enforced using `clang-format` .