I have a simple question that I find pretty hard to find information online. How can I blit layered frame buffers? I have the following:
glGenFramebuffers(1, &MSAAFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, MSAAFramebuffer);
// generate texture
glGenTextures(4, msaaColorBuffers);
for (int i = 0; i < 4; ++i)
{
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, msaaColorBuffers[i]);
if (i == 1) glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, msaaSamples, GL_R11F_G11F_B10F, renderWidth, renderHeight, 2, GL_TRUE);
else glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, msaaSamples, GL_RGBA8, renderWidth, renderHeight, 2, GL_TRUE);
// attach it to currently bound framebuffer object
glFramebufferTextureMultiviewOVR(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, msaaColorBuffers[i], 0, 0, 2);
}
glGenTextures(1, &depthTextureMS);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, depthTextureMS);
glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, msaaSamples, GL_DEPTH_COMPONENT32F, renderWidth, renderHeight, 2, GL_TRUE);
glFramebufferTextureMultiviewOVR(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthTextureMS, 0, 0, 2);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 0);
GLuint resolvedTextAttachments[4] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 , GL_COLOR_ATTACHMENT3 };
glDrawBuffers(4, resolvedTextAttachments);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
Log::error("ERROR::FRAMEBUFFER:: Off screen render Framebuffer is not complete!");
// bind again the default frame buffer
glBindFramebuffer(GL_FRAMEBUFFER, 0);
And trying to blit like this:
glBindFramebuffer(GL_READ_FRAMEBUFFER, gBufferMSAA);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, MSAAFramebuffer);
for (int layer = 0; layer < 2; ++layer) {
glFramebufferTexture3D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE_ARRAY, depthTextureArrayMS, 0, layer);
glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE_ARRAY, depthTextureMS, 0, layer);
glBlitFramebuffer(0, 0, renderWidth, renderHeight, 0, 0, renderWidth, renderHeight, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
}
During initializing the frame buffer I get no errors and everything works as expected. During blit and if I use “glFramebufferTexture3D” or “glFramebufferTextureLayer” I get frame buffer bindings are incomplete. Any ideas here?