如何在iphone或mac中识别可用的金属计算设备

时间:2016-03-30 03:49:50

标签: ios macos gpu metal

有人能举例说明如何用金属识别可用的计算设备,如cpu和gpu吗?非常感谢

1 个答案:

答案 0 :(得分:5)

Metal仅适用于GPU。也就是说,有一个名为MTLCopyAllDevices()的函数可以返回系统拥有的所有GPU。这是一个关于如何在OS X操场上运行它以查看我的系统具有哪些兼容设备的快速示例。

enter image description here

编辑:

Objective-C中,这看起来很相似。首先导入<Metal/Metal.h>

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

    NSArray *devices = MTLCopyAllDevices();
    for (id device in devices) {
        NSLog(@"%@", [device name]);
    }
}

@end