Jump to content
  • Advertisement
Sign in to follow this  
h3xl3r

OpenGL OpenGL 2.1 / ES 2 streaming vertex buffer update performance

This topic is 1674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Good day!

This is something I've been struggling with for a while now:

I am streaming a lot of dynamic vertex data in a OpenGL 2.1/OpenGL ES 2 compatible renderer that is staying away from fixed function completley (in desktop GL 2.1 where there would still be the option). Now, as I have cpu-side state management I can swap on the fly between implementations using either Vertex Arrays or GPU-buffers and profile the separate paths/methods.

All is well, except that there is no way it seems I can get the vertex buffer updates using proper GL buffer objects as fast as the vertex array way, though theoretically it should come down to exactly about the same actions in the driver if I think about it:

- vertex array:
copy all the data from cpu memory to driver in glVertexAttribPointer

- vertex buffer:
copy all the data from cpu memory in glBufferSubData

I know this is of course rather dependent on the driver as well, but between a rather low-spec desktop machine and multiple versions of iPads, there is no way I can get the same times. The GPU buffer always loses.

I've been of course looking on the web and I tried everything I saw that I actually have available in the GL2-class spec (double/triple buffer, invalidating with null data first, etc.) to no avail. Also I am soon going to start the GL3/ES3 version which removes the vertex array option altogether, so this is going to have to be solved.

Any ideas? Appreciate all hints really! Maybe something extension based that isn't too badly supported?

Edit:

Just want to mention I also tried various ways to "Map/MapRange", but none of the new fancy options to these are available to (vanilla) GL2/ES2 and (especially on the pads) these also always came in late in the profiling. I am obviously causing a sync somewhere but going double or triple and invalidation tricks just don't seem to make a difference so I am a bit lost for ideas smile.png

Edited by h3xl3r

Share this post


Link to post
Share on other sites
Advertisement

I've found it's often faster to use glBufferData to overwrite the entire buffer rather than use glBufferSubData, even if only part of the buffer actually needs to be updated. If you have lots of data that can be updated, divide it into multiple buffers of for example 256 vertices per buffer and try to use a method that updates as few buffers as possible each frame.

Share this post


Link to post
Share on other sites

Thank you! That's exactly the sort of experience I wanted to hear about!

 

I am guessing you also mean to combine the glBufferData with "discarding" the "old" buffer before filling it each frame by buffering NULL data first with the same parameters? Seems to be an sort of "accepted" hint for the vendor driver to hand out a new memory region instead of using an "in-flight" buffer and causing a sync.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!