• Advertisement
Sign in to follow this  

Single rich vertex or multiple buffers?

This topic is 3392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I've read that in order to optimize Vertex Buffers' performance, one should align his vertex size to 32 bytes. So isn't really any better (performance-wise) to split vertex data into more separate buffers to avoid redundancy? For example: buffer #1 : texture coords u,v buffer #2 : face indices a,b,c buffers #3..#N: vertex positions x,y,z

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by resle
Hi,
I've read that in order to optimize Vertex Buffers' performance, one should align his vertex size to 32 bytes.

So isn't really any better (performance-wise) to split vertex data into more separate buffers to avoid redundancy? For example:

buffer #1 : texture coords u,v
buffer #2 : face indices a,b,c
buffers #3..#N: vertex positions x,y,z
32 bytes is one GPU cache line. When the GPU reads from the vertex buffer, it has to read a multiple of one cache line, so a multiple of 32 bytes. If your vertex struct is 30 bytes, and your index buffer is arranged in a particularly suboptimal way, you might see some performance increase from moving to a 32-byte vertex struct.

In general, it's not going to make much of a difference, you should profile first, then worry about it. You're likely to get more of an overhead from using multiple buffers, because the GPU has to read from multiple memory locations (meaning multiple reads) to construct a single vertex.

Share this post


Link to post
Share on other sites
Thanks for the clarification. Useless to say the downside is that doing this one 's actually wasting memory but something has to be wasted here or there and probably memory is what abounds the most.

Share this post


Link to post
Share on other sites
Quote:
Original post by resle
Thanks for the clarification. Useless to say the downside is that doing this one 's actually wasting memory but something has to be wasted here or there and probably memory is what abounds the most.
Well, that's exactly what programming is about - gaining performance but requiring more memory, or vice versa.
As I said, profile first, optimise later.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement