PDA

View Full Version : Framebuffers do not support depth texture arrays on Nvidia?



Silverlan
10-16-2015, 03:01 PM
I have a texture array, which is created and initialized like this:


auto size = 4096;
auto depth = 4;
GLuint fbo;
glGenFramebuffers(1,&fbo);
glBindFramebuffer(GL_FRAMEBUFFER,fbo);

GLuint tex;
glGenTextures(1,&tex);
glBindTexture(GL_TEXTURE_2D_ARRAY,tex);

glTexImage3D(
GL_TEXTURE_2D_ARRAY,0,GL_DEPTH_COMPONENT24,
size,size,depth,1,GL_DEPTH_COMPONENT,GL_FLOAT,NULL
);
/*
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MIN _FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_MAG _FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_COM PARE_FUNC,GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_COM PARE_MODE,GL_COMPARE_R_TO_TEXTURE);

glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRA P_R,GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRA P_S,GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_WRA P_T,GL_CLAMP_TO_BORDER);
glm::vec4 col(1.f,1.f,1.f,1.f);
glTexParameterfv(GL_TEXTURE_2D_ARRAY,GL_TEXTURE_BO RDER_COLOR,&col[0]);
*/ // Problem occurs regardless of these

glFramebufferTextureLayer(GL_FRAMEBUFFER,GL_DEPTH_ ATTACHMENT,tex,0,0);
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

On my AMD-card this works just fine, however when trying it on a Nvidia-machine (With OpenGL 4.5 support), the return value is GL_FRAMEBUFFER_UNSUPPORTED.
I've checked whether any of the gl-calls invoke an error, but glGetError returns 0 for all of them, both on the AMD- and the Nvidia-machine.

What am I doing that is 'unsupported' here and what can I do to get around it?

Alfonse Reinheart
10-16-2015, 04:06 PM
What am I doing that is 'unsupported' here

Who knows?

GL_FRAMEBUFFER_UNSUPPORTED is the framebuffer completeness state you get when your implementation doesn't like your combination of framebuffer formats (https://www.opengl.org/wiki/Framebuffer_Object#Completeness_Rules).

NVIDIA usually has decent debug output support (https://www.opengl.org/wiki/Debug_Output), so turn that on and check the debug messages you get. It may help clue you in. You will of course need to create a debug context to use it.


what can I do to get around it?

If you can't get NVIDIA's implementation to tell you much more about it, then there's not much you can do.

What's odd is that GL_DEPTH_COMPONENT24 is a required format. Which means that NVIDIA isn't allowed to return GL_FRAMEBUFFER_UNSUPPORTED for it. It may be that the driver is confused because you're only attaching one layer of the image to the framebuffer.

arekkusu
10-16-2015, 07:42 PM
You're clamping to a border color... and creating a texture with border texels?

Try not using border texels.

Silverlan
10-17-2015, 06:04 AM
NVIDIA usually has decent debug output support (https://www.opengl.org/wiki/Debug_Output), so turn that on and check the debug messages you get. It may help clue you in. You will of course need to create a debug context to use it.

Thank you, I didn't know that feature existed!
Turns out Nvidia doesn't support DEPTH_ATTACHMENT with bordered textures; Removing the border solved the issue!

Alfonse Reinheart
10-17-2015, 07:53 AM
Yet another reason to use the core OpenGL profile. It would have given you an OpenGL error for using a non-zero border.