0
\$\begingroup\$

I was wondering if I could assume that all buffer related GPU operations such as:

  • glDrawElements
  • glBufferData
  • glSubBufferData
  • glUnmapBuffer

are guaranteed to be completed after swap buffer is performed (i.e. frame is finished) assuming vsync is on.

I'm confused as I've come across implementations of vertex streaming techniques such as rond robin vbo which imply that a vbo could still be in use during the next frame.

What I basically want to do is stream vertices through glMapBufferRange with GL_UNSYNCHRONIZED_BIT, managing the correct ranges myself so that writes and reads never overlap. This would work very well if I could just assume synchronization and reset the stream range index at the end of the frame.

In other words, does swap buffer with vsynch guarantee synchronization?

\$\endgroup\$
2
\$\begingroup\$

SwapBuffers and vsync aren't part of OpenGL so this behaviour would be implementation-dependent (or more correctly, windowing system dependent).

If you want to guarantee synchronisation then use glFinish, it's what it's for. Alternatively issue a GL command that can't run until synchronisation happens - anything that needs to read back from the GPU is normally a good bet.

For your specific use case, the usage pattern is known in D3D land as no-overwrite/discard, and has been well-known there for 20-odd years. Just append new data to previously-written data, and if the buffer fills orphan it and begin again at the start of the buffer.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.