diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md index f432400e..1b81ed6c 100644 --- a/Docs/Whats_New.md +++ b/Docs/Whats_New.md @@ -24,6 +24,7 @@ Released TBD - Reducing redundant state changes to improve command encoding performance. - Update minimum Xcode deployment targets to macOS 10.13, iOS 11, and tvOS 11, to avoid Xcode build warnings in Xcode 14. +- Work around MTLCounterSet crash on additional Intel Iris Plus Graphics drivers. diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h index 7de4a798..f7bc5acf 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h @@ -393,6 +393,7 @@ protected: void initExternalMemoryProperties(); void initExtensions(); void initCounterSets(); + bool needsCounterSetRetained(); MVKArrayRef getQueueFamilies(); void initPipelineCacheUUID(); uint32_t getHighestGPUCapability(); diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index b773d0a2..1195cb96 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -2856,12 +2856,7 @@ void MVKPhysicalDevice::initCounterSets() { if (_metalFeatures.counterSamplingPoints) { NSArray>* counterSets = _mtlDevice.counterSets; - // Workaround for a bug in Intel Iris Plus Graphics driver where the counterSets - // array is not properly retained internally, and becomes a zombie when counterSets - // is called more than once, which occurs when an app creates more than one VkInstance. - // This workaround will cause a very small memory leak on systems that do not have this - // bug, so we apply the workaround only when absolutely needed for specific devices. - if (_properties.vendorID == kIntelVendorId && _properties.deviceID == 0x8a53) { [counterSets retain]; } + if (needsCounterSetRetained()) { [counterSets retain]; } for (id cs in counterSets){ NSString* csName = cs.name; @@ -2880,6 +2875,27 @@ void MVKPhysicalDevice::initCounterSets() { } } +// Workaround for a bug in Intel Iris Plus Graphics driver where the counterSets array is +// not properly retained internally, and becomes a zombie when counterSets is called more +// than once, which occurs when an app creates more than one VkInstance. This workaround +// will cause a very small memory leak on systems that do not have this bug, so we apply +// the workaround only when absolutely needed for specific devices. The list of deviceIDs +// is sourced from the list of Intel Iris Plus Graphics Gen11 tier G7 devices found here: +// https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units#Gen11 +bool MVKPhysicalDevice::needsCounterSetRetained() { + + if (_properties.vendorID != kIntelVendorId) { return false; } + + switch (_properties.deviceID) { + case 0x8a51: + case 0x8a52: + case 0x8a53: + return true; + default: + return false; + } +} + void MVKPhysicalDevice::logGPUInfo() { string devTypeStr; switch (_properties.deviceType) {