Skip to content

Instantly share code, notes, and snippets.

@malfet
Last active June 8, 2022 17:35
Show Gist options
  • Save malfet/d8f01d9ac8d2e1268569c4daebd87de6 to your computer and use it in GitHub Desktop.
Save malfet/d8f01d9ac8d2e1268569c4daebd87de6 to your computer and use it in GitHub Desktop.
ObjC script to query available metal devices
// Compile me as
// clang++ query_metal_devices.mm -framework Metal -framework Foundation
#include <Metal/Metal.h>
int main() {
@autoreleasepool {
NSArray* devices = [MTLCopyAllDevices() autorelease];
NSLog(@"Metal device count %lu", devices.count);
for (unsigned long i = 0 ; i < devices.count ; i++) {
id<MTLDevice> device = devices[i];
NSLog(@"Found device %@ isLowPower %s", device.name, device.isLowPower ? "true" : "false");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment