I have encoutered what is most likely a bug in ATI’s driver.
If you have a vertex shader with the line
vec3 someUniformArray[2];
then calling glUniformLocationARB( program, “someUniformArray[0]” ) should point to the first vec3 in the array, and glUniformLocationARB( program, “someUniformArray[1]” ) should point to the second vec3. Then supplying the C/C++ array { 1.0f, 1.0f, 1.0f } to each of these separately by using glUniform3fv() should fill all 6 floats in someUniformArray with 1.0. Is this all correct?
If so, there is a bug in the way it works in the ATI drivers (BTW, I’m running Radeon 9800 Pro, Catalyst 4.9), which always give an offset with a multiple of 4 (in number of floats), as if you are using a uniform array of vec4’s.
For example, using the same uniform array as above - which is really just 6 floats - and requesting “someUniformArray[0]” from glUniformLocationARB() gives the correct location which points to the first of the 6 floats. But, requesting “someUniformArray[1]” points to the 5th float. In other words it is skipping the first 4 floats, which is only correct if the array is of vec4’s, but it happens when using vec3’s and vec2’s as well which means some values never get filled. In this case someUniformArray[1].x will not be set.
Hopefully all that makes sense. Has anyone had this problem? Is it a know issue?
Luckily, it is not too difficult to work around for the moment, the easiest way is to just use 1 big C/C++ array of all the values and updating all at once, but it would be good to have the convience of partial updates in the future.