Ivo Skalický
Ivo Skalický

Reputation: 318

GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT when using texture with internal format GL_R16_SNORM

I am rendering 16bit grayscale images using OpenGL and need to fetch rendered data to buffer without bit depth decimation. My code works perfectly on Intel(R) HD Graphics 4000, but on nVidia graphic cards (NVIDIA Corporation GeForce G 105M/PCIe/SSE2, NVIDIA Corporation GeForce GT 640M LE/PCIe/SSE2) it fails with status GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT when I try to render to texture with internal format GL_R16_SNORM. It works when I use GL_R16 format, but I also loose all negative values of rendered texture. With Intel HD Graphics it works with both GL_R16_SNORM and GL_16 values.

glTexImage2D(GL_TEXTURE_2D, 0, GL_R16_SNORM, width, height, 0, GL_RED, GL_SHORT, null);
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureId, 0);
glDrawBuffers(1, new int[] {GL_COLOR_ATTACHMENT0}, 0);
int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER); 

What is reason of GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT status on nVidia cards? Can you advise how to debug this situation? (unfortunately glGetError()==GL_NO_ERROR)

EDIT: After further testing I found out it work also on ATI graphics cards. As Reto Koradi answered, support in OpenGL version pre 4.4 is manufacturer specific and it seems it works on ATI and Intel cards but not on nVidia cards.

Tested graphic cards

Upvotes: 1

Views: 633

Answers (1)

Reto Koradi
Reto Koradi

Reputation: 54592

GL_R16_SNORM only became a required color-renderable format with OpenGL 4.4.

If you look at the big texture format table for example in the 4.3 spec (starting on page 179), the "color-renderable" field is checked for R16_SNORM. But then on page 178, under "Required Texture Formats", R16_SNORM is listed as a "texture-only color format". This means that while implementations can support rendering to this format, it is not required.

In the 4.4 spec, the table (starting on page 188) basically says the same. R16_SNORM has a checkmark in the column "CR", which means "color-renderable". But the rules were changed. In 4.4 and later, all color-renderable formats have to be supported by implementations. Instead of containing lists, the "Required Texture Formats" section on page 186 now simply refers to the table. This is also mentioned in the change log section of the spec.

This means that unless you require at least OpenGL 4.4, support for rendering to this format is indeed vendor/hardware dependent.

Upvotes: 4

Related Questions