MTLCopyAllDevicesWithObserver(handler:)
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
func MTLCopyAllDevicesWithObserver(handler: @escaping (any MTLDevice, MTLDeviceNotificationName) -> Void) -> (devices: [any MTLDevice], observer: NSObject)Parameters
- handler:
A notification handler you implement that Metal calls when the system adds or removes a GPU device from the system.
Return Value
devicesAn array of MTLDevice instances
observerAn object instance that represents an observer the function creates for you.
Discussion
Keep a copy of observer in your app in case you want to stop receiving notifications. You can stop receiving notifications by passing observer to the MTLRemoveDeviceObserver(_:) function.