- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- Model I/O
A collection of vertex layout objects, vertex attribute objects, and additional information forms a
MDLVertex object, which completely describes the layout of vertex buffers for a
A mesh may store vertex data in either a structure of arrays model, where data for each vertex attribute (such as vertex position or surface normal) lies in a separate vertex buffer, or in an array of structures model, where multiple vertex attributes share the same buffer.
In a structure of arrays, the mesh’s
vertexarray contains several
MDLMeshobjects, and the mesh’s
vertexobject contains a separate
MDLVertexobject for each buffer.
In an array of structures, the mesh contains a single vertex buffer, and its descriptor contains a single vertex buffer layout object. To identify which bytes in the buffer refer to which vertices and vertex attributes, use the layout’s
stridetogether with the
offsetproperties of the descriptor’s vertex attributes.
Because there is only one stride per buffer:
If a buffer uses interleaved layout, it can contain attributes of different sizes, and the stride is the sum of their sizes (plus padding).
If a buffer uses non-interleaved layout (that is, it stores all the data for one attribute, then all the data for another, and so on), each attribute in the buffer must have the same size as the others.