From 1329f3adee456fcdb52c3b2c7617e672c5d72682 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Mon, 30 Nov 2020 18:52:34 -0500 Subject: [PATCH 1/5] Update build scripts to build for Mac Catalyst. --- Makefile | 10 ++++++++++ README.md | 3 +++ fetchDependencies | 32 +++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b2c8406d..e96a870a 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ all: @$(MAKE) macos @$(MAKE) ios @$(MAKE) iossim + @$(MAKE) maccat @$(MAKE) tvos @$(MAKE) tvossim @@ -15,6 +16,7 @@ all-debug: @$(MAKE) macos-debug @$(MAKE) ios-debug @$(MAKE) iossim-debug + @$(MAKE) maccat-debug @$(MAKE) tvos-debug @$(MAKE) tvossim-debug @@ -42,6 +44,14 @@ iossim: iossim-debug: xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" -destination "generic/platform=iOS Simulator" -configuration "Debug" +.PHONY: maccat +maccat: + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" -destination "generic/platform=macOS,variant=Mac Catalyst" + +.PHONY: maccat-debug +maccat-debug: + xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (iOS only)" -destination "generic/platform=macOS,variant=Mac Catalyst" -configuration "Debug" + .PHONY: tvos tvos: xcodebuild build -quiet -project "$(XC_PROJ)" -scheme "$(XC_SCHEME) (tvOS only)" diff --git a/README.md b/README.md index 098450d8..b613e62f 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ for which to build the external libraries. The platform choices include: --macos --ios --iossim + --maccat --tvos --tvossim @@ -205,6 +206,7 @@ from the command line. The following `make` targets are provided: make macos make ios make iossim + make maccat make tvos make tvossim @@ -212,6 +214,7 @@ from the command line. The following `make` targets are provided: make macos-debug make ios-debug make iossim-debug + make maccat-debug make tvos-debug make tvossim-debug diff --git a/fetchDependencies b/fetchDependencies index 0f160585..b4dc38eb 100755 --- a/fetchDependencies +++ b/fetchDependencies @@ -17,6 +17,9 @@ # --iossim # Build the external libraries for the iOS Simulator platform. # +# --maccat +# Build the external libraries for the Mac Catalyst platform. +# # --tvos # Build the external libraries for the tvOS platform. # @@ -24,7 +27,7 @@ # Build the external libraries for the tvOS Simulator platform. # # --all -# Equivalent to specifying [--macos --ios --iossim --tvos --tvossim]. +# Equivalent to specifying [--macos --ios --iossim --maccat --tvos --tvossim]. # Results in one XCFramework for each external library, each containing # binaries for all supported platforms. # @@ -88,6 +91,7 @@ set -e BLD_NONE="" BLD_IOS="" BLD_IOS_SIM="" +BLD_MAC_CAT="" BLD_TVOS="" BLD_TVOS_SIM="" BLD_MACOS="" @@ -113,6 +117,10 @@ while (( "$#" )); do BLD_IOS_SIM="Y" shift 1 ;; + --maccat) + BLD_MAC_CAT="Y" + shift 1 + ;; --tvos) BLD_TVOS="Y" shift 1 @@ -128,6 +136,7 @@ while (( "$#" )); do --all) BLD_IOS="Y" BLD_IOS_SIM="Y" + BLD_MAC_CAT="Y" BLD_TVOS="Y" BLD_TVOS_SIM="Y" BLD_MACOS="Y" @@ -388,22 +397,27 @@ echo Please be patient on first build # Build an Xcode scheme for an OS and platform # 1 - OS -# 2 - platform +# 2 - Platform +# 3 - Destination (Optional. Defaults to same as platform) function build_impl() { BLD_SPECIFIED="Y" XC_OS=${1} XC_PLTFM=${2} + if [ "${3}" != "" ]; then + XC_DEST=${3}; + else + XC_DEST=${XC_PLTFM}; + fi XC_SCHEME="${EXT_DEPS}-${XC_OS}" XC_LCL_DD_PATH="${XC_DD_PATH}/Intermediates/${XC_PLTFM}" - XC_DEST="generic/platform=${XC_PLTFM}" - echo Building external libraries for ${XC_PLTFM} + echo Building external libraries for platform ${XC_PLTFM} and destination ${XC_DEST} xcodebuild \ -project "${XC_PROJ}" \ -scheme "${XC_SCHEME}" \ - -destination "${XC_DEST}" \ + -destination "generic/platform=${XC_DEST}" \ -configuration "${XC_CONFIG}" \ -enableAddressSanitizer "${XC_USE_ASAN}" \ -enableThreadSanitizer "${XC_USE_TSAN}" \ @@ -420,9 +434,9 @@ function build_impl() { # 2 - platform function build() { if [ "$XC_USE_BCKGND" != "" ]; then - build_impl "${1}" "${2}" & + build_impl "${1}" "${2}" "${3}" & else - build_impl "${1}" "${2}" + build_impl "${1}" "${2}" "${3}" fi } @@ -449,6 +463,10 @@ if [ "$BLD_IOS_SIM" != "" ]; then build "iOS" "iOS Simulator" fi +if [ "$BLD_MAC_CAT" != "" ]; then + build "iOS" "Mac Catalyst" "macOS,variant=Mac Catalyst" +fi + if [ "$BLD_TVOS" != "" ]; then build "tvOS" "tvOS" fi From 1ec58c9a92c342371cfe3c008ebaa2cd14399486 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Tue, 1 Dec 2020 19:26:15 -0500 Subject: [PATCH 2/5] Support building for Mac Catalyst on macOS 11.0+. Define MVK_MACCAT build macro and use it to conditionally compile code to align with build features and capabilities of Mac Catalyst platform on macOS 11.0+. Treat Mac Catalyst as minor variation of macOS 11.0. Update documentation. Currently only support Mac Catalyst on macOS 11.0+, to avoid complexities of deselecting iOS features and capabilities for Mac Catalyst on previous macOS versions. Mac Catalyst (and Simulators) require use of XCFrameworks. Currently unable to generate a dylib for Mac Catalyst. --- Common/MVKCommonEnvironment.h | 9 +++++++-- Common/MVKOSExtensions.h | 11 ++++++---- .../API-Samples/API-Samples.entitlements | 10 ++++++++++ .../API-Samples.xcodeproj/project.pbxproj | 12 +++++++++-- .../Cube/Cube.entitlements | 10 ++++++++++ .../Cube/Cube.xcodeproj/project.pbxproj | 12 +++++++++-- Demos/README.md | 8 +++++--- Docs/MoltenVK_Runtime_UserGuide.md | 5 +++-- Docs/Whats_New.md | 3 ++- MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm | 2 ++ MoltenVK/MoltenVK/GPUObjects/MVKDevice.h | 10 ++++++++++ MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm | 16 ++++++++++++++- MoltenVK/MoltenVK/GPUObjects/MVKImage.mm | 7 ++++--- MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm | 6 ++++++ .../MoltenVK/GPUObjects/MVKPixelFormats.mm | 20 +++++++++++++++---- MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm | 6 +----- MoltenVK/MoltenVK/Layers/MVKExtensions.mm | 2 +- MoltenVK/MoltenVK/OS/MVKGPUCapture.mm | 4 ++++ README.md | 3 ++- Scripts/create_dylib_ios.sh | 5 +++++ Scripts/package_moltenvk.sh | 3 +++ 21 files changed, 133 insertions(+), 31 deletions(-) create mode 100644 Demos/LunarG-VulkanSamples/API-Samples/API-Samples.entitlements create mode 100644 Demos/LunarG-VulkanSamples/Cube/Cube.entitlements diff --git a/Common/MVKCommonEnvironment.h b/Common/MVKCommonEnvironment.h index 8087c9fe..6874e7dd 100644 --- a/Common/MVKCommonEnvironment.h +++ b/Common/MVKCommonEnvironment.h @@ -44,12 +44,17 @@ extern "C" { /** Building for macOS. */ #ifndef MVK_MACOS -# define MVK_MACOS TARGET_OS_OSX +# define MVK_MACOS (TARGET_OS_OSX || TARGET_OS_MACCATALYST) #endif /** Building for iOS. */ #ifndef MVK_IOS -# define MVK_IOS TARGET_OS_IOS +# define MVK_IOS (TARGET_OS_IOS && !TARGET_OS_MACCATALYST) +#endif + +/** Building for iOS on Mac Catalyst. */ +#ifndef MVK_MACCAT +# define MVK_MACCAT TARGET_OS_MACCATALYST #endif /** Building for tvOS. */ diff --git a/Common/MVKOSExtensions.h b/Common/MVKOSExtensions.h index a8dade92..b3ad369f 100644 --- a/Common/MVKOSExtensions.h +++ b/Common/MVKOSExtensions.h @@ -48,16 +48,19 @@ inline bool mvkOSVersionIsAtLeast(MVKOSVersion minVer) { return mvkOSVersion() > /** * Returns whether the operating system version is at least the appropriate min version. - * The constant kMVKOSVersionUnsupported can be used for either value to cause the test + * The constant kMVKOSVersionUnsupported can be used for any value to cause the test * to always fail on that OS, which is useful for indidicating functionalty guarded by * this test is not supported on that OS. */ -inline bool mvkOSVersionIsAtLeast(MVKOSVersion macOSMinVer, MVKOSVersion iOSMinVer) { +inline bool mvkOSVersionIsAtLeast(MVKOSVersion iOSMinVer, MVKOSVersion macOSMinVer, MVKOSVersion macCatMinVer) { +#if MVK_IOS_OR_TVOS + return mvkOSVersionIsAtLeast(iOSMinVer); +#endif #if MVK_MACOS return mvkOSVersionIsAtLeast(macOSMinVer); #endif -#if MVK_IOS_OR_TVOS - return mvkOSVersionIsAtLeast(iOSMinVer); +#if MVK_MACCAT + return mvkOSVersionIsAtLeast(macCatMinVer); #endif } diff --git a/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.entitlements b/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.entitlements new file mode 100644 index 00000000..ee95ab7e --- /dev/null +++ b/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.xcodeproj/project.pbxproj b/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.xcodeproj/project.pbxproj index 20d05057..6d30115a 100644 --- a/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.xcodeproj/project.pbxproj +++ b/Demos/LunarG-VulkanSamples/API-Samples/API-Samples.xcodeproj/project.pbxproj @@ -110,6 +110,7 @@ A9B67B881C3AAEA200373FFD /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; A9B67B8A1C3AAEA200373FFD /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; A9B67B8B1C3AAEA200373FFD /* macOS.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = macOS.xcassets; sourceTree = ""; }; + A9B735072576E0D900455E2A /* API-Samples.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "API-Samples.entitlements"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -144,6 +145,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + A9B735072576E0D900455E2A /* API-Samples.entitlements */, A92F37071C7E1B2B008F8BC9 /* Samples.h */, A99B2F0D24436190001117F7 /* generateSPIRVShaders */, A95C03971C98FBED00CC653D /* API-Samples */, @@ -630,6 +632,7 @@ 1D6058940D05DD3E006BFB54 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = "API-Samples.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; @@ -642,17 +645,20 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = NO; INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; MARKETING_VERSION = 1; PRODUCT_BUNDLE_IDENTIFIER = "com.moltenvk.API-Samples"; PRODUCT_NAME = "API-Samples"; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; 1D6058950D05DD3E006BFB54 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = "API-Samples.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; @@ -661,11 +667,13 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = NO; INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; MARKETING_VERSION = 1; PRODUCT_BUNDLE_IDENTIFIER = "com.moltenvk.API-Samples"; PRODUCT_NAME = "API-Samples"; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; diff --git a/Demos/LunarG-VulkanSamples/Cube/Cube.entitlements b/Demos/LunarG-VulkanSamples/Cube/Cube.entitlements new file mode 100644 index 00000000..ee95ab7e --- /dev/null +++ b/Demos/LunarG-VulkanSamples/Cube/Cube.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/Demos/LunarG-VulkanSamples/Cube/Cube.xcodeproj/project.pbxproj b/Demos/LunarG-VulkanSamples/Cube/Cube.xcodeproj/project.pbxproj index ebcc7be3..5cbadae4 100644 --- a/Demos/LunarG-VulkanSamples/Cube/Cube.xcodeproj/project.pbxproj +++ b/Demos/LunarG-VulkanSamples/Cube/Cube.xcodeproj/project.pbxproj @@ -61,6 +61,7 @@ A9B67B881C3AAEA200373FFD /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; A9B67B8A1C3AAEA200373FFD /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; A9B67B8B1C3AAEA200373FFD /* macOS.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = macOS.xcassets; sourceTree = ""; }; + A9B734FE2576E04000455E2A /* Cube.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Cube.entitlements; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -104,6 +105,7 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( + A9B734FE2576E04000455E2A /* Cube.entitlements */, A904B52C1C9A08C80008C013 /* cube */, A9B67B6A1C3AAE9800373FFD /* iOS */, A9B67B811C3AAEA200373FFD /* macOS */, @@ -411,6 +413,7 @@ A9B53B411C3AC15200ABC6F6 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = Cube.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; @@ -421,16 +424,19 @@ ); INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; MARKETING_VERSION = 1; PRODUCT_NAME = Cube; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; A9B53B421C3AC15200ABC6F6 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = Cube.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; @@ -441,10 +447,12 @@ ); INFOPLIST_FILE = "$(SRCROOT)/iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; MARKETING_VERSION = 1; PRODUCT_NAME = Cube; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; diff --git a/Demos/README.md b/Demos/README.md index 0334bb33..61108f58 100644 --- a/Demos/README.md +++ b/Demos/README.md @@ -56,8 +56,9 @@ In addition to devices, this demo will also run on the `iOS Simulator` or `tvOS The *macOS* version of this demo includes a sizable window, and represents an example of how to detect, within your *Vulkan* code, when a window has been resized, and to modify the *Vulkan* swapchain accordingly. -The `Cube` demo is a simple example of installing **MoltenVK** as an `XCFramework` -that is statically linked to the application. +The `Cube` demo is a simple example of installing **MoltenVK** as an `XCFramework` that is +statically linked to the application. It supports all platforms, including _Mac Catalyst_, _iOS +Simulator_ and _tvOS Simulator_, and all architectures including _Apple Silicon_. @@ -121,7 +122,8 @@ To see descriptions and screenshots of each of the demos, open [this summary document](LunarG-VulkanSamples/VulkanSamples/samples_index.html#AdditionalVulkan). The `API-Samples` demo is a simple example of installing **MoltenVK** as an `XCFramework` that -is statically linked to the application. +is statically linked to the application. It supports all platforms, including _Mac Catalyst_, _iOS +Simulator_ and _tvOS Simulator_, and all architectures including _Apple Silicon_. diff --git a/Docs/MoltenVK_Runtime_UserGuide.md b/Docs/MoltenVK_Runtime_UserGuide.md index 49881456..4ce56fd2 100644 --- a/Docs/MoltenVK_Runtime_UserGuide.md +++ b/Docs/MoltenVK_Runtime_UserGuide.md @@ -58,7 +58,8 @@ About **MoltenVK** 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*, and *tvOS*. +and applications, and to run them across many platforms, including *macOS*, *iOS*, *tvOS*, *Simulators*, +and *Mac Catalyst* on *macOS 11.0+*. *Metal* uses a different shading language, the *Metal Shading Language (MSL)*, than *Vulkan*, which uses *SPIR-V*. **MoltenVK** automatically converts your *SPIR-V* shaders @@ -84,7 +85,7 @@ as a universal `XCFramework` or as a *dynamic library* (`.dylib`). Distributing a dynamic library via the *iOS App Store* or *tvOS App Store* can require specialized bundling. If you are unsure about which linking and deployment option you need, or on *iOS* or *tvOS*, unless you have specific needs for dynamic libraries, follow the steps for linking **MoltenVK** -as an `XCFramework`, as it is the simpler option. +as an `XCFramework`, as it is the simpler option, and encompasses the largest set of supported platforms. The demo apps, found in the `Demos.xcworkspace`, located in the `Demos` folder, demonstrate both of the installation techniques discussed above: diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index 330df3bf..8868309e 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -16,7 +16,7 @@ For best results, use a Markdown reader.* MoltenVK 1.1.1 -------------- -Released TBD +Released 2010/12/07 - Add support for extensions: - `VK_KHR_timeline_semaphore` @@ -26,6 +26,7 @@ Released TBD - `VK_EXT_texture_compression_astc_hdr` - `VK_AMD_shader_image_load_store` (macOS) - `VK_IMG_format_pvrtc` (macOS) +- Support the *Mac Catalyst* platform for *iOS* apps on *macOS 11.0+*, under both `x86_64` and `arm64` architectures. - Use `VK_KHR_image_format_list` to disable `MTLTextureUsagePixelFormatView` if only swizzles or `sRGB` conversion will be used for image views, improving performance on *iOS* by allowing Metal to use lossless texture compression. diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm b/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm index 00029a63..229e9f8c 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdPipeline.mm @@ -107,7 +107,9 @@ void MVKCmdPipelineBarrier::encode(MVKCommandEncoder* cmdEncoder) { beforeStages: dstStages]; } } else { +#if !MVK_MACCAT if (coversTextures()) { [cmdEncoder->_mtlRenderEncoder textureBarrier]; } +#endif } #endif diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h index 80261195..fc6a9fc4 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h @@ -909,3 +909,13 @@ protected: /** Returns the registry ID of the specified device, or zero if the device does not have a registry ID. */ uint64_t mvkGetRegistryID(id mtlDevice); + +/** Redefinitions because Mac Catalyst doesn't support feature sets. */ +#if MVK_MACCAT +#define MTLFeatureSet_macOS_GPUFamily1_v1 MTLGPUFamilyMacCatalyst1 +#define MTLFeatureSet_macOS_GPUFamily1_v2 MTLGPUFamilyMacCatalyst1 +#define MTLFeatureSet_macOS_GPUFamily1_v3 MTLGPUFamilyMacCatalyst1 +#define MTLFeatureSet_macOS_GPUFamily1_v4 MTLGPUFamilyMacCatalyst1 + +#define MTLFeatureSet_macOS_GPUFamily2_v1 MTLGPUFamilyMacCatalyst2 +#endif diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 70535678..02cf61a2 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -50,7 +50,13 @@ using namespace std; # define MVKViewClass NSView #endif +// Mac Catalyst does not support feature sets, so we redefine them to GPU families in MVKDevice.h. +#if MVK_MACCAT +#define supportsMTLFeatureSet(MFS) [_mtlDevice supportsFamily: MTLFeatureSet_ ##MFS] +#else #define supportsMTLFeatureSet(MFS) [_mtlDevice supportsFeatureSet: MTLFeatureSet_ ##MFS] +#endif + #define supportsMTLGPUFamily(GPUF) ([_mtlDevice respondsToSelector: @selector(supportsFamily:)] && [_mtlDevice supportsFamily: MTLGPUFamily ##GPUF]) @@ -324,7 +330,7 @@ void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) { if (_features.tessellationShader) { subgroupProps->supportedStages |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; } - if (mvkOSVersionIsAtLeast(10.15, 13.0)) { + if (mvkOSVersionIsAtLeast(13.0, 10.15, 14.0)) { subgroupProps->supportedStages |= VK_SHADER_STAGE_FRAGMENT_BIT; } subgroupProps->supportedOperations = VK_SUBGROUP_FEATURE_BASIC_BIT; @@ -2684,8 +2690,16 @@ void MVKPhysicalDevice::logGPUInfo() { if (supportsMTLFeatureSet(macOS_GPUFamily1_v2)) { logMsg += "\n\t\tmacOS GPU Family 1 v2"; } if (supportsMTLFeatureSet(macOS_GPUFamily1_v1)) { logMsg += "\n\t\tmacOS GPU Family 1 v1"; } +#if !MVK_MACCAT if (supportsMTLFeatureSet(macOS_ReadWriteTextureTier2)) { logMsg += "\n\t\tmacOS Read-Write Texture Tier 2"; } +#endif +#endif +#if MVK_MACCAT + if ([_mtlDevice respondsToSelector: @selector(readWriteTextureSupport)] && + _mtlDevice.readWriteTextureSupport == MTLReadWriteTextureTier2) { + logMsg += "\n\t\tmacOS Read-Write Texture Tier 2"; + } #endif NSUUID* nsUUID = [[NSUUID alloc] initWithUUIDBytes: _properties.pipelineCacheUUID]; // temp retain diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm index 63fe437c..35bd99e6 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm @@ -114,7 +114,8 @@ MTLTextureDescriptor* MVKImagePlane::newMTLTextureDescriptor() { // Metal before 3.0 doesn't support 3D compressed textures, so we'll decompress // the texture ourselves. This, then, is the *uncompressed* format. - MTLPixelFormat mtlPixFmt = (MVK_MACOS && _image->_is3DCompressed) ? MTLPixelFormatBGRA8Unorm : _mtlPixFmt; + bool shouldSubFmt = MVK_MACOS && _image->_is3DCompressed; + MTLPixelFormat mtlPixFmt = shouldSubFmt ? MTLPixelFormatBGRA8Unorm : _mtlPixFmt; VkExtent3D extent = _image->getExtent3D(_planeIndex, 0); MTLTextureDescriptor* mtlTexDesc = [MTLTextureDescriptor new]; // retained @@ -847,7 +848,8 @@ MTLTextureUsage MVKImage::getMTLTextureUsage(MTLPixelFormat mtlPixFmt) { // Metal before 3.0 doesn't support 3D compressed textures, so we'll // decompress the texture ourselves, and we need to be able to write to it. - if (MVK_MACOS && _is3DCompressed) { + bool makeWritable = MVK_MACOS && _is3DCompressed; + if (makeWritable) { mvkEnableFlags(mtlUsage, MTLTextureUsageShaderWrite); } @@ -1014,7 +1016,6 @@ void MVKImage::validateConfig(const VkImageCreateInfo* pCreateInfo, bool isAttac MVKPixelFormats* pixFmts = getPixelFormats(); bool is2D = (getImageType() == VK_IMAGE_TYPE_2D); - bool isCompressed = pixFmts->getFormatType(pCreateInfo->format) == kMVKFormatCompressed; bool isChromaSubsampled = pixFmts->getChromaSubsamplingPlaneCount(pCreateInfo->format) > 0; if (isChromaSubsampled && !is2D) { diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm index 76193070..1c09eafd 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm @@ -364,6 +364,12 @@ MVKInstance::MVKInstance(const VkInstanceCreateInfo* pCreateInfo) : _enabledExte setConfigurationResult(reportError(VK_ERROR_INCOMPATIBLE_DRIVER, "Vulkan is not supported on this device. MoltenVK requires Metal, which is not available on this device.")); } + if (MVK_MACCAT && !mvkOSVersionIsAtLeast(11.0)) { + setConfigurationResult(reportError(VK_ERROR_INCOMPATIBLE_DRIVER, "To support Mac Catalyst, MoltenVK requires macOS 11.0 or above.")); + } + MVKLogInfo("Running Mac Catalyst %.4f.", mvkOSVersion()); + + MVKLogInfo("Created VkInstance with the following %d Vulkan extensions enabled:%s", _enabledExtensions.getEnabledCount(), _enabledExtensions.enabledNamesString("\n\t\t", true).c_str()); diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm index 9ad1cf66..9bb28397 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm @@ -1434,9 +1434,23 @@ void MVKPixelFormats::modifyMTLFormatCapabilities() { } +// Mac Catalyst does not support feature sets, so we redefine them to GPU families in MVKDevice.h. +#if MVK_MACCAT +#define addFeatSetMTLPixFmtCaps(FEAT_SET, MTL_FMT, CAPS) \ + addMTLPixelFormatCapabilities(mtlDevice, MTLFeatureSet_ ##FEAT_SET, 10.16, MTLPixelFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) + +#define addFeatSetMTLVtxFmtCaps(FEAT_SET, MTL_FMT, CAPS) \ + addMTLVertexFormatCapabilities(mtlDevice, MTLFeatureSet_ ##FEAT_SET, 10.16, MTLVertexFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) + +#else #define addFeatSetMTLPixFmtCaps(FEAT_SET, MTL_FMT, CAPS) \ addMTLPixelFormatCapabilities(mtlDevice, MTLFeatureSet_ ##FEAT_SET, MTLPixelFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) +#define addFeatSetMTLVtxFmtCaps(FEAT_SET, MTL_FMT, CAPS) \ + addMTLVertexFormatCapabilities(mtlDevice, MTLFeatureSet_ ##FEAT_SET, MTLVertexFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) + +#endif + #define addGPUOSMTLPixFmtCaps(GPU_FAM, OS_VER, MTL_FMT, CAPS) \ addMTLPixelFormatCapabilities(mtlDevice, MTLGPUFamily ##GPU_FAM, OS_VER, MTLPixelFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) @@ -1446,9 +1460,6 @@ void MVKPixelFormats::modifyMTLFormatCapabilities() { #define disableMTLPixFmtCaps(MTL_FMT, CAPS) \ disableMTLPixelFormatCapabilities(MTLPixelFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) -#define addFeatSetMTLVtxFmtCaps(FEAT_SET, MTL_FMT, CAPS) \ - addMTLVertexFormatCapabilities(mtlDevice, MTLFeatureSet_ ##FEAT_SET, MTLVertexFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) - #define addGPUOSMTLVtxFmtCaps(GPU_FAM, OS_VER, MTL_FMT, CAPS) \ addMTLVertexFormatCapabilities(mtlDevice, MTLGPUFamily ##GPU_FAM, OS_VER, MTLVertexFormat ##MTL_FMT, kMVKMTLFmtCaps ##CAPS) @@ -2039,7 +2050,8 @@ void MVKPixelFormats::setFormatProperties(MVKVkFormatDesc& vkDesc) { // XXX We really want to use the device's Metal features instead of duplicating the // logic from MVKPhysicalDevice, but those may not have been initialized yet. #if MVK_MACOS - (isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || ![mtlDev supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily2_v1])) + (isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || !([mtlDev supportsFamily: MTLGPUFamilyMac2] || + [mtlDev supportsFamily: MTLGPUFamilyMacCatalyst2]))) #endif #if MVK_IOS (isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || ![mtlDev supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1])) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm b/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm index 84c49979..3db55988 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm @@ -327,15 +327,11 @@ void MVKRenderSubpass::populateMTLRenderPassDescriptor(MTLRenderPassDescriptor* mtlTexDesc.textureType = MTLTextureType2DMultisample; mtlTexDesc.sampleCount = sampleCount; } -#if MVK_IOS - if ([_renderPass->getMTLDevice() supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v3]) { + if (mvkOSVersionIsAtLeast(10.0, 11.0, 14.0)) { mtlTexDesc.storageMode = MTLStorageModeMemoryless; } else { mtlTexDesc.storageMode = MTLStorageModePrivate; } -#else - mtlTexDesc.storageMode = MTLStorageModePrivate; -#endif mtlTexDesc.usage = MTLTextureUsageRenderTarget; _mtlDummyTex = [_renderPass->getMTLDevice() newTextureWithDescriptor: mtlTexDesc]; // not retained [_mtlDummyTex setPurgeableState: MTLPurgeableStateVolatile]; diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.mm b/MoltenVK/MoltenVK/Layers/MVKExtensions.mm index 0dc34002..ecf06ab3 100644 --- a/MoltenVK/MoltenVK/Layers/MVKExtensions.mm +++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.mm @@ -49,7 +49,7 @@ static bool mvkIsSupportedOnPlatform(VkExtensionProperties* pProperties) { #define MVK_DISABLED_EXTENSION(EXT) \ if (pProperties == &kVkExtProps_##EXT) { return false; } #define MVK_EXTENSION_MIN_OS(EXT, MAC, IOS) \ - if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(MAC, IOS); } + if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(IOS, MAC, 14.0); } #if MVK_MACOS MVK_DISABLED_EXTENSION(MVK_IOS_SURFACE) diff --git a/MoltenVK/MoltenVK/OS/MVKGPUCapture.mm b/MoltenVK/MoltenVK/OS/MVKGPUCapture.mm index d72a7924..051bf2b0 100644 --- a/MoltenVK/MoltenVK/OS/MVKGPUCapture.mm +++ b/MoltenVK/MoltenVK/OS/MVKGPUCapture.mm @@ -36,7 +36,9 @@ void MVKGPUCaptureScope::beginScope() { if (_mtlCaptureScope) { [_mtlCaptureScope beginScope]; } else if (_isDefault && _isFirstBoundary) { +#if !MVK_MACCAT [_mtlQueue insertDebugCaptureBoundary]; +#endif } _isFirstBoundary = false; } @@ -45,7 +47,9 @@ void MVKGPUCaptureScope::endScope() { if (_mtlCaptureScope) { [_mtlCaptureScope endScope]; } else if (_isDefault) { +#if !MVK_MACCAT [_mtlQueue insertDebugCaptureBoundary]; +#endif } } diff --git a/README.md b/README.md index b613e62f..d2510b22 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ Introduction to MoltenVK 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*, and *tvOS*. +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*. *Metal* uses a different shading language, the *Metal Shading Language (MSL)*, than *Vulkan*, which uses *SPIR-V*. **MoltenVK** automatically converts your *SPIR-V* shaders diff --git a/Scripts/create_dylib_ios.sh b/Scripts/create_dylib_ios.sh index c2ee93c3..a3672f92 100755 --- a/Scripts/create_dylib_ios.sh +++ b/Scripts/create_dylib_ios.sh @@ -2,6 +2,11 @@ set -e +# We don't support dylib for Mac Catalyst yet +if [ "${IS_MACCATALYST}" == "YES" ]; then + exit 0 +fi + export MVK_OS_CLANG="ios" export MVK_UX_FWK="UIKit" export MVK_MIN_OS_VERSION=${IPHONEOS_DEPLOYMENT_TARGET} diff --git a/Scripts/package_moltenvk.sh b/Scripts/package_moltenvk.sh index 61f99b20..396dd129 100755 --- a/Scripts/package_moltenvk.sh +++ b/Scripts/package_moltenvk.sh @@ -30,6 +30,9 @@ export MVK_PROD_NAME="MoltenVK" export MVK_PROD_PROJ_PATH="${PROJECT_DIR}/${MVK_PROD_NAME}" export MVK_PKG_PROD_PATH="${PROJECT_DIR}/Package/${CONFIGURATION}/${MVK_PROD_NAME}" +# Make sure directory is there in case no dylibs are created for this platform +mkdir -p "${MVK_PKG_PROD_PATH}" + copy_dylib "" "macOS" copy_dylib "-iphoneos" "iOS" copy_dylib "-iphonesimulator" "iOS-simulator" From ab34b8c6d4906e157ce7324a97f399179fdf553e Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Wed, 2 Dec 2020 08:07:39 -0500 Subject: [PATCH 3/5] Remove spurious debug log message. --- MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm index 1c09eafd..4c22b556 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm @@ -367,8 +367,6 @@ MVKInstance::MVKInstance(const VkInstanceCreateInfo* pCreateInfo) : _enabledExte if (MVK_MACCAT && !mvkOSVersionIsAtLeast(11.0)) { setConfigurationResult(reportError(VK_ERROR_INCOMPATIBLE_DRIVER, "To support Mac Catalyst, MoltenVK requires macOS 11.0 or above.")); } - MVKLogInfo("Running Mac Catalyst %.4f.", mvkOSVersion()); - MVKLogInfo("Created VkInstance with the following %d Vulkan extensions enabled:%s", _enabledExtensions.getEnabledCount(), From f8d82620c08299cc8a55887d84c883ea0d82c2dd Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Wed, 2 Dec 2020 11:34:44 -0500 Subject: [PATCH 4/5] Update Travis CI to use Xcode 12.2 to support macOS 11.0 builds. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 503dc992..81a3a5d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: objective-c # macOS and Xcode Version os: osx -osx_image: xcode12 +osx_image: xcode12.2 # Build with verbose logging to avoid Travis timing out. script: From 7f62362db30ce8526a54d5911448dd5e00544fe7 Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Wed, 2 Dec 2020 16:22:38 -0500 Subject: [PATCH 5/5] Fixes from review for Mac Catalyst on macOS 11.0+. MVKPixelFormats revert testing for stencil feedback and add Mac Catalyst test. Revert mvkOSVersionIsAtLeast(mac, ios) to remove test for Mac Catalyst version. MVKRenderPass revert testing for MTLStorageModeMemoryless for iOS. --- Common/MVKOSExtensions.h | 11 ++++----- MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm | 2 +- .../MoltenVK/GPUObjects/MVKPixelFormats.mm | 24 +++++++++---------- MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm | 6 ++++- MoltenVK/MoltenVK/Layers/MVKExtensions.mm | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Common/MVKOSExtensions.h b/Common/MVKOSExtensions.h index b3ad369f..a8dade92 100644 --- a/Common/MVKOSExtensions.h +++ b/Common/MVKOSExtensions.h @@ -48,19 +48,16 @@ inline bool mvkOSVersionIsAtLeast(MVKOSVersion minVer) { return mvkOSVersion() > /** * Returns whether the operating system version is at least the appropriate min version. - * The constant kMVKOSVersionUnsupported can be used for any value to cause the test + * The constant kMVKOSVersionUnsupported can be used for either value to cause the test * to always fail on that OS, which is useful for indidicating functionalty guarded by * this test is not supported on that OS. */ -inline bool mvkOSVersionIsAtLeast(MVKOSVersion iOSMinVer, MVKOSVersion macOSMinVer, MVKOSVersion macCatMinVer) { -#if MVK_IOS_OR_TVOS - return mvkOSVersionIsAtLeast(iOSMinVer); -#endif +inline bool mvkOSVersionIsAtLeast(MVKOSVersion macOSMinVer, MVKOSVersion iOSMinVer) { #if MVK_MACOS return mvkOSVersionIsAtLeast(macOSMinVer); #endif -#if MVK_MACCAT - return mvkOSVersionIsAtLeast(macCatMinVer); +#if MVK_IOS_OR_TVOS + return mvkOSVersionIsAtLeast(iOSMinVer); #endif } diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 02cf61a2..63046590 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -330,7 +330,7 @@ void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) { if (_features.tessellationShader) { subgroupProps->supportedStages |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; } - if (mvkOSVersionIsAtLeast(13.0, 10.15, 14.0)) { + if (mvkOSVersionIsAtLeast(10.15, 13.0)) { subgroupProps->supportedStages |= VK_SHADER_STAGE_FRAGMENT_BIT; } subgroupProps->supportedOperations = VK_SUBGROUP_FEATURE_BASIC_BIT; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm index 9bb28397..4ca6b4fe 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPixelFormats.mm @@ -2043,25 +2043,25 @@ void MVKPixelFormats::setFormatProperties(MVKVkFormatDesc& vkDesc) { enableFormatFeatures(DSAtt, Tex, mtlPixFmtCaps, vkProps.optimalTilingFeatures); enableFormatFeatures(Blend, Tex, mtlPixFmtCaps, vkProps.optimalTilingFeatures); -#if MVK_MACOS_OR_IOS + // We would really want to use the device's Metal features instead of duplicating + // the logic from MVKPhysicalDevice, but those may not have been initialized yet. id mtlDev = _physicalDevice ? _physicalDevice->getMTLDevice() : nil; +#if MVK_MACOS && !MVK_MACCAT + bool supportsStencilFeedback = [mtlDev supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily2_v1]; #endif - if ( chromaSubsamplingComponentBits > 0 || - // XXX We really want to use the device's Metal features instead of duplicating the - // logic from MVKPhysicalDevice, but those may not have been initialized yet. -#if MVK_MACOS - (isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || !([mtlDev supportsFamily: MTLGPUFamilyMac2] || - [mtlDev supportsFamily: MTLGPUFamilyMacCatalyst2]))) +#if MVK_MACCAT + bool supportsStencilFeedback = [mtlDev supportsFamily: MTLGPUFamilyMacCatalyst2]; #endif #if MVK_IOS - (isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || ![mtlDev supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1])) + bool supportsStencilFeedback = [mtlDev supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1]; #endif #if MVK_TVOS - isStencilFormat(vkDesc.mtlPixelFormat) + bool supportsStencilFeedback = (mtlDev && !mtlDev); // Really just false...but silence warning on unused mtlDev otherwise #endif - ) { - // Vulkan forbids blits between chroma-subsampled formats. - // If we can't write the stencil reference from the shader, we can't blit stencil. + + // Vulkan forbids blits between chroma-subsampled formats. + // If we can't write the stencil reference from the shader, we can't blit stencil. + if (chromaSubsamplingComponentBits > 0 || (isStencilFormat(vkDesc.mtlPixelFormat) && !supportsStencilFeedback)) { mvkDisableFlags(vkProps.optimalTilingFeatures, (VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT)); } diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm b/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm index 3db55988..84c49979 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKRenderPass.mm @@ -327,11 +327,15 @@ void MVKRenderSubpass::populateMTLRenderPassDescriptor(MTLRenderPassDescriptor* mtlTexDesc.textureType = MTLTextureType2DMultisample; mtlTexDesc.sampleCount = sampleCount; } - if (mvkOSVersionIsAtLeast(10.0, 11.0, 14.0)) { +#if MVK_IOS + if ([_renderPass->getMTLDevice() supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v3]) { mtlTexDesc.storageMode = MTLStorageModeMemoryless; } else { mtlTexDesc.storageMode = MTLStorageModePrivate; } +#else + mtlTexDesc.storageMode = MTLStorageModePrivate; +#endif mtlTexDesc.usage = MTLTextureUsageRenderTarget; _mtlDummyTex = [_renderPass->getMTLDevice() newTextureWithDescriptor: mtlTexDesc]; // not retained [_mtlDummyTex setPurgeableState: MTLPurgeableStateVolatile]; diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.mm b/MoltenVK/MoltenVK/Layers/MVKExtensions.mm index ecf06ab3..0dc34002 100644 --- a/MoltenVK/MoltenVK/Layers/MVKExtensions.mm +++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.mm @@ -49,7 +49,7 @@ static bool mvkIsSupportedOnPlatform(VkExtensionProperties* pProperties) { #define MVK_DISABLED_EXTENSION(EXT) \ if (pProperties == &kVkExtProps_##EXT) { return false; } #define MVK_EXTENSION_MIN_OS(EXT, MAC, IOS) \ - if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(IOS, MAC, 14.0); } + if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(MAC, IOS); } #if MVK_MACOS MVK_DISABLED_EXTENSION(MVK_IOS_SURFACE)