I was testing a new feature on my Nexus 4/Adreno 320, driver version CL@3776187
and noticed that calling this
glGetProgramiv( ProgramHandle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &MaxLength );
kind of returns me (probably) the length of one of the uniforms from a uniform block, but not the maximum of them so I kind of have to hardcode a max length in which is rather annoying.
I will add that calls to glBindBufferRange works as expected ( in multiples of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT which is really small on Adreno, like 4 )
One more weird thing I found is that putting a structure inside a uniform block sometimes fails compilation. Got this
struct Light
{
vec3 Position;
int LightType;
vec3 Direction;
vec3 Attenuation;
vec3 Ambient;
vec3 Diffuse;
vec3 Specular;
float Intensity;
};
uniform PerFrameBuffer
{
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
uniform mat4 WorldMatrix;
uniform mat4 InverseWorldMatrix;
uniform mat4 ShadowViewMatrix;
uniform vec4 MaterialColor;
uniform Light Light0;
};
void ComputeLight( Light LightProperties, vec3 WorldPosition, vec3 Normal, vec3 WorldViewVector,
inout vec3 TotalAmbient, inout vec3 TotalDiffuse, inout vec3 TotalSpecular){
....
}
And then it says
ERROR: 0:258: 'ComputeLight' : no matching overloaded function found
As if the type is wrong or something. I'll add that the structure has some problems on Apple's reference driver too, it says the uniform types are mismatching, so I don't know what it wants cause it's the final variable and it doesn't even matter what other alignment comes in play. On desktop AMD hardware works flawless though.
Some interesting observations
We haven't seen problems reported with GL_ACTIVE_UNIFORM_MAX_LENGTH.
Can you put together a sample app with a shader that has the uniforms for which the length is incorrectly reported?
Also include the ComputeLight example. Structures should be able to passed as parameters, so likely something else could be affecting the compiler.