Hey , i have a Question regarding interleaving VBO’s . Currently i am using glMap to map the buffer and copy the data into the buffer. At the moment i have a struct called VertexData looking something along the lines:
So the VBO layout is something like VertexData[0],VertexData[1],VertexData[n]. My Question is if i am going to notice (or will be there) any significant performance boost if the data layout is something like VertexPositions[0-n],VertexNormals[0-n],VertexUV[0-n] … etc. As i understand both methods are type of interleaving the data in the buffer. Does it matter which layout i use ?
Thanks in advance
Access vertex data in a relatively sequential manner. Modern GPUs cache memory accesses when fetching vertices. As in any memory hierarchy, spatial locality of reference helps maximize hits in the cache, thus reducing bandwidth requirements.
All this is assuming that vertex fetching is actually a measurable bottleneck in your program, of course, but as a general rule the way you are doing it now is preferred.
A counterpoint is that if the vertex data isn’t static, interleaved attributes may increase the cost of uploads, as you’ll effectively have to upload all of the attributes even if only some of them were modified.
A related issue is that manipulating vertex data on the CPU will typically have worse locality with interleaved attributes because iterating over the vertices will end up reading and caching all of the attributes, not just the ones which are actually used.
But for static data, interleaved attributes will typically be better (and at least no worse) than using a separate region for each attribute.