Function

MTLCopyAllDevicesWithObserver

Fetches the available Metal devices and registers a notification observer for changes to the list.

Declaration

NSArray<id<MTLDevice>> * MTLCopyAllDevicesWithObserver(id<NSObject>  _Nullable *observer, MTLDeviceNotificationHandler handler);

Parameters

observer

An object that receives device notifications.

handler

A block of code invoked when a device notification is received.

Discussion

The observer object is retained by Metal. Call the MTLRemoveDeviceObserver function, passing the observer object, to stop receiving device notifications.

Topics

Notification Handler

MTLDeviceNotificationHandler

A block of code invoked when a device observer receives a notification.

Notifications

MTLDeviceNotificationName

The notifications posted when a GPU supported by Metal is added to or removed from the system.

See Also

Acquiring Device Objects

MTLCreateSystemDefaultDevice

Returns a reference to the preferred default Metal device object.

MTLCopyAllDevices

Returns an array of references to all Metal device objects in the system.

MTLRemoveDeviceObserver

Removes a registered observer of device notifications.

CGDirectDisplayCopyCurrentMetalDevice

Returns a reference to the Metal device currently driving a given display.