Checking if "Prefer External GPU" is enabled in Objective-C

Viewed 133

I'm making an application that should behave differently if "Prefer External GPU" is enabled or not.

Explaining that quickly: in Mojave, now you can enable an option called "Prefer External GPU" for any application in its "Get info" window.

Although, I still couldn't find any method to retrieve that information.

  • NSBundle didn't change since El Capitan, so it does not include any eGPU related info.
  • MTLDevice didn't received any isEnabled function or similar, and none of its new Mojave methods seems to be helpful either.
  • MTLCopyAllDevices returns an array of references to all Metal devices in the system, according to the official documentation, so that includes the eGPUs, even the mentioned option is selected.
  • MTLCopyAllDevicesWithObserver has the same problem, since in the sample in the documentation, it returns all Metal devices available to the system, so that basically ignores the mentioned option again.
  • The terminal command mdls doesn't seems to show any info related to eGPUs either (although I can be wrong, since I don't have any eGPU to check its output for an app if I enable the said option). Still, if it does exists, it's still undocumented:

Common Metadata Attribute Keys https://developer.apple.com/documentation/coreservices/file_metadata/mditem/common_metadata_attribute_keys?language=objc

File System Metadata Attribute Keys https://developer.apple.com/documentation/coreservices/file_metadata/mditem/file_system_metadata_attribute_keys?language=objc

Does anyone knows how to check that in Objective-C or using a terminal command? (I would prefer the first option, but in case there no other way I can run a terminal command within the app).

0 Answers
Related