Sign in to follow this  
noodleBowl

Bad Practice? Multiple VAOs

Recommended Posts

I'm rounding out a particle emitter I'm creating, which uses transform feedback. As you can guess, I have a update method to update my particles and then a render method to actually show them on the screen.

To avoid floating point issues, in my transform feedback I'm using GL_POINTS and then out 4 values per input.
E.G Update code:

//CPU side of things
glBeginTransformfeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, particleCount);
glEndTransformfeedback();

//In my Shader code
//My Shader Inputs/Outputs
in vec2 positionIN;
out vec2 position0OUT;
out vec2 position1OUT;
out vec2 position2OUT;
out vec2 position3OUT;
When I hit the render method I use my buffer that I just wrote to, I am Ping-Ponging the buffers too, to get the particles on the screen. Where I use glDrawElements and GL_TRIANGLES, so I'm basically expanding the points from the transform feedback into a quad.
//CPU side of things
glBeginTransformfeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, particleCount);
glEndTransformfeedback();

//In my Shader code
//My Shader Inputs/Outputs
in vec2 positionIN;
out vec2 position0OUT;
out vec2 position1OUT;
out vec2 position2OUT;
out vec2 position3OUT;

Here is where my question comes in. In order for this to happen I believe I need 4 VAOs.

1 VAO for the way the data should be interpenetrated in the update method. This VAO skips redundant data since I want avoid recalculating the same information over and over.

1 VAO for the way the data should be interpenetrated in the render method. Does not skip data and interprets 1 GL_POINT from the transform feedback as a quad's vertex.

A additional VAO for each of the above because I need to Ping-Pong my VBO buffers.


So am I creating a situation for myself where I'm falling into a bad practice?
Is this too many VAOs for one object, where there is a high chance that there will multiple instances of this object?

Would it be better to just bind the buffer I need?

//Example: code in update mehtod
glBindVertexArray(renderVAO)
glBindBuffer(GL_ARRAY_BUFFER, vbos[currentVBO]);

/* Other code for transform feedback */

Share this post


Link to post
Share on other sites

VAO are not heavyweight, so if they simplify your approach I would recommend using them. In this case, I don't see why not. If you are using GL 4.2+ ( methinks) you could use the vertex attribute binding functionality to do the same thing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this