Proper use of VAO

Started by
16 comments, last by B_old 10 years, 7 months ago

I wouldn't really recommend it, but it is possible, yes. Even so you do need at least one VAO, so "entirely optional" isn't entirely true.

Would you say, that the proper OpenGL style is to have two VAO per model for instance? One for the lighting/g-buffer passe(s) and another for shadow passes.

In that case I don't understand the benefit of the 4.3 glBindVertexBuffer(), because it now seems it should still happen in a initialization phase.

Why would you need two different VAOs for that? Just don't use the normal information in the shadow pass shaders. If you maintain consistent attribute locations between shaders, a single VAO per mesh should do, IMO.

Advertisement

I wouldn't really recommend it, but it is possible, yes. Even so you do need at least one VAO, so "entirely optional" isn't entirely true.

Well id do it, Valve do it, so it seems (at least on the surface) to be viable. Despite that, I do find VAOs useful as a way to avoid having to track lots of state, but I'm still looking forward to GL_ARB_vertex_attrib_binding being more widely available.

It is obviously doable/viable but why track all that state yourself, when the API can do it for you (which may have the side effect of being more efficient)?

Why would you need two different VAOs for that? Just don't use the normal information in the shadow pass shaders. If you maintain consistent attribute locations between shaders, a single VAO per mesh should do, IMO.

But wouldn't you waste bandwidth that way?

Well id do it, Valve do it, so it seems (at least on the surface) to be viable. Despite that, I do find VAOs useful as a way to avoid having to track lots of state, but I'm still looking forward to GL_ARB_vertex_attrib_binding being more widely available.

Did you get this info from this presentation about porting the source engine to OpenGL? Because I did not quite understand the part about VAOs.

Why would you need two different VAOs for that? Just don't use the normal information in the shadow pass shaders. If you maintain consistent attribute locations between shaders, a single VAO per mesh should do, IMO.

But wouldn't you waste bandwidth that way?

Unlikely. As the driver knows which attributes are actually used by the shader and the shader has no reason to access that memory. Performance will not be optimal if your attributes are interleaved, but unbinding the interleaved attributes won't change that. In any case, if you need performance: profile.

Unlikely. As the driver knows which attributes are actually used by the shader and the shader has no reason to access that memory. Performance will not be optimal if your attributes are interleaved, but unbinding the interleaved attributes won't change that. In any case, if you need performance: profile.

Even if the data is not accessed it still takes up bandwidth if the data is interleaved, right?

But if you only partly interleave the vertex data and partly keep it in separate streams you can potentially skip a stream thus saving bandwidth.

Unlikely. As the driver knows which attributes are actually used by the shader and the shader has no reason to access that memory. Performance will not be optimal if your attributes are interleaved, but unbinding the interleaved attributes won't change that. In any case, if you need performance: profile.

Even if the data is not accessed it still takes up bandwidth if the data is interleaved, right?

But if you only partly interleave the vertex data and partly keep it in separate streams you can potentially skip a stream thus saving bandwidth.

But at the higher cost of drawing non-interleaved verts.

This is one that there is no "correct in every case" answer to. One really needs to profile and find which option is best for one's own case, not forgetting to watch out for factors that you can't directly measure (i.e. bandwidth cost can be measured but the higher cost of drawing non-interleaved data is not immediately obvious).

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

But at the higher cost of drawing non-interleaved verts.

This is one that there is no "correct in every case" answer to. One really needs to profile and find which option is best for one's own case, not forgetting to watch out for factors that you can't directly measure (i.e. bandwidth cost can be measured but the higher cost of drawing non-interleaved data is not immediately obvious).

Fair enough.

Could you please elaborate more on Valve's VAO usage? Are you referring to the presentation I linked?

This topic is closed to new replies.

Advertisement