Reputation: 33
In migrating custom Core Image filter kernels to Metal Shading Language, I encountered an error with building the default Metal library (default.metallib):
metallib: error: exactly one input file required
I was under the impression these could be in separate .metal files. Attempting to merge them into one file leads to this error:
Metal library creation failed: Error Domain=MTLLibraryErrorDomain Code=3 "Filters module must contain no vertex/fragment/kernel functions but contains 1 kernel function"
Namespacing to metal
and to coreimage
prevent the compute kernel from showing up as an available function in the default library.
Found this SO answer, which recommends building separate libraries:
Upvotes: 0
Views: 1246
Reputation: 573
You may create multiple Foo.metal
and Bar.metal
files.
Just don't add them as linker targets.
Instead #include "Foo.metal"
and #include "Bar.metal"
in a Main.metal
file.
And only add the Main.metal
file as linker target.
That way there is only one .metal
file, which includes all the other .metal
files. Simple.
Therefore the content of the Main.metal
file may very simply look like:
#include "Foo.metal"
#include "Bar.metal"
Upvotes: 1
Reputation: 10408
You can’t use the default Metal build pipeline for compiling multiple .metal
files containing Core Image kernels into one library right now. The linker doesn’t allow merging multiple .air
files into one .metallib
when setting the -cikernel
flag.
You either have to put all your kernels into one .metal
file or use the solution I posted in the answer you linked to above.
Upvotes: 0