Swift struct to Metal?

Hello,

I begin / test a little with Swift and Metal (only for compute shaders). All I see (in samples) is working with primitive datatypes but I work with struct or classes. Can I and How move data between Swift and Metal in a struct or in other words declare a kernel function with struct and used from Swift? Is somewhere an example?

I want to compute with 100+ input parameters and not much less result values for maybe more than hundred thousand times.

Thanks
Sebastian

This is more of a question for the Metal section on the Apple dev forums, but the quick answer is to define your struct type in a .h file, which can be imported by the Metal shader language, [Obj-]C[++], and Swift.

3 Likes