PDA

View Full Version : FBO Multisample / FBO Blit question MRTs



Keith Z. Leonard
06-26-2007, 03:07 PM
I am implementing Framebuffer Object Multisample. And I have it working for the most part. I have one sticking point currently.

I have a color attachment on COLOR_ATTACHMENT0, another on COLOR_ATTACHMENT1, as well as depth and stencil (via DEPTH_STENCIL Extension). My shader (Cg) outputs to both COLOR0 and COLOR1, this works fine for my non-multisample FBO. When I do my BlitFramebuffer call, should it be copying all of the color attachments from the source FBO to the dest FBO? Everything works but the 2nd render target. Certainly I could have something wrong, so any comments are welcome.

Basically, I have 2 FBOs, 1 setup with 2 texture attachments, and 1 setup with multisample render buffers.

Here's the Blit code.


glBindFramebuffer( GL_DRAW_FRAMEBUFFER_EXT, _fbo );
glBindFramebuffer( GL_READ_FRAMEBUFFER_EXT, _fbo_multisample );
glBlitFramebuffer(0, 0, _rb_size_x, _rb_size_y, 0, 0, _rb_size_x, _rb_size_y,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
Thanks, Keith

Michael Gold
06-26-2007, 09:38 PM
I predict that you are seeing the contents of read.color0 resolved into both draw.color0 and draw.color1. Is that correct?

In order to resolve multiple color buffers you need to split the operation into two steps.

readbuffer(color0);
drawbuffer(color0);
blit(color|depth|stencil);
readbuffer(color1);
drawbuffer(color1);
blit(color);

Keith Z. Leonard
06-27-2007, 10:32 AM
Michael, that was indeed the problem. Seems fairly obvious now that you have pointed it out, thanks a bunch!

Keith