Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you need a VAO for each VBO?

Currently, I have a collection of RenderObject classes which contains a texture, a VAO and a VBO. Drawing thousands of these objects incurs a performance penalty due to all the state switching and calls to glDrawArrays with small numbers of triangles.

So now I'm going to change my implementation so that I create a series of 1MiB VBOs (start with one, once it gets full, create a second 1MiB VBO and continue to fill that). Do I need a separate VAO for each VBO? The VBO already uses interleaved vertex data, so I'm not talking about using multiple VBOs for vertices, normals, texture coords, etc.

like image 818
Mark Ingram Avatar asked Jul 11 '13 15:07

Mark Ingram


1 Answers

I think there may be some confusion. Vertex Attribs refers to the number of per vertex elements you can pass in with a single vertex (normals would be one, UVs another, etc). In your implementation, that is limited to 16 which you are most likely not going to exceed.

VAOs store the state information required to issue a single draw call. This includes storing which VBOs need to be bound for that call. Given that each VBO must be drawn in it's own separate draw call I would also think you need a VAO to store setup info for each.

Here is a good explanation:

http://ogldev.atspace.co.uk/www/tutorial32/tutorial32.html

like image 93
Justin Meiners Avatar answered Oct 09 '22 23:10

Justin Meiners