PDA

View Full Version : FBO with multiple color attachments and MSAA



addmx
06-04-2009, 05:15 AM
Hi

i have FBO with GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT binded
both GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT
are multisampled renderbuffers (glRenderbufferStorageMultisampleEXT ... etc.)
now i render to this FBO
and unbind it

then i have another fbo with with GL_COLOR_ATTACHMENT0_EXT and GL_COLOR_ATTACHMENT1_EXT binded (this time those two are textures
with format and dimensions identical to renderbuffers of previous FBO)

now i want to resolve my MSAA renderbuffers to those textures

glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, MSAA_FBO);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, TEXTURES_FBO);

glBlitFramebufferEXT( 0, 0, texWidth, texHeight, 0, 0, texWidth, texHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

but what a crap ! ;)
both textures binded to TEXTURES_FBO now have context of the FIRST renderbuffer ;)

what is wrong ?
my first texture should have context from the GL_COLOR_ATTACHMENT0_EXT of MSAA_FBO and the second one from GL_COLOR_ATTACHMENT1_EXT.

is there any way to do this 'at once' ?
or i must bind each renderbuffer to the fbo, then texture to the fbo and do it one by one ?

skynet
06-04-2009, 06:13 AM
There's only one glReadBuffer(), thus only one source for the blit. But, as you have experienced, there can be multiple glDrawBuffers().

To do what you want, perform two blits, adjusting glReadBuffer() and glDrawBuffer() inbetween.

I find it amusing that the blit actually really followed the glDrawBuffers() setting - this is something I have never thought about, nor read about in the specs. But it seems logical and consistent.

addmx
06-05-2009, 01:33 AM
ok, after reading the GL_EXT_framebuffer_blit specification second time i'v spot that there is a note about multiple color attachments :)