What is the correct and most efficient approach of streaming vertex data?

Posted by Martijn Courteaux on Game Development See other posts from Game Development or by Martijn Courteaux
Published on 2013-07-27T07:09:13Z Indexed on 2013/10/25 16:13 UTC
Read the original article Hit count: 273

Filed under:
|

Usually, I do this in my current OpenGL ES project (for iOS):

Initialization:

  • Create two VBO's and one IndexBuffer (since I will use the same indices), same size.
  • Create two VAO's and configure them, both bound to the same Index Buffer.

Each frame:

  1. Choose a VBO/VAO couple. (Different from the previous frame, so I'm alternating.)
  2. Bind that VBO
  3. Upload new data using glBufferSubData(GL_ARRAY_BUFFER, ...).
  4. Bind the VAO
  5. Render my stuff using glDrawElements(GL_***, ...);
  6. Unbind the VAO

However, someone told me to avoid uploading data (step 3) and render immediately the new data (step 5). I should avoid this, because the glDrawElements call will stall until the buffer is effectively uploaded to VRAM. So he suggested to draw all my geometry I uploaded the previous frame and upload in the current frame what will be drawn in the next frame. Thus, everything is rendered with the delay of one frame.

Is this true or am I using the good approach to work with streaming vertex data?

(I do know that the pipeline will stall the other way around. Ie: when you draw and immediately try to change the buffer data. But I'm not doing that, since I implemented double buffering.)

© Game Development or respective owner

Related posts about ios

Related posts about opengl-es