OpenGL-Refpages icon indicating copy to clipboard operation
OpenGL-Refpages copied to clipboard

Remove "equal to" in the GL_INVALID_VALUE error of glGetActiveUniformsiv

Open andylin-hao opened this issue 2 years ago • 4 comments

The document of glGetActiveUniformsiv states that GL_INVALID_VALUE is generated if uniformCount is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program.

However, it's reasonable for OpenGL programs to give a value of uniformCount equaling the number of active uniforms in a specified shader program. This is because uniformCount specifies the length of the uniform array passed to glGetActiveUniformsiv. As long as this value does not exceed (i.e., is greater than) the actual number of active uniform variables, things should be fine.

andylin-hao avatar Jun 13 '22 08:06 andylin-hao

I also find that the error message of glTexStorage3D is not correct in certain ES versions. The concerned error message states that GL_INVALID_VALUE is generated if target is GL_TEXTURE_2D_ARRAY or GL_TEXTURE_CUBE_MAP_ARRAY and width and height are not equal, or depth is not a multiple of six. However, as stated in glTexStorage3D's documentation, when target is GL_TEXTURE_2D_ARRAY or GL_TEXTURE_CUBE_MAP_ARRAY, glTexStorage3D is equivalent to:

    for (i = 0; i < levels; i++)
    {
        glTexImage3D(target, i, internalformat, width, height, depth, 0, format, type, NULL);
        width = max(1, (width / 2));
        height = max(1, (height / 2));
    }

That is, glTexStorage3D should provide similar error message as glTexImage3D. However, in the document of glTexImage3D we can see that the same error is generated only when the target is GL_TEXTURE_CUBE_MAP_ARRAY, but not when the target is GL_TEXTURE_2D_ARRAY. This is reasonable because only cube requires 6 * N surfaces and width==height.

In all, I think GL_TEXTURE_2D_ARRAY should be removed from the error message in glTexStorage3D's document.

andylin-hao avatar Jun 16 '22 12:06 andylin-hao

@pdaniell-nv this is interesting, because there's no error corresponding to this in the API spec, and probably should be. This call is constructed as "equivalent to a later, more generic call" with a loop over 0..uniformCount-1, but even in GL 4.2 before the more generic call was introduced, there's no error for this. I suspect the right answer is to update the error here as suggested by @andylin-hao, and add this error to the spec (and to other calls that behave similarly, like GetUniformIndices).

oddhack avatar Sep 14 '23 03:09 oddhack

@pdaniell-nv this is interesting, because there's no error corresponding to this in the API spec, and probably should be. This call is constructed as "equivalent to a later, more generic call" with a loop over 0..uniformCount-1, but even in GL 4.2 before the more generic call was introduced, there's no error for this. I suspect the right answer is to update the error here as suggested by @andylin-hao, and add this error to the spec (and to other calls that behave similarly, like GetUniformIndices).

I think the GL_INVALID_VALUE is generated if uniformCount is greater than or equal to the value of GL_ACTIVE_UNIFORMS for program. statement in https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGetActiveUniformsiv.xhtml is totally bogus and should just be removed. The only use of "uniformCount" is for the size of the app provided uniformIndices and params parameters and doesn't depend on the active uniforms in the program.

pdaniell-nv avatar Sep 18 '23 23:09 pdaniell-nv

Thanks for the confirmation, guys! Let me know if you need me to make changes to the PR.

andylin-hao avatar Sep 26 '23 02:09 andylin-hao