Metal seems to provide two very different ways to access vertex data in your vertex shader. You can:
- Create an
MTLVertexDescriptor
object, which describes vertex shader inputs, including per-vertex, per-instance, and constant data of basically any Metal-supported primitive type, and compile it into anMTLRenderPipelineState
. The inputs you describe map to indexed attributes in a singlestruct
, which you declare as the[[stage_in]]
argument of a vertex function.
OR
- Use the
[[vertex_id]]
and[[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.