Archived

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

TheAIDSVirus

Many VBs vs. Lock()

Recommended Posts

Often the answer I see to questions like these is, "It depends." So, let''s simulate a situation. Let''s say I''m building a game that''s going to have many objects, for sake of example 100, and each will have its own orientation. In other words, each could essentially have its own world matrix. Would it be better to put all of the vertices into one dynamic vertex buffer and Lock(), move vertices, and Unlock() each frame or should each object have its own VB, own DrawPrimitive() call, and own world matrix? Also, when a VB grows rather large, say 1000 vertices, how much of a performance hit is locking the entire VB? ---- AIDS

Share this post


Link to post
Share on other sites
Well first off I might have misunderstood your post but when you say move the vertices in the dynamic buffer I suppose that you''re meaning that you''ll pre-transform the vertices? If that''s so don''t... I''ll try to give a general idea of how I work... If you have static objects, as seems to be the case here, you should have individiual vertex buffers for individual objects, say if you have a tree and a house it should have it''s own VB and matrix... however dynamic objects that requires manual transformations of the vertices... i.e. not using matrices should be used with dynamic buffers. I should probably add that if you have the same static object twice you should of course reuse your vertex buffer.

/ Fredrik

Share this post


Link to post
Share on other sites
I''m sorry, I should have made that clearer. All of the objects are dynamic. For instance, say all 100 of them are vehicles currently in motion.

What I meant by move the vertices is Lock(), fill the vertex buffer with vertices that may have new values, Unlock(). I''m assuming that would be pre-transforming vertices. Why would I not want to do that?

----
AIDS

Share this post


Link to post
Share on other sites
Well what I mean when saying that you shouldn''t pre transform is that you shouldn''t manually move for example move all your vertices 100units + on x axis for example. If you''re doing animations using interpolation and stuff you more or less have to use manual transformations or vertex shaders (which is faster). I suppose that you could go either way in how many buffers you''d use but I''d suppose that using one buffer for type of different FVF you have might be a good idea and then group all your rendering calls that uses that FVF and so on... I''m not sure in which order you should group them what''s more expensive texture change or vertex buffer change... I haven''t timed anything but you should at least keep in mind those two as well as you should remember to minimize state changes as well..

Regards Fredrik

Share this post


Link to post
Share on other sites