一个来自多个.metal文件的默认MTLLibrary(计算内核和CIKernel实现)?

在将自定义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"

将名称间隔设置为metalcoreimage可以防止计算内核在默认库中显示为可用函数。

找到了这个SO答案,建议建立单独的库:

Metal: vertexFunction defined in .metal file becomes nil once setting Compiler and Linker Options for MSL cikernel

true430 回答:一个来自多个.metal文件的默认MTLLibrary(计算内核和CIKernel实现)?

您现在不能使用默认的Metal构建管道将包含Core Image内核的多个.metal文件编译到一个库中。设置.air标志时,链接器不允许将多个.metallib文件合并为一个-cikernel

您要么必须将所有内核放入一个.metal文件中,要么使用我在上面链接到的答案中发布的解决方案。

本文链接:https://www.f2er.com/3148773.html

大家都在问