Opengl asyncronous PBOs read

280 views Asked by At

I am developing an application that needs to read back the whole frame from the openGL frame buffer.
In order to improve the performance, I'm using asynchronous glReadPixels with multiple PBOs:

glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbos[m_index]);
glReadPixels(0, 0, GLL_WINDOW_SIZE, GLL_WINDOW_SIZE, GL_RED, GL_UNSIGNED_BYTE, 0);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

After reading some tutorials, I do the following (e.g. with 2 PBOs):

  1. draw frame N (glDrawArrays)
  2. start asynchronous read of PBO N from buffer (see above)
  3. draw frame N+1 (glDrawArrays)
  4. start asynchronous read of PBO N+1 from buffer (see above)
  5. sync PBO read N (glMapBuffer)
  6. process N
  7. draw frame N+2 (glDrawArrays)
  8. ...

This seems to work correctly, but I have some concerns regarding the pipeline.
Typically, the drawing operation on frame N+1 (3) is done before the completion of the asynchronous reading of the frame N (2).
Is the frame buffer overwritten by the drawing operation?
If the glReadPixels runs asynchronously (2), is the frame N corrupted by this overwrite?

0

There are 0 answers