You can only read from a single color buffer at a time when you do a framebuffer blit; you can write to many draw buffers (technically up to GL_MAX_DRAW_BUFFERS
at once). The problem here is that you want to read from two different color buffers, and you are trying to do it in a single blit.
OpenGL 4.4 Core Specification - 18.3. Copying Pixels - (pp. 483)
When the color buffer is transferred, values are taken from the read buffer of the read framebuffer and written to each of the draw buffers of the draw framebuffer.
Your code indicates to me that you forgot to actually do a second blit for the second color attachment, and that is why it comes up empty.
To correct this, I would expect to see something like:
// Resolve multisampling
if ( m_Multisample > 0 )
{
//
// Do the first resolve (COLOR_ATTACHMENT0)
//
gl::BindFramebuffer(gl::READ_FRAMEBUFFER,m_Framebuffers[eFBO_RENDERBUFFER]);
gl::ReadBuffer (gl::COLOR_ATTACHMENT0); // Read: Attachment 0 (MSAA)
gl::BindFramebuffer(gl::DRAW_FRAMEBUFFER,m_Framebuffers[eFBO_RESOLVEBUFFER]);
gl::DrawBuffer (gl::COLOR_ATTACHMENT0); // Write: Attachment 0 (Resolve)
gl::BlitFramebuffer(0, 0, m_FrameDims, m_FrameDims, 0, 0, m_FrameDims,
m_FrameDims, gl::COLOR_BUFFER_BIT, gl::NEAREST);
gl::enum_t blit_error = gl::NO_ERROR_;
blit_error = gl::GetError();
if ( blit_error != gl::NO_ERROR_ )
{
throw framebuffer_error(string::format<128>(
"BlitFramebuffer failed with error: %d",blit_error));
}
//
// Do the second resolve (COLOR_ATTACHMENT1)
//
gl::BindFramebuffer(gl::READ_FRAMEBUFFER,m_Framebuffers[eFBO_RENDERBUFFER]);
gl::ReadBuffer (gl::COLOR_ATTACHMENT1); // Read: Attachment 1 (MSAA)
gl::BindFramebuffer(gl::DRAW_FRAMEBUFFER,m_Framebuffers[eFBO_RESOLVEBUFFER]);
gl::DrawBuffer (gl::COLOR_ATTACHMENT1); // Write: Attachment 1 (Resolve)
gl::BlitFramebuffer(0, 0, m_FrameDims, m_FrameDims, 0, 0, m_FrameDims,
m_FrameDims, gl::COLOR_BUFFER_BIT, gl::NEAREST);
gl::enum_t blit_error = gl::NO_ERROR_;
blit_error = gl::GetError();
if ( blit_error != gl::NO_ERROR_ )
{
throw framebuffer_error(string::format<128>(
"BlitFramebuffer failed with error: %d",blit_error));
}
gl::BindFramebuffer(gl::READ_FRAMEBUFFER,m_Framebuffers[eFBO_RESOLVEBUFFER]);
}
This assumes that the textures / renderbuffers you want to blit from/to have the same attachment point. If not, you can adjust gl::ReadBuffer (...)
and gl::DrawBuffer (...)
accordingly.