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

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.)

• What you can do is upload the buffer data as early in the frame as possible, and render the buffer as late in the frame as possible, so that there is some CPU-bound work in between the two operations. This will remove the 1-frame latency and stop wasting time if the GPU takes a while. Jul 27 '13 at 7:42
• There's ultimately no way to know, since OpenGL ES runs on an extremely wide variety of hardware. Jul 27 '13 at 8:54
• @NicolBolas: What do you do in general. This way or not? Jul 27 '13 at 10:16