Work around MTLCounterSet crash on additional Intel Iris Plus Graphics drivers.

Add 0x8a51 and 0x8a52 to list of device IDs requiring workaround.
This commit is contained in:
Bill Hollings 2022-07-14 11:19:48 -04:00
parent 41f59d0f3e
commit c5c7e80a6c
3 changed files with 24 additions and 6 deletions

View File

@ -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.

View File

@ -393,6 +393,7 @@ protected:
void initExternalMemoryProperties();
void initExtensions();
void initCounterSets();
bool needsCounterSetRetained();
MVKArrayRef<MVKQueueFamily*> getQueueFamilies();
void initPipelineCacheUUID();
uint32_t getHighestGPUCapability();

View File

@ -2856,12 +2856,7 @@ void MVKPhysicalDevice::initCounterSets() {
if (_metalFeatures.counterSamplingPoints) {
NSArray<id<MTLCounterSet>>* 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<MTLCounterSet> 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) {