FBO + multisample + blit + multiple color buffers

Hi all,

Using FBO alone is easy. Performing multisample antialiasing on a FP16 target is a bit harder. The procedure I’m using is:

  • Create FBO A, attach the renderable texture to COLOR_ATTACHEMENT_0, attach a depth buffer.
  • Create FBO B, attach a multisample render buffer to COLOR_ATTACHMENT_0, attach a multisample depth buffer.
  • Render scene into FBO B
  • Blit FBO B into FBO A

Now, my problem is that I want to use multiple FP16 render buffers AND antialiasing at the same time.

I felt that the procedure above should work “as is”, ie. with a single blit, the two color attachments get copied. Doesn’t seem that way. When I try to display the second color attachment, I get the data from the first one.

There’s not a single word in the specifications about mixing ARB_draw_buffers with EXT_framebuffer_multisample/blit.

I tried a slightly different approach. Instead of a single blit, I do:

  • glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_fboB);
  • glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_fboA);
  • glReadBuffer(GL_COLOR_ATTACHMENT0_EXT)
  • glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
  • glBlitFramebufferEXT(0, 0, m_width - 1, m_height - 1, 0, 0, m_width - 1, m_height - 1, mask, GL_NEAREST);
  • glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
  • glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
  • glBlitFramebufferEXT(0, 0, m_width - 1, m_height - 1, 0, 0, m_width - 1, m_height - 1, mask, GL_NEAREST);

I check for glGetError between each call, and no error happens. But the end result (when displaying the secondary texture) is still showing the first texture’s content.

I have a GF 8800 GTX under Vista 32 bits.

Did anybody succeed in mixing those extensions together ? Or has any idea ?

Y.

So what’s attached to GL_COLOR_ATTACHMENT1_EXT?
The depth buffer isn’t a color attachment if that’s what you’re looking for.

N.

There’s not a single word in the specifications about mixing ARB_draw_buffers with EXT_framebuffer_multisample/blit.

From the EXT_framebuffer_blit specs:

 12) Should we add support for multiple ReadBuffers, so that
    multiple color buffers may be copied with a single call to
    BlitFramebuffer?

Resolved: No, we considered this but the behavior is awkward
to define and the functionality is of limited use.

So, your multiple-blits-approach seems the only reasonable way. It might be a driver bug…

I’m rendering to 2 color textures and 1 depth buffer. So in COLOR_ATTACHMENT_1_EXT, there is the secondary color texture. There’s no problem related to the depth buffer.

Right… but that doesn’t tell me what the “correct” approach should be. The one I’ve tried is the “natural” one that came to my mind, not necessarily the good one…

Bump. Problem is still alive…

A nasty solution I know, but what about swapping the colour attachments around so that after each blit the next target is moved to attachment 0.

If that works then you can assume a driver bug/oversight wrt copying from different source attachments/destinations on an FBO.

Has this problem been resolved is some other way or is the above suggestion the correct way to do it?