Sign in to follow this  
resle

Single rich vertex or multiple buffers?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this