简体   繁体   English

加载金属内核着色器进行测试

[英]Loading metal kernel shaders for testing

I'm trying to make a cocoa touch framework that will be performing some parallel computations on OSX/iOS and I'm having some issues with setting up the tests.我正在尝试制作一个可可触摸框架,它将在 OSX/iOS 上执行一些并行计算,但我在设置测试时遇到了一些问题。 Whenever I try to run :每当我尝试运行时:

library = device.newDefaultLibrary()!

I get hit by the error :我被错误击中:

/Library/Caches/com.apple.xbs/Sources/Metal/Metal-55.2.8/Framework/MTLLibrary.mm:1016: failed assertion `filepath must not be nil.'

I was also trying to load shaders straight from the bundle without success.我也试图直接从包中加载着色器,但没有成功。

How do I load up metal shaders properly so I can use them within a framework / tests?如何正确加载金属着色器,以便我可以在框架/测试中使用它们?

Thanks!谢谢!

You can load a Metal library from your framework with this code:您可以使用以下代码从您的框架加载 Metal 库:

let library = try! sceneKitView.device!.newLibraryWithFile(NSBundle(forClass: TheNameOfThisClass.self).URLForResource("default", withExtension: "metallib")!.path!)

BUT I filed rdar://22618641 in September 2015 with a sample project that demonstrates that you can't load precompiled Metal libraries from frameworks — you get the same error you saw above when you try to use the library.但我在 2015 年 9 月提交了 rdar://22618641,其中包含一个示例项目,该项目表明您无法从框架加载预编译的 Metal 库——当您尝试使用该库时,您会遇到与上面看到的相同的错误。

(Well, you CAN load the library, you just can't actually use it.) (好吧,您可以加载库,但实际上无法使用它。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM