Archived

This topic is now archived and is closed to further replies.

BlitzKrieg

Number of Vertex buffers VS performance

Recommended Posts

BlitzKrieg    122
I read that increased numbers of vertex buffers can hamper performannce, and was wondering how drastic it is. Would having a seperate vertex buffer for each model be ok? Or should i try and put everything into a single vertex buffer. Thanks

Share this post


Link to post
Share on other sites
Fidelio_    122
quote:
Original post by BlitzKrieg
I read that increased numbers of vertex buffers can hamper performannce, and was wondering how drastic it is. Would having a seperate vertex buffer for each model be ok? Or should i try and put everything into a single vertex buffer.
Thanks


It depends. Switching buffers gives a small penalty, but the advantage is that as soon you draw the first one, the card starts working while you prepare the next buffers.

But if you use one giant buffer and fill it every frame, you shouldn''t spend too much time processing it. If you take 30 ms sorting 5000 triangles, sort them on texture and then front to back, your game will never run faster than 30 fps.

In the one-buffer variant, you start work on the buffer, the card sits there doing nothing, and in the end it gets the whole buffer and draws it, then your cpu does nothing. It doesn''t take advantage of the fact that the CPU and GPU are separate fast processors capable of running in parallel at all.

Basically if you draw 100 static trees, it''s better to transform the trees to world space into one big tree buffer and draw that, instead of 100 calls to drawprimitive for one tree each. This is because this can happen during initialization, and the buffer stays the same each frame.

But if you have 20 models of players that change position and are animated each frame, just draw each player using a separate buffer. It would be too expensive to transform and copy everything into one big buffer.

A big buffer full of objects that can be created during init: yes, a big buffer that has to be created from scratch every frame: no.

Share this post


Link to post
Share on other sites