在将自定义 Core Image 过滤器内核迁移到 Metal Shading Language 时,我在构建默认 Metal 库 (default.metallib) 时遇到错误:
metallib: error: exactly one input file required
我的印象是这些可能在单独的 .metal 文件中。尝试将它们合并到一个文件中会导致此错误:
Metal library creation failed: Error Domain=MTLLibraryErrorDomain Code=3 "Filters module must contain no vertex/fragment/kernel functions but contains 1 kernel function"
命名空间以metal
防止coreimage
计算内核在默认库中显示为可用函数。
找到了这个 SO answer,它建议构建单独的库:
Metal:为 MSL cikernel 设置编译器和链接器选项后,.metal 文件中定义的 vertexFunction 变为 nil