What does it mean to interleave vertex data?

What does it mean to interleave vertex data?

When it comes to storing vertex data, there’s basically two different schools of thought. One says interleave the attributes, that is, store “fat” vertices which contain position, normal, UV coordinates and so on together. I’ll refer to this as interleaved storage, as it interleaves all vertex attributes in memory.

Can a vertex be interleaved with a null buffer?

With interleaved data, it’s hard to turn off an attribute, as the vertex layout needs to be adjusted. With de-interleaved data, it’s as easy as binding a null buffer or using a shader permutation which just skips the channel. One point for de-interleaved data.

What can you do with de interleaved data?

With de-interleaved data, it’s as easy as binding a null buffer or using a shader permutation which just skips the channel. One point for de-interleaved data. The next use case is position-only rendering, which is very common for shadow maps. Again, de-interleaved data wins here, due to cache efficiency.

What should the vertex format be in OpenGL?

The optimal layout depends on the specific GPU and driver (plus OpenGL implementation), but there are some things that are just generally good ideas. When rendering multiple different meshes, try to organize your data so that as many meshes as possible reside in the same buffer object with the same vertex format.

How are vertex data and descriptors used in metal?

Vertex data can be supplied such that all data for a single vertex is contiguous (interleaved), or all instances of a particular attribute are contiguous (non-interleaved). Fortunately, Metal gives us a lot of flexibility when it comes to how we arrange our data in memory.

How to set an offset in a vertex descriptor?

In addition to telling the command encoder which argument buffer slot to set, you can provide an offset, which is the number of bytes from the beginning of the buffer where data should start to be read from.