Instanced vertex buffers
Both OpenGL ES and Vulkan have support for instanced drawing. Instanced drawing uses attribute instance divisors to divide a buffer to locate the data for each instance. There are some hardware limitations which determine the optimal usage of instanced vertex buffers.
You must understand the following concepts:
- Instance divisors.
- Instanced vertex buffers.
How to optimize the use of vertex buffers
Try using the following optimization steps:
- Use a single interleaved vertex buffer for all instance data.
- Use instanced attributes to work around limitation of 16KB uniform buffers.
- Use a number of vertices per instance that are a power-of-two.
- Prefer indexed lookups using
gl_InstanceIDinto uniform buffers or shader storage buffers. Rather than per-instance attribute data.
Instanced vertex buffer steps to avoid
Do not use more than one instanced vertex buffer per draw call.
The negative impacts of an inefficient instanced vertex buffer
If the vertex buffer is not properly optimized, then you can expect a reduced performance on all impacted instanced draw calls.