diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index cfefbb17..47a6ff26 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -18,7 +18,13 @@ MoltenVK 1.1.7 Released TBD -- Support building MoltenVK with static Vulkan linkage symbols hidden. +- Support building MoltenVK with static Vulkan linkage symbols hidden. +- Do not use `MTLEvent` for `VkSemaphore` under *Rosetta2*. +- Support compiling *MSL 2.4* in runtime pipelines and `MoltenVKShaderConverterTool`. +- Fix issue where *MSL 2.3* only available on *Apple Silicon*, even on *macOS*. +- Update to latest SPIRV-Cross: + - MSL: Add 64 bit support for `OpSwitch`. + - MSL: Don't output depth and stencil values with explicit early fragment tests. diff --git a/ExternalRevisions/SPIRV-Cross_repo_revision b/ExternalRevisions/SPIRV-Cross_repo_revision index 25967c3b..11d4f3bd 100644 --- a/ExternalRevisions/SPIRV-Cross_repo_revision +++ b/ExternalRevisions/SPIRV-Cross_repo_revision @@ -1 +1 @@ -7c3cb0b12c9965497b08403c82ac1b82846fa7be +e9cc6403341baf0edd430a4027b074d0a06b782f diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index a4e69ff8..49aea68b 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -1273,6 +1273,11 @@ void MVKPhysicalDevice::initMetalFeatures() { _metalFeatures.mslVersionEnum = MTLLanguageVersion2_3; } #endif +#if MVK_XCODE_13 + if ( mvkOSVersionIsAtLeast(15.0) ) { + _metalFeatures.mslVersionEnum = MTLLanguageVersion2_4; + } +#endif #endif @@ -1377,6 +1382,11 @@ void MVKPhysicalDevice::initMetalFeatures() { } } #endif +#if MVK_XCODE_13 + if ( mvkOSVersionIsAtLeast(15.0) ) { + _metalFeatures.mslVersionEnum = MTLLanguageVersion2_4; + } +#endif #endif @@ -1447,7 +1457,7 @@ void MVKPhysicalDevice::initMetalFeatures() { } } -#if MVK_MACOS_APPLE_SILICON +#if MVK_XCODE_12 if ( mvkOSVersionIsAtLeast(10.16) ) { _metalFeatures.mslVersionEnum = MTLLanguageVersion2_3; if (supportsMTLGPUFamily(Apple5)) { @@ -1475,6 +1485,11 @@ void MVKPhysicalDevice::initMetalFeatures() { _metalFeatures.textureBarriers = true; } +#if MVK_XCODE_13 + if ( mvkOSVersionIsAtLeast(12.0) ) { + _metalFeatures.mslVersionEnum = MTLLanguageVersion2_4; + } +#endif #endif // Note the selector name, which is different from the property name. @@ -2201,20 +2216,19 @@ void MVKPhysicalDevice::initGPUInfoProperties() { strlcpy(_properties.deviceName, _mtlDevice.name.UTF8String, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE); if (supportsMTLGPUFamily(Apple5)) { - // This is an Apple GPU. It won't have a 'device-id' property, so fill it in - // like on iOS/tvOS. + // This is an Apple GPU. It won't have a 'device-id' property, so fill it in like on iOS/tvOS. + // Test for Apple5 first instead of Apple7 to support Xcode 11.7 builds. _properties.vendorID = kAppleVendorId; -#if MVK_MACOS_APPLE_SILICON +#if MVK_XCODE_12 if (supportsMTLGPUFamily(Apple7)) { _properties.deviceID = 0xa140; } else if (supportsMTLGPUFamily(Apple6)) { _properties.deviceID = 0xa130; - } else { + } else +#endif + { _properties.deviceID = 0xa120; } -#else - _properties.deviceID = 0xa120; -#endif return; } @@ -2268,6 +2282,11 @@ void MVKPhysicalDevice::initGPUInfoProperties() { void MVKPhysicalDevice::initGPUInfoProperties() { NSUInteger coreCnt = NSProcessInfo.processInfo.processorCount; uint32_t devID = 0xa070; +#if MVK_XCODE_13 + if (supportsMTLGPUFamily(Apple8)) { + devID = 0xa150; + } else +#endif #if MVK_XCODE_12 if (supportsMTLGPUFamily(Apple7)) { devID = 0xa140; @@ -2480,10 +2499,15 @@ uint32_t MVKPhysicalDevice::getHighestMTLFeatureSet() { if (supportsMTLGPUFamily(Apple3)) { mtlFam = MTLGPUFamilyApple3; } if (supportsMTLGPUFamily(Apple4)) { mtlFam = MTLGPUFamilyApple4; } if (supportsMTLGPUFamily(Apple5)) { mtlFam = MTLGPUFamilyApple5; } -#if MVK_IOS || MVK_MACOS_APPLE_SILICON +#if MVK_IOS || (MVK_MACOS && MVK_XCODE_12) if (supportsMTLGPUFamily(Apple6)) { mtlFam = MTLGPUFamilyApple6; } +#endif +#if (MVK_IOS || MVK_MACOS) && MVK_XCODE_12 if (supportsMTLGPUFamily(Apple7)) { mtlFam = MTLGPUFamilyApple7; } #endif +#if MVK_IOS && MVK_XCODE_13 + if (supportsMTLGPUFamily(Apple8)) { mtlFam = MTLGPUFamilyApple8; } +#endif // Not explicitly guaranteed to be unique...but close enough without spilling over uint32_t mtlFS = (mtlVer << 8) + (uint32_t)mtlFam; @@ -2622,7 +2646,7 @@ void MVKPhysicalDevice::initMemoryProperties() { // Memoryless storage uint32_t memlessBit = 0; -#if MVK_MACOS_APPLE_SILICON +#if MVK_MACOS if (supportsMTLGPUFamily(Apple5)) { memlessBit = 1 << typeIdx; setMemoryType(typeIdx, mainHeapIdx, MVK_VK_MEMORY_TYPE_METAL_MEMORYLESS); @@ -2808,8 +2832,13 @@ void MVKPhysicalDevice::logGPUInfo() { logMsg += "\n\tsupports the following Metal Versions, GPU's and Feature Sets:"; logMsg += "\n\t\tMetal Shading Language %s"; -#if MVK_IOS || MVK_MACOS_APPLE_SILICON +#if MVK_IOS && MVK_XCODE_13 + if (supportsMTLGPUFamily(Apple8)) { logMsg += "\n\t\tGPU Family Apple 8"; } +#endif +#if (MVK_IOS || MVK_MACOS) && MVK_XCODE_12 if (supportsMTLGPUFamily(Apple7)) { logMsg += "\n\t\tGPU Family Apple 7"; } +#endif +#if MVK_IOS || (MVK_MACOS && MVK_XCODE_12) if (supportsMTLGPUFamily(Apple6)) { logMsg += "\n\t\tGPU Family Apple 6"; } #endif if (supportsMTLGPUFamily(Apple5)) { logMsg += "\n\t\tGPU Family Apple 5"; } @@ -3966,9 +3995,12 @@ void MVKDevice::initPhysicalDevice(MVKPhysicalDevice* physicalDevice, const VkDe // Decide whether Vulkan semaphores should use a MTLEvent or MTLFence if they are available. // Prefer MTLEvent, because MTLEvent handles sync across MTLCommandBuffers and MTLCommandQueues. - // However, do not allow use of MTLEvents on NVIDIA GPUs, which have demonstrated trouble with MTLEvents. - // Since MTLFence config is disabled by default, emulation will be used on NVIDIA unless MTLFence is enabled. - bool canUseMTLEventForSem4 = _pMetalFeatures->events && mvkConfig().semaphoreUseMTLEvent && (_pProperties->vendorID != kNVVendorId); + // However, do not allow use of MTLEvents on Rosetta2 (x86 build on M1 runtime) or NVIDIA GPUs, + // which have demonstrated trouble with MTLEvents. In that case, since MTLFence use is disabled + // by default, unless MTLFence is deliberately enabled, CPU emulation will be used. + bool isNVIDIA = _pProperties->vendorID == kNVVendorId; + bool isRosetta2 = _pProperties->vendorID == kAppleVendorId && !MVK_APPLE_SILICON; + bool canUseMTLEventForSem4 = _pMetalFeatures->events && mvkConfig().semaphoreUseMTLEvent && !(isRosetta2 || isNVIDIA); bool canUseMTLFenceForSem4 = _pMetalFeatures->fences && mvkConfig().semaphoreUseMTLFence; _vkSemaphoreStyle = canUseMTLEventForSem4 ? VkSemaphoreStyleUseMTLEvent : (canUseMTLFenceForSem4 ? VkSemaphoreStyleUseMTLFence : VkSemaphoreStyleUseEmulation); switch (_vkSemaphoreStyle) { diff --git a/MoltenVKShaderConverter/MoltenVKShaderConverterTool/OSSupport.mm b/MoltenVKShaderConverter/MoltenVKShaderConverterTool/OSSupport.mm index 2af65a8a..f0f8cb9f 100644 --- a/MoltenVKShaderConverter/MoltenVKShaderConverterTool/OSSupport.mm +++ b/MoltenVKShaderConverter/MoltenVKShaderConverterTool/OSSupport.mm @@ -71,6 +71,11 @@ bool mvk::compile(const string& mslSourceCode, #define mslVer(MJ, MN, PT) mslVersionMajor == MJ && mslVersionMinor == MN && mslVersionPoint == PT MTLLanguageVersion mslVerEnum = (MTLLanguageVersion)0; +#if MVK_XCODE_13 + if (mslVer(2, 4, 0)) { + mslVerEnum = MTLLanguageVersion2_4; + } else +#endif #if MVK_XCODE_12 if (mslVer(2, 3, 0)) { mslVerEnum = MTLLanguageVersion2_3;