简体   繁体   中英

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. 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:

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.

(Well, you CAN load the library, you just can't actually use it.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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