如何检测macOS上的外部GPU(eGPU)连接和断开?
我想写一个macOS应用程序,当你通过如何检测macOS上的外部GPU(eGPU)连接和断开?,macos,gpu,metal,iokit,Macos,Gpu,Metal,Iokit,我想写一个macOS应用程序,当你通过disconnect“GPU Name”菜单Extra断开一个外部GPU时,它会检测你,然后采取一些措施 我使用什么API来检测GPU的存在 当GPU断开连接并随后插入时,我可以收到通知吗 来自苹果: 注册外部GPU通知 调用函数以获取列表 一个系统可用的所有金属设备的 此列表更改(或可能会因更改而更改)时调用的观察者 安全断开连接请求) id <NSObject> deviceObserver = nil; NSArray<id<
disconnect“GPU Name”
菜单Extra断开一个外部GPU时,它会检测你,然后采取一些措施
- 我使用什么API来检测GPU的存在
- 当GPU断开连接并随后插入时,我可以收到通知吗
id <NSObject> deviceObserver = nil;
NSArray<id<MTLDevice>> *deviceList = nil;
deviceList = MTLCopyAllDevicesWithObserver(&deviceObserver,
^(id<MTLDevice> device, MTLDeviceNotificationName name) {
[self handleExternalGPUEventsForDevice:device notification:name];
});
_deviceObserver = deviceObserver;
_deviceList = deviceList;
- (void)handleExternalGPUEventsForDevice:(id<MTLDevice>)device notification:(MTLDeviceNotificationName)notification
{
if (notification == MTLDeviceWasAddedNotification) { }
else if (notification == MTLDeviceRemovalRequestedNotification) { }
else if (notification == MTLDeviceWasRemovedNotification) { }
}