PDA

View Full Version : glBlitFramebuffer multisampled fbo on OSX ATI



ahypnosis
12-22-2011, 07:22 AM
Dear OpenGL Specialists!

I would like to ask for your help.

I have a problem with the operation of the glBlitFramebuffer command on OSX. If my actual framebuffer is multisampled (for example 4x) then the glBlitFramebuffer won’t be able to copy the value of the deptbuffer to another same-structured framebuffer.

In case of correct operation we should see this picture below (on Windows, ATI and NVIDIA): link (http://aha.amigaspirit.hu/DepthBufferBlit/4x_msa_win_nv.png)

Instead of this, on the same computer on OSX, mainly on ATI we can see this: link (http://aha.amigaspirit.hu/DepthBufferBlit/4x_msa_mac_ati.png)

The DepthBuffer copy operates well, if there is no multisampling on the framebuffer. Example pictures:
win: link (http://aha.amigaspirit.hu/DepthBufferBlit/no_msa_win_nv.png)
osx: link (http://aha.amigaspirit.hu/DepthBufferBlit/no_msa_mac_ati.png)

Please download the example program (which compiles both on windows and mac) from the link below : download (http://aha.amigaspirit.hu/DepthBufferBlit/GLFWTest4.zip)

I would like to ask what was the mistake I made that windows driver can handle, but OSX can't. Is there any other method to solve this problem? My task would be to be able to copy multisampled depthbuffer between two framebuffers.

Thank you for your kind help in advance, and I wish you a merry Christmas and happy new year.

Kind regards,

ahypnosis

ahypnosis
12-26-2011, 03:52 AM
This is how I create the FBO:


glGenRenderbuffersEXT (1, &ColorRenderbufferName);
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, ColorRenderbufferName);
glRenderbufferStorageMultisampleEXT (GL_RENDERBUFFER_EXT, samples, GL_RGBA, width, height);

glGenRenderbuffersEXT (1, &DepthRenderbufferName);
glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, DepthRenderbufferName);
glRenderbufferStorageMultisampleEXT (GL_RENDERBUFFER_EXT, samples, GL_DEPTH24_STENCIL8_EXT, width, height);

glGenFramebuffersEXT (1, &FramebufferRenderName);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, FramebufferRenderName);
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, ColorRenderbufferName);
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, DepthRenderbufferName);
glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, DepthRenderbufferName);

status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
valid = status == GL_FRAMEBUFFER_COMPLETE_EXT;
if (valid) {
glClearColor (0,0,0,0);
glClearDepth (1.0);
glClearStencil (0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

glGenFramebuffersEXT (1, &FramebufferResolveName);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, FramebufferResolveName);

glGenTextures(1, &ColorTextureName);
glBindTexture(GL_TEXTURE_2D, ColorTextureName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glFramebufferTextureEXT (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ColorTextureName, 0);

status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
valid = status == GL_FRAMEBUFFER_COMPLETE_EXT;
if (!valid) {
PrintFramebufferStatus (status);
} else {
glClearColor (0,0,0,0);
glClear (GL_COLOR_BUFFER_BIT);
}
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
} else {
PrintFramebufferStatus (status);
}


After this here you can see how I select the FBO:


glBindFramebufferEXT (GL_FRAMEBUFFER_EXT,FramebufferRenderName);
glViewport(0, 0, width, height);


And this how I deselct:


glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, FramebufferRenderName);
glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, FramebufferResolveName);
glBlitFramebufferEXT (0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);


Then later after I would like to copy the DepthBuffer to another FBO, this way:


glBindFramebufferEXT (GL_READ_FRAMEBUFFER_EXT, src);
glBindFramebufferEXT (GL_DRAW_FRAMEBUFFER_EXT, FramebufferRenderName);
glBlitFramebufferEXT (0, 0, width, height, 0, 0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);


I'm looking forward to your help!
Thx