Contents

MDLVertexBufferLayout

A Mdlvertexbufferlayout object describes layout information for a vertex buffer in a Mdlmesh object. A collection of vertex layer objects, vertex attribute objects, and additional information forms a Mdlvertexdescriptor object, which completely describes the layout of vertex buffers for a mesh.

Declaration

class MDLVertexBufferLayout

Overview

A collection of vertex layout objects, vertex attribute objects, and additional information forms a MDLVertexDescriptor object, which completely describes the layout of vertex buffers for a MDLMesh object.

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 vertexBuffers array contains several MDLMeshBuffer objects, and the mesh’s vertexDescriptor object contains a separate MDLVertexBufferLayout object 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 stride together with the format and offset properties 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.

Topics

Working with Layout Information

Initializers

See Also

Managing Mesh Data