MTLCopyAllDevicesWithObserver
Returns an array of all the Metal GPU devices in the system and registers a notification handler that Metal calls when the device list changes.
Declaration
extern NSArray<id<MTLDevice>> *MTLCopyAllDevicesWithObserver(id<NSObject>*observer, MTLDeviceNotificationHandler handler);Parameters
- observer:
A pointer to an object instance the method sets to a new observer — which Metal retains — before returning.
- handler:
A notification handler you implement that Metal calls when the system adds or removes a GPU device from the system.
Mentioned in
Discussion
Keep a copy of observer in your app after this function returns in case you want to stop receiving notifications. You can stop receiving notifications by passing observer to the MTLRemoveDeviceObserver(_:) function.