PDA

View Full Version : blit FBO and swapbuffers



jaketehsnake
08-30-2015, 09:43 AM
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?

jaketehsnake
08-30-2015, 09:48 AM
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

jaketehsnake
08-30-2015, 10:06 AM
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.

Osbios
08-30-2015, 02:44 PM
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.

jaketehsnake
08-30-2015, 11:30 PM
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?