glGetUniform bug on NVIDIA

Hello,

I have a shader with a bool uniform:

uniform bool u_Bool;

Since there is no initializer, I expect its initial value to be 0. From the GLSL 1.5 spec:

The link time initial value is either the value of the variable’s initializer, if present, or 0 if no initializer is present.

After linking, I query the value with glGetUniformiv and receive 13 not 0. Furthermore, the if statement in the shader that checks the uniform evaluates to false so it’s as if the value is actually 0 but 13 is returned.

I’ve tried both glGetUniformiv and glGetUniformfv using GLSL 1.1 and 1.5. I am running NVIDIA GeForce 9 on Windows Vista 64-bit with 191.07 drivers. Has anyone experienced anything similar?

Regards,
Patrick

Sounds like a minor driver bug. Most people don’t use glGetUniform (since it’s slow), so it’s probably not a high-priority item for NVIDIA.

I agree that it’s slow but I shadow the value of uniforms to avoid redundantly setting them so I need to query the value once right after linking. I can’t just give it a default value because that would overwrite an initializer in the GLSL code. So I wind up reading the initial value with glGetUniform then immediately setting that same value with glUniform so my shadowed copy is in sync with the driver.

Regards,
Patrick


#version 120
uniform bool u_Bool = false; 

?

Not sure if this is what you’re talking about or not, but if so, I don’t understand your statement. false would be the initializer, and the value you want. No?

Not sure if this is what you’re talking about or not, but if so, I don’t understand your statement. false would be the initializer, and the value you want. No?

He’s saying that he can’t query the initializer from the OpenGL interface. Obviously yes, if he wanted to, he could parse the shader himself to find out. However, since there’s already a perfectly functional parser in the OpenGL implementation, and a perfectly functional interface to ask these things, there’s no reason for him to do that manually.

Exactly.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.