Consider the following code, which prints out the name of uniforms in a program:
glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &numUniforms);
std::cout << "Num uniforms: " << numUniforms << "
for(int ix = 0; ix < numUniforms; ++ix)
glGetActiveUniformsiv(program, 1, (GLuint*)&ix, GL_UNIFORM_NAME_LENGTH, &length);
glGetActiveUniformName(program, ix, length, NULL, &str);
std::string name(str.begin(), str.end());
std::cout << ix << ": " << name << "
Now considering the following Vertex Shader:
uniform float a_name;
in vec3 position;
gl_Position.xyz = position.xyz * 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 [i]does not say.[/i] 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?
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.
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.
This reminds me of a related bug on MacOS:
layout(std140) uniform exampleblock
layout(std140) uniform exampleblocknamed
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 )
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.