Optimising Vertex and Index Buffers

For optimal performance on PowerVR graphics cores, a mesh with static attribute data should:

  • Use indexed triangle lists

  • Interleave VBO attribute data

  • Not include unused attributes

For optimal vertex shader execution performance, meshes transformed by the same vertex shader, even if compiled into different shader programs, must have the same VBO attribute data layout. On some devices, padding each vertex to 16-byte boundaries may also improve performance.

Generating optimal vertex and index buffers

When rendering large amounts of geometry, sub-optimal vertex and index buffers can affect performance dramatically. For optimal performance, vertex and index buffers need to be sorted so they become cache efficient. The tool PVRGeoPOD can be used for this purpose.

The PVRGeoPOD GUI can be used to work with individual meshes. For batch processing, such as when automatically optimising meshes in a game engine, use the command-line version of PVRGeoPOD, or the meshoptimizer library. This library has many features including cache efficiency optimisation, view-independent overdraw optimisation, vertex fetch optimisation, and vertex quantisation. Please refer to the documentation on GitHub for more instructions.

Interleaving attributes

There are two ways to store vertex data in memory:

  • Data is stored with all the information, position, normals, and so on relevant to a given vertex in a single block. This is followed by all the information relevant to the next vertex.

  • Data can be stored in a series of arrays, each containing all the information of a particular type for each vertex. For example, an array of positions or an array of normals.

The first of these two options is called interleaving. Usually data should be interleaved, as this provides better cache efficiency, and therefore better performance. However, two major caveats exist to this rule:

  • Interleaving should not be used if several meshes share only some vertex attributes from an array of vertex attributes. In this case, separating the shared attributes into their own array may result in better performance, as opposed to duplicating the shared attributes in order to interleave them with the shared ones.

  • Interleaving should also not be used if a single attribute will be updated frequently, outside of the graphics core, while the other attributes remain the same. In this instance, data that will not be updated should be interleaved, while data that will be updated is held in a separate array.