I use glVertexAttribPointer to load my vertex data each frame(~242kb) it takes about 8ms.
Will I gain any performance increase by employing VBO?
I think the answer is NO since I still have to load whole data.
The only way it can get performance gain is if glBufferData loads data faster than glVertexAttribPointer
Is this is the case?
Add a comment
|
1 Answer
If you have static vertex data then VBO has very clear performance advantage because data is kept in GPU accessible memory.
When you use glVertexAttribPointer without VBOs driver has to copy your vertex data to GPU accessible memory every frame. There is two reason why client arrays require copy
- GPU doesn't have access to all your memory. It can only see pages that GPU driver has mapped to it.
- OpenGL promises that you are free to change client array memory after glDraw* returns but GPU rendering happens asynchronously after return.
VBO data is allocated by driver and mapped to GPU. That avoids copies if you keep same vertex data. Updates also can be optimized if you only update part of vertex array with glBufferSubData. (eg. only update texture coordinates without vertex position update)
11 Comments
undefined
The problem is my vertex data could change significantly(mostly by changes in order of drawing) >That avoids copies if you keep same vertex data.<br/> Does this mean that glBufferData doesn't actually copy data to gpu memory and I can modify my vertex data on client side and then call glBufferData which will be extra fast?
Pauli Nieminen
@undefined No. You will have to do copy at some point when ever you move data from software memory to GPU memory. But glBufferSubData and glMapBuffer can let your update less. But changes in drawing order shouldn't change vertex data. You can use indeces with glDrawElements to tell about vertex order. Modern GPU rendering basic idea is use static data as much as possible and let shaders transform that to dynamic cotent with minimal dynamic input (minimal dynamic input can be uniforms only or a few vertex attributes). Every time data changes you risk copies, allocations and pipeline stalls.
undefined
What is glMapBuffer?There is no such method inside GLES20 class.I think this is what I need to avoid unecessary copying of vertex data
Pauli Nieminen
stackoverflow.com/questions/30641095/… is extension in es2. But remember thatr glMapBuffer risks pipeline stalls because mapping has to wait GPU complete reading (or writing to) from the buffer before driver can give pointer for you. If you really need dynamic vertex data then you might be better of using two VBOs for same data in round robin fashion.
undefined
Thanks but this thread is for ios.Is there way to use it on android?
|