PDA

View Full Version : Invalid operation when I try to load a GL_R8UI texture.



Krux02
12-13-2016, 09:59 AM
loading the same texture with GL_R8 works just fine, but loading with GL_R8UI throws an GL_INVALID_OPERATION. I am on an OpenGL 3.3 core context profile, but I loaded the extention ARB_direct_state_access (https://www.opengl.org/registry/specs/ARB/direct_state_access.txt). These are the function calls that are tracked from apitrace:



glCreateTextures(GL_TEXTURE_2D, 1, [2]) // [2] means that two is the value that got stored in the parameter array
glTextureStorage2D(2, 1, GL_R8UI, 1024, 1024)
glTextureParameteri(2, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTextureParameteri(2, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
glGetTextureLevelParameteriv(2, 0, GL_TEXTURE_WIDTH, [1024])
glGetTextureLevelParameteriv(2, 0, GL_TEXTURE_HEIGHT, [1024])
glTextureSubImage2D(texture=2, level=0, xoffset=0, yoffset=0, width=1024, height=1024, format = GL_RED, type = GL_UNSIGNED_BYTE, pixels = [binary data, size = 1024kb])


and this is the error message:



message: GL_INVALID_OPERATION error generated. Texture type and format combination is not valid.


I just do not understand the problem.

GClements
12-13-2016, 05:41 PM
glTextureStorage2D(2, 1, GL_R8UI, 1024, 1024)
...
glTextureSubImage2D(..., format = GL_RED, ...)




message: GL_INVALID_OPERATION error generated. Texture type and format combination is not valid.


The format parameter should be GL_RED_INTEGER for an integer texture (the online reference page is incorrect on this point; the list of acceptable values for format doesn't appear to have been updated since integer textures were added).

Krux02
12-14-2016, 08:29 AM
The format parameter should be GL_RED_INTEGER for an integer texture

Thanks a lot, I really thought there was a bug in my driver or something like that, because it just refused to work.


(the online reference page is incorrect on this point; the list of acceptable values for format doesn't appear to have been updated since integer textures were added).

No wonder that I could not find it. How should I be able to do it properly when the official reference is incomplete? And where do other people know it from?

Anyway you really could help, thank you very much.

GClements
12-15-2016, 12:07 AM
No wonder that I could not find it. How should I be able to do it properly when the official reference is incomplete? And where do other people know it from?

If in doubt, refer to the current specification (https://www.opengl.org/registry/#apispecs).

Unfortunately, information is often fairly scattered. E.g. the description of glTexSubImage2D() just refers to glTexImage2D() which refers to glTexImage3D() which refers to the "Transfer of Pixel Rectangles" section.