Force Metal app to run on integrated graphics card

As I pointed out in another thread, I'm having serious difficulties porting my OpenGL app to Metal because every graphics card behaves differently, and I don't have the resources to test the app on every single one of them. So I was wondering if I could force the Metal app to always run on the integrated graphics which, for all Macs currently being sold on the Apple website, is always Intel. Is this possible and does anyone know if older Macs have integrated graphics cards that are not Intel?

Accepted Reply

This seems unwise - my iMac has no integrated GPU (or it has, but it's disabled and can't be used). You're also going to get poor performance unless it's something fairly basic, on systems that maybe have a weak integrated GPU but a high end descrete GPU. Fixing the actual issue might make more sense - make sure you have Metal validation enabled and check any reported issues, and check you're setting pixel formats properly etc.


But to select a particular GPU: when you set up your MTLDevice, instead of using MTLCreateSystemDefaultDevice, use MTLCopyAllDevices which will give you an array. You'll then need to figure out which device you want.

Replies

This seems unwise - my iMac has no integrated GPU (or it has, but it's disabled and can't be used). You're also going to get poor performance unless it's something fairly basic, on systems that maybe have a weak integrated GPU but a high end descrete GPU. Fixing the actual issue might make more sense - make sure you have Metal validation enabled and check any reported issues, and check you're setting pixel formats properly etc.


But to select a particular GPU: when you set up your MTLDevice, instead of using MTLCreateSystemDefaultDevice, use MTLCopyAllDevices which will give you an array. You'll then need to figure out which device you want.

Thank you, I wasn't aware that the different MTLDevice represent a GPU each. Performance is not much of a problem and it seems to run just fine on integrated graphic cards. So my solution now is to filter out all unsupported graphic cards (i.e. Nvidia), get the first one in the filtered list (which seems to sort the integrated graphic card first), and if there is no device left, fallback to the old OpenGL implementation (which sadly doesn't work on macOS 10.15). I'll probably have to put a big attention sign on the App Store page to alert users about this issue.

Rather than looking at the order of devices you can use the lowPower attribute to identify the integrated GPU. Apart from that I must say that except for the very old Nvidia GPUs I haven't really seen any Metal device specific issues when it comes to our compute code

It is an Nvidia GeForce GT 750M 2 GB. Does it belong to the very old ones?

Yes - in todays time frame every Nvidia GPU built into a Mac can be considered old