Reputation: 1171
Edit: I narrowed down the cause and simplified the problem
I noticed, when playing around with OpenGL layered rendering, that Nvidia drivers/GPUs have trouble with framebuffers that have cube map textures bound to them. Intel IGPUs has no problem with this but when I switch over to my dedicated GPU, I get an error
The code below recreates the error:
GLuint environment = 0; glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &environment);
constexpr GLsizei resolution = 512;
glTextureStorage2D(environment, 1, GL_RGB32F, resolution, resolution);
glTextureParameteri(environment, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTextureParameteri(environment, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTextureParameteri(environment, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTextureParameteri(environment, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTextureParameteri(environment, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTextureParameteri(environment, GL_TEXTURE_BASE_LEVEL, 0);
glTextureParameteri(environment, GL_TEXTURE_MAX_LEVEL, 0);
GLuint capture_fbo = 0; glCreateFramebuffers(1, &capture_fbo);
GLuint capture_rbo = 0; glCreateRenderbuffers(1, &capture_rbo);
glNamedRenderbufferStorage(capture_rbo, GL_DEPTH_COMPONENT32F, resolution, resolution);
glNamedFramebufferTexture(capture_fbo, GL_COLOR_ATTACHMENT0, environment, 0);
glNamedFramebufferRenderbuffer(capture_fbo, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, capture_rbo);
if (glCheckNamedFramebufferStatus(capture_fbo, GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
{
fmt::print("Framebuffer Complete!\n");
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, capture_fbo);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else fmt::print("Framebuffer Not Complete!\n");
When I query the framebuffer after trying to run the code above, it says it isn't complete until I unbind/rebind the framebuffer. After which it says it's complete again, even though nothing has changed.
The console output on Nvidia:
Manufacturer: NVIDIA Corporation
GPU: GeForce GTX 1060 with Max-Q Design/PCIe/SSE2
OpenGL Version: 4.5.0 NVIDIA 416.34
GLSL Version: 4.50 NVIDIA
Framebuffer Complete!
OpenGL [API Error 1286] (High): GL_INVALID_FRAMEBUFFER_OPERATION error generated. Operation is not valid because a bound framebuffer is not framebuffer complete.
Console output on Intel:
Manufacturer: Intel
GPU: Intel(R) UHD Graphics 630
OpenGL Version: 4.5.0 - Build 23.20.16.4973
GLSL Version: 4.50 - Build 23.20.16.4973
Framebuffer Complete!
Am I encountering a bug? Since it works on one vendor but not another, is there some special specification for Nvidia framebuffers?
Upvotes: 1
Views: 1153
Reputation: 474126
Cubemap textures effectively have 6 layers. So calling glNamedFramebufferTexture
will attach the cubemap as a layered image. And for framebuffers to be complete, either all attached images are layered, or none of them are. Renderbuffer images are never layered, so you have a framebuffer which should not be complete.
So while glCheckNamedFramebufferStatus
should not have returned "complete", NVIDIA is closer to being correct than Intel (not a surprise).
Upvotes: 2