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

Pon*_*ony 4 macos gpu ios metal

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

gpu*_*u3d 5

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

在此输入图像描述

编辑:

Objective-C这看起来类似.<Metal/Metal.h>先输入:

@implementation AppDelegate

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

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

@end

  • 文档在这里:[`MTLCopyAllDevices`](https://developer.apple.com/library/mac/documentation/Metal/Reference/MTLFunctions_Ref/#//apple_ref/c/func/MTLCopyAllDevices).此功能仅适用于OS X.在iOS上,只有一个设备,您可以通过调用[`MTLCreateSystemDefaultDevice`]来获取它(https://developer.apple.com/library/ios/documentation/Metal/Reference/ MTLFunctions_Ref /#// apple_ref/C/FUNC/MTLCreateSystemDefaultDevice). (2认同)