79157949

Date: 2024-11-05 07:00:07
Score: 2
Natty:
Report link

Found a workaround, it seems that all the metal files in the target will be built into a normal .metallib library. But adding the -fcikernel makes it build for CIKernel. I end up building one of the .metallib using command line.

xcrun -sdk iphoneos metal -c -mios-version-min=15.0 blur.metal -o blur.air

xcrun -sdk iphoneos metallib blur.air -o blur.metallib

Then add the output file to the target.

let library = ShaderLibrary(url: Bundle.main.url(forResource: "blur", withExtension: "metallib")!)

The drawback is you have to manually build it when you update the metal file and it can not work on simulator. Guess the better way to do it is separate two different metal source file into frameworks?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Perry Wang