PDA

View Full Version : Multisample Framebuffer resolved with glBlitFrameBuffer



MarkTheFox
08-23-2016, 07:01 AM
Hi there,

I am writing a code to resolve automatically the multisampling from one FBO (with multiple color attachements - MS textures) to another FBO (with the same color attachements - simple textures).

When applying this method to blit from one simple FBO to another (with same color attachements and no MS applied) it works perfectly well !
But when I just change the source FBO to a multisampled one (with multisampled textures), blitting is not resolved (but no error is detected using glGetError after the glBlitFramebuffer function). It seems nothing is done to the output texture (I tried to do a "glClear(GL_COLOR_BUFFER_BIT) before calling the glBlitFramebuffer function and the output texture only takes the clear color).

Does anyone have any idea ?
I activated the "GL_MULTISAMPLE" state and my multisampled FBO / textures have 4 samples too.
I set my SDL2 window with 1 sample buffer with 4 samples (but it should not have any incidence while blitting)

Here is the code used to process the blitting process:



void resolve()
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fboSrcID);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fboDstID);

// there are 2 color attachements (textures)
for(unsigned int i = 0 ; i < 2; i++)
{
glReadBuffer(GL_COLOR_ATTACHMENT0+i);
glDrawBuffer(GL_COLOR_ATTACHMENT0+i);
glBlitFramebuffer(0,0,1024,1024,0,0,1024,1024,GL_C OLOR_BUFFER_BIT, GL_NEAREST);

GLenum err = glGetError();
if(err!=GL_NO_ERROR)
{
printf("Error while blitting\n");
}
}
}