PDA

View Full Version : Framenbuffer: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT



Lodeman
12-19-2013, 02:34 PM
Hi guys,

I've been trying to get my application running on someone else's computer, so the code that follows is known to work on my PC, as well as on that of another friend. We both have AMD GPUs.
The code is however returning a faulty framebuffer on the PC of an NVIDIA user (unsure if manufacturer is a factor here, but mentioning to be sure).
The status it returns for him is: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT

The purpose of this code is to generate a framebuffer with a texture array (GL_TEXTURE_2D_ARRAY) in order to generate cascades for shadowmapping.
m_fbo is a GLuint to store the framebuffer, m_shadowMap is a GLuint to store the shadowMap texture array.
windowWidth and windowHeight are positive integers.

I've not had much luck searching the internet for similar problems using GL_TEXTURE_2D_ARRAY, so I've taken to the forums.
My question is thus: am I doing certain steps incorrectly, possibly in the wrong order?

Any suggestions are greatly appreciated!

Thanks in advance,
Lodeman



bool ShadowMapFBO::init(unsigned int windowWidth, unsigned int windowHeight)
{
// Create the FBO
glGenFramebuffers(1, &m_fbo);

// Create the depth buffer
glGenTextures(1, &m_shadowMap);
glBindTexture(GL_TEXTURE_2D_ARRAY, m_shadowMap);

glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT16, windowWidth, windowHeight, NUM_CASCADES, GL_FALSE, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);

glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_ARRAY, m_shadowMap, 0, 0);
for(int i = 0; i < NUM_CASCADES; ++i)
{
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_shadowMap, 0, i);
}


// Disable writes to the color buffer
glDrawBuffer(GL_NONE);

GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

if (Status != GL_FRAMEBUFFER_COMPLETE) {
MessageBox(NULL, "Failed to create ShadowMapFBO, status: "+Status, "Heavy times", MB_ICONERROR | MB_OK);
Debug::printDebugTextWithInt("Failed to create ShadowMapFBO, status: ", Status);
return false;
}

Debug::printDebugText("Succesfully created ShadowMapFBO");
return true;
}

Dark Photon
12-19-2013, 06:41 PM
...
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_ARRAY, m_shadowMap, 0, 0);
for(int i = 0; i < NUM_CASCADES; ++i)
{
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_shadowMap, 0, i);
}



I think you want to nuke the glFramebufferTexture3D() as this is for 3D textures only IIRC. Just keep the glFramebufferTextureLayer() to bind the specific layer you're rendering to.

Also would check for GL errors, and verify that m_shadowMap is not 0 when you set it on the FBO.

Lodeman
12-26-2013, 02:26 PM
Hi Dark Photon,

It took me awhile to get around to testing this solution with the specific people, but we got it to work.
Alongside removing the glFrameBufferTexture3D() we also had to make sure the app was running with their dedicated 3D Graphics card, as it turned out to be running with the onboard mobo one.

Thanks for your help!