PDA

View Full Version : Fastest way to copy data for FBO / backbuffer?



Leadwerks
08-03-2008, 06:09 PM
I need to copy data either from one FBO to another, or from the FBO to the back buffer, or vice-versa. What is the preferred way of doing this? It would be nice if it treated the back buffer and FBOs the same.

zed
08-03-2008, 09:32 PM
GL_EXT_framebuffer_blit, though has some caveats, check the spec
though if your FBO has a texture attached then perhaps a fullscreen texture (but I assume this will be slower)

Leadwerks
08-16-2008, 04:49 PM
Thanks. It seems to be supported on all the SM3 hardware I tried.

Leadwerks
08-16-2008, 09:22 PM
If I have an FBO with multiple color attachments, can I blit just one color attachment?

Chris Lux
08-17-2008, 08:05 AM
If I have an FBO with multiple color attachments, can I blit just one color attachment?



BindFramebufferEXT(READ_FRAMEBUFFER_EXT, 2);
BindFramebufferEXT(DRAW_FRAMEBUFFER_EXT, 1);

glReadBuffer(GL_COLOR_ATTACHMENT0 + x);

BlitFramebufferEXT(0, 0, 640, 480,
0, 0, 640, 480,
GL_COLOR_BUFFER_BIT,
GL_NEAREST);

Leadwerks
08-17-2008, 10:42 AM
Brilliant! :D

Thank you.

Leadwerks
08-17-2008, 11:56 AM
For the benefit of those reading this, you also need to specify the color attachment to write to:

BindFramebufferEXT(READ_FRAMEBUFFER_EXT, 2);
BindFramebufferEXT(DRAW_FRAMEBUFFER_EXT, 1);

glReadBuffer(GL_COLOR_ATTACHMENT0 + x);
glDrawBuffer(GL_COLOR_ATTACHMENT0 + x);

BlitFramebufferEXT(0, 0, 640, 480,
0, 0, 640, 480,
GL_COLOR_BUFFER_BIT,
GL_NEAREST);

Leadwerks
08-19-2008, 11:06 AM
Is it possible to blit from an FBO to the back buffer?

martinsm
08-19-2008, 12:12 PM
Yes. Just bind fbo with id 0 as DRAW_FRAMEBUFFER_EXT:

glBindFramebufferEXT(DRAW_FRAMEBUFFER_EXT, 0);
glDrawBuffer(GL_BACK);

Leadwerks
08-19-2008, 12:33 PM
Hmmm, this does not give control over depth copying. Is there anything I can use for copying the depth buffer from an FBO to the back buffer? What about going from the back buffer to an FBO?

arekkusu
08-19-2008, 10:28 PM
Please read the instructions. (http://www.opengl.org/registry/specs/EXT/framebuffer_blit.txt). These questions are all answered there.

martinsm
08-20-2008, 12:55 AM
Hmmm, this does not give control over depth copying. Is there anything I can use for copying the depth buffer from an FBO to the back buffer?
I assume you are aware, that in your source snippet BlitFramebufferEXT have only GL_COLOR_BUFFER_BIT specified as mask. Not GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT. Or not?


What about going from the back buffer to an FBO?
Isn't it obvious that you should bind 0 as READ_FRAMEBUFFER_BINDING_EXT ?