Advertisement

When to use VBO?

Started by September 29, 2003 04:57 PM
3 comments, last by Thor82 21 years, 5 months ago
i read the tutorial about VBO and i find it really useful and important,but i have some unclear things: with VBO you can put vertices/textures coords in the graphic memory,but 1) how/when to delete them? 2) how is possible to use them in a right way? i mean: it''s better hold in memory N objects forever (and at the end delete them) or hold N objects use them when needed,deallocate them, load other objects use them etc etc? thanks since now
There aren''''t problems that can''''t be solved with a gun...
There aren''t problems that can''t be solved with a gun...
1) You can delete them when you don''t need them any more. You can store any of the vertex data in VBO, including indices. The driver manages the buffers to make sure they aren''t lost and are in video memory as much as possible. Of course theres plenty you can do to assist the driver to prevent thrashing (i.e. constant loading/unloading from the card).

2) This is a very broad subject and highly depends on what the vertices store and how many there are. Creating buffers is potentially a slow operation, as is switching buffers so you should minimize this.

My suggestion is to make it work for your system, then worry if it is the ''right way''. You might well find that you aren''t worrying the card with the amount of data you are using so you don''t need to have a perfect system. You can try browsing through the Graphics Programming and Theory forum archive, there have been many threads (quite a few involving Yann ) on optimizing for graphics cards.
Advertisement
1) generally at the end of the program, or the end of the "level" if you can be sure that a graphics object will not be used before a long time (typically, when the player finishes a level in a game).

2) it depends on your application : if you want it to start quickly, choose the latter. if you want the application to run smoothly without lag when data is being uploaded to graphics card,choose the other.

Also, keep in mind that if your graphics memory is full, chances are that the driver still accepts buffer object allocation, but may perform it on the software side, just like traditional vertex arrays. And even clever drivers will be able to detect which objects are used most so that they are uploaded to the graphics card in priority and objects used least will be downloaded and kept on the software side.
i have a scheme on how to load thing at run time, like a BIG tilebased world, only that tiles can be reloaded if the player comes back for example (not so easy,but to give the idea)so load/unload must be made at runtime,without "levels" but in this case it should be better load in the video memory objects in sight instead of the terrain, because it shouldn''t be really too much detailed... i dont know... -_-''



There aren''''t problems that can''''t be solved with a gun...
There aren''t problems that can''t be solved with a gun...
Then I recommend to delete objects when they become out of interest, for instance compute a "distance" from the objects to the camera and delete objects that are too far.

As a side note, uploading vertex arrays into graphics memory is very fast, it''s just like rendering the object once with "traditional" vertex arrays. I mean, you shouldn''t see any significant drop when you upload your vertex buffer objects in realtime. At worst there will be a minor slowdown just as if the scene was rendered twice (you''ll drop from 25fps to 24fps for one second), at best you won''t even notice the difference.

This topic is closed to new replies.

Advertisement