Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: NVIDIA or AMD driver bug with uniform names for block uniforms

Hybrid View

  1. #1
    Senior Member OpenGL Lord
    Join Date
    May 2009

    NVIDIA or AMD driver bug with uniform names for block uniforms

    Consider the following code, which prints out the name of uniforms in a program:

    Code :
    GLint numUniforms;
    glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &numUniforms);
    std::cout << "Num uniforms: " << numUniforms << "\n";
    for(int ix = 0; ix < numUniforms; ++ix)
    	GLint length;
    	glGetActiveUniformsiv(program, 1, (GLuint*)&ix, GL_UNIFORM_NAME_LENGTH, &length);
    	std::vector<GLchar> str(length);
    	glGetActiveUniformName(program, ix, length, NULL, &str[0]);
    	std::string name(str.begin(), str.end());
    	std::cout << ix << ":\t" << name << "\n";

    Now considering the following Vertex Shader:

    Code :
    #version 330
    uniform BlockName
      float a_name;
    } instance_name;
    uniform float a_name;
    in vec3 position;
    void main()
    { = * a_name * instance_name.a_name;
    	gl_Position.w = 1.0;

    If the fragment shader has no other uniforms, we would expect to see 2 uniforms come out of this code. And on both NVIDIA and AMD drivers, I do. The problem is what they're named.

    On AMD, they're called "a_name" and "instance_name.a_name". On NVIDIA, they're called "a_name" and "BlockName.a_name".

    I'm fairly sure NVIDIA is correct here, but I can't say that they are because... the actual OpenGL spec does not say. Or if it does, I certainly can't find it.

    So one of them is wrong. Or maybe both are. I don't know. Does anyone know? Will the ARB ever bother clarifying it?

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Yes, NVIDIA is correct in this case.

    From the GLSL 4.30 spec revision 7, page 52:

    Outside the shading language (i.e., in the API), members are similarly identified except the block name is
    always used in place of the instance name (API accesses are to interfaces, not to shaders). If there is no
    instance name, then the API does not use the block name to access a member, just the member name.
    Last edited by randall; 01-02-2013 at 05:34 PM.

  3. #3
    Senior Member OpenGL Lord
    Join Date
    May 2009
    I knew I had seen that somewhere; I just couldn't find it. That's a really odd place for it though. Especially since 7.3.1 in the 4.3 spec lists how everything is named except for members of uniform blocks. It talks about array elements, struct members, etc. Just not direct members of uniform blocks.

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2012
    This reminds me of a related bug on MacOS:

    Code :
    layout(std140) uniform exampleblock
        mat4 viewMatrix;
        mat4 projectionMatrix;
    layout(std140) uniform exampleblocknamed
        mat4 viewMatrix;
        mat4 projectionMatrix;
    } nameOfBlock;

    The names of the first block should be
    'uViewMatrix' / 'uProjectionMatrix' as the block is unnamed and the second 'exampleblocknamed.uViewMatrix' / 'exampleblocknamed.uProjectionMatrix' as the block is named. However, on MacOS you always get the blockname, here 'exampleblock.uViewMatrix' / 'exampleblock.uProjectionMatrix' in the first case...

    Seems like 3 implementors managed to get 3 different implementations...

    (Bug ID is 11335828, open since april 2012, let's see if AMD fixes it faster ;-) )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts