Metal seems to provide two very different ways to access vertex data in your vertex shader. You can:
- Create an
MTLVertexDescriptorobject, which describes vertex shader inputs, including per-vertex, per-instance, and constant data of basically any Metal-supported primitive type, and compile it into an
MTLRenderPipelineState. The inputs you describe map to indexed attributes in a single
struct, which you declare as the
[[stage_in]]argument of a vertex function.
- Use the
[[instance_id]]inputs to a vertex function as indices into user-defined buffers of arbitrary data.
The first option is very reminiscent of a classical VBO-centric rendering pipeline, while the second option is a very compute-shader-like approach. Personally, I prefer the second approach, but I'm concerned as to whether it offers the same performance as the first.