Strange latency when updating dynamic VBO with glUnmapBuffer()

Started by
-1 comments, last by Aressera 8 years, 5 months ago

I use a custom immediate-mode renderer for things like GUI, debug drawing. This works a lot like the old OpenGL immediate mode. To render something, the operations that I am doing are:

  1. orphan the previous buffer memory with glBufferData( NULL ), usage = GL_DYNAMIC_DRAW;
  2. map vertex buffers for position, normal, uv, etc with glMapBuffer();
  3. write vertex data directly to the mapped buffer pointers.
  4. unmap vertex buffers with glUnmapBuffer();
  5. render the data in the buffers.

This works pretty well in most cases and is also pretty fast. However, I am getting a strange artifact when I render dynamic vertex data (e.g. frustum of a rotating camera). The rendered output seems to lag behind the rest of my scene by a few frames. i.e. on frame (n) it seems to render the scene from frame (n) combined with the immediate mode output from frame (n-3). This looks like really bad jitter when the motion is fast.

The only thing I can think that is causing this is that there is some significant latency between when I call glUnmapBuffer() and when the vertex buffers are actually used for rendering. My understanding that glUnmapBuffer() should block the caller until the vertex data has been copied to the GPU, but this doesn't seem to be the case.

If I can't get it to work without these artifacts I will try next to just build the vertex buffers in CPU memory and then glBufferData() to copy the data to the buffers.

Any ideas as to the cause/fix of this problem?

This topic is closed to new replies.

Advertisement