Reputation: 299
Is there any performance difference between using one vao and one buffer ( VAO will catch glVertexAttribPointer calls to one VBO ) , and using one vao and multiple buffers ( VAO will catch glVertexAttribPointer calls to different VBO's ). ?
In the two situations, I'll have to bind the VAO once before drawing, but will this binding call's execution time change ?
Upvotes: 2
Views: 1905
Reputation: 572
In short, yes, but in reality, the execution time is so small that it's negligible. You are going to usually need multiple vertex buffers if you're making any dynamic scene. Putting everything in one buffer will only serve to complicate things. Remember the maxim: never optimise early.
Upvotes: 6
Reputation: 8317
In your question you assume you will use only VAOs. In recent OpenGL versions VAOs are mandatory, but you can live without VAOs (just bind 1 VAO at initialization time and then you forget about it: this solution is widely used).
Is faster using a VAO for each VBO, or calling glVertexAttribPointer for each VBO? This is driver dependent. The risk you incurr when optimizing for one driver is to make things slower for another driver.
Is faster using many VBOs or few VBOs (it is not dependent on your VAO)? It depends on your bottleneck:
Increasing number of VBOs may help to do frustum culling or occlusion culling effectively reducing the workload for the GPU (less overdraw and fewer primitives to process), but too many VBOs may result in worst case in much more drawcalls wich would slow down things anyway.
There is no better solution, it all depends on your problem and profiling.
Upvotes: -1
Reputation: 68847
Yes it is going to be slower. Why? Because the rendering process now has to access data from different VBO's in order to have one the data for one vertex. The data is spread around in memory, whereas if everything is in one VBO, your data is "interleaved". This causes to have faster memory access times.
Upvotes: 2
Reputation: 578
In theory if you use one VBO then you are not causing a lot of cache miss, but if you have a lot of verticies each have position, normal, uv, color, tangent, ... then the driver may decide to store the array in the client memory, so in this case it would make sense to use mutiple VBOs. personnaly i use multiple VBOs no matter what the size is.
Upvotes: 0