Hi there!
Let’s say that:
- I have two metal files A and B containing shaders that I want to keep separate
- I need to call the same helper function (not a shader) from both files
Putting the helper function in a third file and importing it dosen’t works because generates duplicated symbols.
And:
#ifndef thirdFile_metal
#define thirdFile_metal
...//here helper function
#endif
seem don’t work
Any ideas?
Thanks in advance
@quaternionboy You need to declare the function.
For example, this is a complete Metal file with a helper function (B.metal):
#include <metal_stdlib>
using namespace metal;
uint addOne(uint in) {
return in + 1;
}
In a function in another Metal file (A.metal), you use it like this:
uint one = 1;
uint two = addOne(one);
This won’t compile unless you declare the function in A.metal:
uint addOne(uint in);
1 Like