Most of the time, the code works fine. But once, I got glCheckFramebufferStatusEXT status is 36061 10 times, which is 0x8cdd, glBindFramebufferEXT from officical doc. Does anybody know what is the meaning of this enum? And why this happens?
I used CUDA 11.6, and Nvidia driver 510.47
I searched a lot, and didn’t find any clue to debug and fix this occasional bug.
Thanks!
bool OpenglViewer::bindFbo(unsigned int width, unsigned int height)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferId);
//We must bind color_rb before we call glRenderbufferStorageEXT
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorRenderBufferId);
//The storage format is RGBA8
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB10_A2, width, height);
//Attach color buffer to FBO
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorRenderBufferId);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthRenderBufferId);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT32, width, height);
//Attach depth buffer to FBO
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthRenderBufferId);
//and now you can render to the FBO (also called RenderBuffer)
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferId);
//Does the GPU support current FBO configuration?
GLenum status;
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
//std::wstring message = L"The glCheckFramebufferStatusEXT status is " + boost::lexical_cast<std::wstring>(status) + L".";
//ServiceManagerUtility::log(LOGLEVEL_ENG, message);
static int exceptionCount = 0;
static const int MAX_EXCEPTION_NUM = 10;
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
exceptionCount++;
if(exceptionCount <= MAX_EXCEPTION_NUM)
{
std::wstring message = L"The glCheckFramebufferStatusEXT status is " + boost::lexical_cast<std::wstring>(status) + L".";
ServiceManagerUtility::log(LOGLEVEL_SUP, message,ET_EXCEPTION);
}
if(exceptionCount == MAX_EXCEPTION_NUM)
{
ServiceManagerUtility::log(LOGLEVEL_ENG, openglexception::OPENGL_BINDFBO_ERROR_DESC, ET_ERROR, openglexception::MEMORY_ALLOCATION_FAILED_ID);
ServiceManagerUtility::reportError(openglexception::MEMORY_ALLOCATION_FAILED_ID);
}
return false;
}
else
{
exceptionCount = 0;
return true;
}
}
There isn’t much you can do with it. You can play around with different image formats. But unless NVIDIA’s debug reporting gives you more information, the only things you can do to guarantee that you won’t get framebuffer unsupported are:
Stick to the required image formats for framebuffers; implementations are not allowed to give you “framebuffer unsupported” if all of your image formats are on that list.
what do you mean by image format? from the above code, I found that I used glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferId) twice, one is at the beginning of the method, the other one is just before the status check. Where to set the image format for bind framebuffer?
The internalformat parameters to glRenderbufferStorage.
You’re using GL_RGB10_A2 for the colour buffer and GL_DEPTH_COMPONENT32 for the depth buffer. GL_RGB10_A2 is a required colour-renderable format, but GL_DEPTH_COMPONENT32 isn’t a required format; implementations aren’t required to support it, and even if it’s supported for textures it isn’t required to be renderable or supported for renderbuffers.
GL_DEPTH_COMPONENT24, GL_DEPTH24_STENCIL8 and GL_DEPTH_COMPONENT32F are required depth-renderable formats.
GL_DEPTH_COMPONENT32F requires OpenGL 3.0 or the GL_ARB_depth_buffer_float extension.