blit FBO and swapbuffers

I’m doing this:

1 - do all FBO related opengl calls
2 - blit FBO to system FB.
3 - do CPU stuff.
4 - swapbuffers

This works great, however, I’ve noticed that the blitting takes a long time, taking away potential CPU processing.

My theory is this: before the blitting can be executed, all opengl-calls of stage 1 has to be completed. So, that’s not a good thing. That’s why I want to do this:

1- blit previous FBO. (it should be done by now)
2- do all FBO related opengl calls
3 - do CPU stuff.
4 - swapbuffers

Now I would achieve some kind of triple buffering, right? But for some reason this doesn’t work. All I’m getting is a black screen. Any idea why?

And I just solved it, it wasn’t a mystery:
1- blit previous FBO. (it should be done by now)
2- do all FBO related opengl calls
3 - do CPU stuff.
4 - BIND readBuffer 0!
5 - swapbuffers

But still I’m getting some weird results then v-sync is enabled. Does anyone know if there’s a connection between blit, swapbuffers and v-sync and fullscreen if using double buffering? I’m noticing that if I’ve got windowed mode, swapbuffers is taking a long time. In full screen mode, the actual blit command takes a long time.

There is a lot of caching going on with OpenGL calls. Use glFlush after you submitted all OpenGL calls and before you want to do the CPU stuff. Otherwise the swapbuffers command will cause a glFlush AFTER you done your CPU stuff.

It seems blitting the color buffer bit to the system FB waits for a VBLANC. At least it full screen mode. Could there be truth to this?