CIContext contextWithMTLDevice vs CIContext contextWithOptions

The docs for +[CIContext contextWithMTLDevice:options:] says

“If a client wishes to use the default MTLDevice then call [CIContext contextWithOptions:] instead”


However, I noticed different behavior if I call:


ciContext = [CIContext contextWithOptions:nil];


vs


id device = MTLCreateSystemDefaultDevice();
ciContext = [CIContext contextWithMTLDevice:device options:nil];


in that on my Macbook Pro, the latter engages the Discrete GPU and the former does not.


Thoughts? Are there differences behind the scenes here?

Can an Apple dev explain the proper way to create a context that will succeed on Metal and non-Metal capable Macs, but use the best GPU?

Will MTLCreateSystemDefaultDevice() fail on a non-Metal capable Mac?


Thanks,

-Ken

Replies

This seems like a CI problem (in documentation if not implementaion).


MTLCreateSystemDefaultDevice() will always return the Discrete GPU on MacBooks that have one.


MTLCreateSystemDefaultDevice() will return nil on non-Metal capable Macs.