Merge pull request #1485 from billhollings/rosetta2-and-msl24
Updates to better support Rosetta2 runtimes, and MSL 2.4 and 2.3 versions.
This commit is contained in:
commit
bc4ce5799c
@ -19,6 +19,12 @@ MoltenVK 1.1.7
|
|||||||
Released TBD
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
7c3cb0b12c9965497b08403c82ac1b82846fa7be
|
e9cc6403341baf0edd430a4027b074d0a06b782f
|
||||||
|
@ -1273,6 +1273,11 @@ void MVKPhysicalDevice::initMetalFeatures() {
|
|||||||
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_3;
|
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_3;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if MVK_XCODE_13
|
||||||
|
if ( mvkOSVersionIsAtLeast(15.0) ) {
|
||||||
|
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1377,6 +1382,11 @@ void MVKPhysicalDevice::initMetalFeatures() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if MVK_XCODE_13
|
||||||
|
if ( mvkOSVersionIsAtLeast(15.0) ) {
|
||||||
|
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1447,7 +1457,7 @@ void MVKPhysicalDevice::initMetalFeatures() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MVK_MACOS_APPLE_SILICON
|
#if MVK_XCODE_12
|
||||||
if ( mvkOSVersionIsAtLeast(10.16) ) {
|
if ( mvkOSVersionIsAtLeast(10.16) ) {
|
||||||
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_3;
|
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_3;
|
||||||
if (supportsMTLGPUFamily(Apple5)) {
|
if (supportsMTLGPUFamily(Apple5)) {
|
||||||
@ -1475,6 +1485,11 @@ void MVKPhysicalDevice::initMetalFeatures() {
|
|||||||
_metalFeatures.textureBarriers = true;
|
_metalFeatures.textureBarriers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MVK_XCODE_13
|
||||||
|
if ( mvkOSVersionIsAtLeast(12.0) ) {
|
||||||
|
_metalFeatures.mslVersionEnum = MTLLanguageVersion2_4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Note the selector name, which is different from the property name.
|
// 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);
|
strlcpy(_properties.deviceName, _mtlDevice.name.UTF8String, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE);
|
||||||
|
|
||||||
if (supportsMTLGPUFamily(Apple5)) {
|
if (supportsMTLGPUFamily(Apple5)) {
|
||||||
// This is an Apple GPU. It won't have a 'device-id' property, so fill it in
|
// This is an Apple GPU. It won't have a 'device-id' property, so fill it in like on iOS/tvOS.
|
||||||
// like on iOS/tvOS.
|
// Test for Apple5 first instead of Apple7 to support Xcode 11.7 builds.
|
||||||
_properties.vendorID = kAppleVendorId;
|
_properties.vendorID = kAppleVendorId;
|
||||||
#if MVK_MACOS_APPLE_SILICON
|
#if MVK_XCODE_12
|
||||||
if (supportsMTLGPUFamily(Apple7)) {
|
if (supportsMTLGPUFamily(Apple7)) {
|
||||||
_properties.deviceID = 0xa140;
|
_properties.deviceID = 0xa140;
|
||||||
} else if (supportsMTLGPUFamily(Apple6)) {
|
} else if (supportsMTLGPUFamily(Apple6)) {
|
||||||
_properties.deviceID = 0xa130;
|
_properties.deviceID = 0xa130;
|
||||||
} else {
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
_properties.deviceID = 0xa120;
|
_properties.deviceID = 0xa120;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
_properties.deviceID = 0xa120;
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2268,6 +2282,11 @@ void MVKPhysicalDevice::initGPUInfoProperties() {
|
|||||||
void MVKPhysicalDevice::initGPUInfoProperties() {
|
void MVKPhysicalDevice::initGPUInfoProperties() {
|
||||||
NSUInteger coreCnt = NSProcessInfo.processInfo.processorCount;
|
NSUInteger coreCnt = NSProcessInfo.processInfo.processorCount;
|
||||||
uint32_t devID = 0xa070;
|
uint32_t devID = 0xa070;
|
||||||
|
#if MVK_XCODE_13
|
||||||
|
if (supportsMTLGPUFamily(Apple8)) {
|
||||||
|
devID = 0xa150;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
#if MVK_XCODE_12
|
#if MVK_XCODE_12
|
||||||
if (supportsMTLGPUFamily(Apple7)) {
|
if (supportsMTLGPUFamily(Apple7)) {
|
||||||
devID = 0xa140;
|
devID = 0xa140;
|
||||||
@ -2480,10 +2499,15 @@ uint32_t MVKPhysicalDevice::getHighestMTLFeatureSet() {
|
|||||||
if (supportsMTLGPUFamily(Apple3)) { mtlFam = MTLGPUFamilyApple3; }
|
if (supportsMTLGPUFamily(Apple3)) { mtlFam = MTLGPUFamilyApple3; }
|
||||||
if (supportsMTLGPUFamily(Apple4)) { mtlFam = MTLGPUFamilyApple4; }
|
if (supportsMTLGPUFamily(Apple4)) { mtlFam = MTLGPUFamilyApple4; }
|
||||||
if (supportsMTLGPUFamily(Apple5)) { mtlFam = MTLGPUFamilyApple5; }
|
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; }
|
if (supportsMTLGPUFamily(Apple6)) { mtlFam = MTLGPUFamilyApple6; }
|
||||||
|
#endif
|
||||||
|
#if (MVK_IOS || MVK_MACOS) && MVK_XCODE_12
|
||||||
if (supportsMTLGPUFamily(Apple7)) { mtlFam = MTLGPUFamilyApple7; }
|
if (supportsMTLGPUFamily(Apple7)) { mtlFam = MTLGPUFamilyApple7; }
|
||||||
#endif
|
#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
|
// Not explicitly guaranteed to be unique...but close enough without spilling over
|
||||||
uint32_t mtlFS = (mtlVer << 8) + (uint32_t)mtlFam;
|
uint32_t mtlFS = (mtlVer << 8) + (uint32_t)mtlFam;
|
||||||
@ -2622,7 +2646,7 @@ void MVKPhysicalDevice::initMemoryProperties() {
|
|||||||
|
|
||||||
// Memoryless storage
|
// Memoryless storage
|
||||||
uint32_t memlessBit = 0;
|
uint32_t memlessBit = 0;
|
||||||
#if MVK_MACOS_APPLE_SILICON
|
#if MVK_MACOS
|
||||||
if (supportsMTLGPUFamily(Apple5)) {
|
if (supportsMTLGPUFamily(Apple5)) {
|
||||||
memlessBit = 1 << typeIdx;
|
memlessBit = 1 << typeIdx;
|
||||||
setMemoryType(typeIdx, mainHeapIdx, MVK_VK_MEMORY_TYPE_METAL_MEMORYLESS);
|
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\tsupports the following Metal Versions, GPU's and Feature Sets:";
|
||||||
logMsg += "\n\t\tMetal Shading Language %s";
|
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"; }
|
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"; }
|
if (supportsMTLGPUFamily(Apple6)) { logMsg += "\n\t\tGPU Family Apple 6"; }
|
||||||
#endif
|
#endif
|
||||||
if (supportsMTLGPUFamily(Apple5)) { logMsg += "\n\t\tGPU Family Apple 5"; }
|
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.
|
// Decide whether Vulkan semaphores should use a MTLEvent or MTLFence if they are available.
|
||||||
// Prefer MTLEvent, because MTLEvent handles sync across MTLCommandBuffers and MTLCommandQueues.
|
// 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.
|
// However, do not allow use of MTLEvents on Rosetta2 (x86 build on M1 runtime) or NVIDIA GPUs,
|
||||||
// Since MTLFence config is disabled by default, emulation will be used on NVIDIA unless MTLFence is enabled.
|
// which have demonstrated trouble with MTLEvents. In that case, since MTLFence use is disabled
|
||||||
bool canUseMTLEventForSem4 = _pMetalFeatures->events && mvkConfig().semaphoreUseMTLEvent && (_pProperties->vendorID != kNVVendorId);
|
// 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;
|
bool canUseMTLFenceForSem4 = _pMetalFeatures->fences && mvkConfig().semaphoreUseMTLFence;
|
||||||
_vkSemaphoreStyle = canUseMTLEventForSem4 ? VkSemaphoreStyleUseMTLEvent : (canUseMTLFenceForSem4 ? VkSemaphoreStyleUseMTLFence : VkSemaphoreStyleUseEmulation);
|
_vkSemaphoreStyle = canUseMTLEventForSem4 ? VkSemaphoreStyleUseMTLEvent : (canUseMTLFenceForSem4 ? VkSemaphoreStyleUseMTLFence : VkSemaphoreStyleUseEmulation);
|
||||||
switch (_vkSemaphoreStyle) {
|
switch (_vkSemaphoreStyle) {
|
||||||
|
@ -71,6 +71,11 @@ bool mvk::compile(const string& mslSourceCode,
|
|||||||
#define mslVer(MJ, MN, PT) mslVersionMajor == MJ && mslVersionMinor == MN && mslVersionPoint == PT
|
#define mslVer(MJ, MN, PT) mslVersionMajor == MJ && mslVersionMinor == MN && mslVersionPoint == PT
|
||||||
|
|
||||||
MTLLanguageVersion mslVerEnum = (MTLLanguageVersion)0;
|
MTLLanguageVersion mslVerEnum = (MTLLanguageVersion)0;
|
||||||
|
#if MVK_XCODE_13
|
||||||
|
if (mslVer(2, 4, 0)) {
|
||||||
|
mslVerEnum = MTLLanguageVersion2_4;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
#if MVK_XCODE_12
|
#if MVK_XCODE_12
|
||||||
if (mslVer(2, 3, 0)) {
|
if (mslVer(2, 3, 0)) {
|
||||||
mslVerEnum = MTLLanguageVersion2_3;
|
mslVerEnum = MTLLanguageVersion2_3;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user