Using VBOs to send data to the GPU

Started by blobjim, April 26, 2016, 01:16:51

Previous topic - Next topic

blobjim

(Sorry for the generic title)

Let's say I have a sandbox game (I don't, this is theoretical) where any objects in the world that are 100m from the player are loaded into the game. To load these objects' models, their data needs to be loaded to VBOs and sent to the GPU. The question is, what format would I use to send that data to the GPU?

Option 1: Put every object's model into a single VBO. The problem is, would this actually be a viable option? If a new object came into the scene, wouldn't the entire VBO have to be resent to the GPU, or is there a way to add a small amount of data to a buffer without resending the entire thing? (or something else I haven't thought of)

Option 2: Store each object in a separate VBO. When an object is loaded by the game, its model is sent to the GPU, and when an object is unloaded by the game, its model is unloaded by the GPU.

(I would probably interleave the data and also have indices in each VBO)

Kai

I don't know about your envisioned game and the number of artists producing digital content for that game, but you are probably not going to have so many different models that such caching scheme would make sense. Let it be 100 different models, each having probably around 100,000 vertices. If we only took 3 floats for position, 3 for normal and 2 floats for texture coordinates, then this would only be a total memory cost of 76 megabytes. Every graphics card can handle that small amount of memory.
Also remember: You do not have to load and unload every instance of every model that is in the visible scene. You only have to load each model data once and display its instances once they become visible. If you constantly load and unload everything then that loading and unloading could possibly become the major bottleneck. But we don't know until we measure.
So as long as you do not have thousands and thousands of different models in your game, then I would probably just load everything right from the start (whether in a single VBO or one VBO each does not really matter, because your bottleneck is probably going to be somewhere else).
But again: We don't know until we measure.

blobjim

Thanks! That makes a lot of sense. No need to unload model data from the graphics card unless the space they take up is larger than the capacity of the graphics card, which is unlikely. :)
Thanks for the reply.

Kai

Just saw that it was a bit of a miscalculation of me. That amount of models with those average number of vertices and 3+3+2 components, is 305 megabytes. Still doable. :)