Skip to content

Instantly share code, notes, and snippets.

@Keyaku
Created May 20, 2016 07:08
Show Gist options
  • Save Keyaku/3d8d493b080a08f21e7122c02ecfd33a to your computer and use it in GitHub Desktop.
Save Keyaku/3d8d493b080a08f21e7122c02ecfd33a to your computer and use it in GitHub Desktop.
Check for Metal capability on your Mac OS X system. 10.11 & above only!
/*
** Compile in terminal with the following line:
** clang main.m -framework Foundation -framework Metal -o TestMetal
*/
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
int main(void) {
@autoreleasepool {
NSArray<id<MTLDevice>> *devices = MTLCopyAllDevices();
printf("Metal-capable devices: %d\n", (int) devices.count);
for (id<MTLDevice> device in devices) {
const char *name = device.name.UTF8String;
const char *lowpower = device.isLowPower ? "yes" : "no";
const char *headless = device.isHeadless ? "yes" : "no";
printf(" - %s (low power: %s, headless: %s)\n", name, lowpower, headless);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment