我正在尝试使用MTLCaptureManager
在命令行应用程序中以编程方式捕获GPU帧。
到目前为止,捕获管理器不支持MTLCaptureDestinationGPUTraceDocument
目标。
我尝试使用XCode创建一个非常简单的重现案例:
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
MTLCaptureManager* captureManager = [MTLCaptureManager sharedCaptureManager];
if (![captureManager supportsDestination:MTLCaptureDestinationGPUTraceDocument])
{
NSLog(@"********** captureManager does not support MTLCaptureDestinationGPUTraceDocument ************");
}
else
{
NSLog(@"captureManager support is fine");
}
}
return 0;
}
当在XCode下运行时,它似乎愿意工作: 输出为:
2020-09-02 16:25:59.712217+0200 testMetalCapture[20095:416447] Metal GPU Frame Capture Enabled
2020-09-02 16:25:59.712503+0200 testMetalCapture[20095:416447] Metal API Validation Enabled
2020-09-02 16:26:00.669092+0200 testMetalCapture[20095:416447] captureManager support is fine
Program ended with exit code: 0
但是当我归档构建结果并从终端运行时,它失败了:
2020-09-02 16:32:57.607 testMetalCapture[20126:419837] ********** captureManager does not support MTLCaptureDestinationGPUTraceDocument ************
有没有可以在终端中复制的运行时环境,以便使 MTLCaptureManager
生效?
(环境为 XCode 11.6 + MacOS 10.15 Catalina)