MTLCopyAllDevicesWithObserver() returns an array of MTLCaptureDevice objects, but the observer returns MTLDebugDevice objects. How do I compare them?

I'm looking at Apple's Device Selection and Fallback for Graphics Rendering sample code. In that code, MTLCopyAllDevicesWithObserver() returns an array of MTLCaptureDevice objects. However, when a disconnect event is handled, the device sent to the observer is an MTLDebugDevice.


How do I correctly compare an MTLDebugDevice with an MTLCaptureDevice? You would think that -isEqual: would return true if they pointed to the same device, but it doesn't. I'm using macOS 10.15.4.

Replies

Sounds like a bug, so you should probably report it.

If I understand correctly, MTLCaptureDevice and MTLDebugDevice are MTLDevice wrappers used when launching Debugging under Xcode in Debug mode, so the real MTLDevice should be somewhere under the hood of these objects. Looks like they forgot to wrap the MTLDevice propeply in disconnect handling code.

Comparing registryID property of MTLDevice should work. I'm pretty sure it is the intended way.