VBOs questions

I’m currently implementing VBOs into my engine and some things are still unclear to me even after reading a lot of material on the net.

  1. Allmost all whitepapers I read said that you should reduce number of batchs/frame as mutch as possible becouse it overloads CPU, its also said that a batch is a call like glDrawArrays, glDrawElements, etc… but when I use VBO with a static data ( GL_STATIC_DRAW ) and draw a geometry with glDrawElements is it still a batch or not? Usualy no data are transfered from comuputer to g. card so CPU shouldnt perform any activity…

  2. In all demos about VBOs I saw construction like this : bindBuffer, setXXPointer… draw, unbindBuffer. I have also read that glVertexPointer() is an expensive call when using VBOs. However do I really need to set glVertexPointer ( and other xxPointers too ) before each draw call? I can imagine a situation when I have many VBOs but offsets of vertex data,normal data, etc are same for all of them so my idea is just to implement some simple cache where I will remember last offsets and change the glXXPointer only if its necessary. I have tested it and it worked but im not sure if its a correct approach and if it really provides any performance benefit.

thanks for answers :slight_smile:

I think you shouldn’t rely on this to work. AFAIK an implementation may choose to change the currently used VBO only when you call glVertexPointer. So if you don’t, you may end up using the previous bound VBO.

Regarding the CPU usage: The CPU has to send the drawing commands to the GPU. Of course it doesn’t need to transmit vertex data, that’s why the batch count matters more that the batch size.

thanks. It seems you are right. When I did some more tests the trick with storing offset did not work so you really have to set it manualy before each draw call ( it works only if you are using the same VBO for drawing again and again … ).

About the Batchs - you are probably right, what confused me was the sentence in one whitepapers from NVidia ( Batch, Batch, Batch ) where is said that batch is every DrawIndexedPrimitiveCall() ( DirectX ) which sends N number of triangles to GPU … but buffers dont send any triangles to GPU so i was confused… well I’m probably reading too mutch and programming too little :slight_smile: