Function

MTLCopyAllDevicesWithObserver(handler:)

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

Declaration

func MTLCopyAllDevicesWithObserver(handler: @escaping MTLDeviceNotificationHandler) -> (devices: [MTLDevice], observer: NSObject)

Parameters

handler

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

Return Value

A tuple containing the array of device objects and an observer object.

Discussion

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

Topics

Notification Handler

typealias MTLDeviceNotificationHandler

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

Notifications

struct MTLDeviceNotificationName

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

See Also

Acquiring Device Objects

func MTLCreateSystemDefaultDevice() -> MTLDevice?

Returns a reference to the preferred default Metal device object.

func MTLCopyAllDevices() -> [MTLDevice]

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

func MTLRemoveDeviceObserver(NSObjectProtocol)

Removes a registered observer of device notifications.