Maximum array size for uniform attribute not matching up

Hi folks! I did not write in the forum for a while! But I got a question now.
In my skinning shader I am using a uniform buffer for the matrices instead of a texture. It works great. Then I queried the maximum uniform side and got:


long long int value;
glGetInteger64v(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &value);

Output was 4096 on both a gtx 960 and 980, which is also confirmed by NSight. This means 4096 / 16 i should get 256 matrices in. If y try to set 256 in the shader i get compiler error (from compiling the shader not the c++), saying i got out of range and stuff, if needed I can post the full compiling error. Although I can successifully use a size up to 253. Any reason for this 3 missing matrices? (Happens on both 960 and 980).
Here is how i do it in the shader:



const int MAX_BONES = 253;
uniform mat4 mat_bones[MAX_BONES];

Any idea? Thanks a lot folks

M.

In my skinning shader I am using a uniform buffer for the matrices instead of a texture.

You say that as though it were unusual. Who uses a texture for matrices rather than a UBO or SSBO? Maybe a buffer texture…

Also, you’re not using a uniform buffer. Those are just regular uniforms. Your uniform array is not declared within a uniform-declared interface block.

Any reason for this 3 missing matrices?

Maybe you have declared other uniforms somewhere. Or maybe the implementation needed those uniforms for something.

It’s generally best not to push limits that far.

@Alfonse, sorry my terms were not precise, true I am using a uniform, not a uniform buffer. About using texture, I am not a opengl expert but talking to colleagues of mine they often told me they used texture to pass in the matrices in order to avoid the uniform size limit. Are there other or better way? I would love to know.
About the 3 missing matrices I figured might have been used for something by opengl I was curious if that thing was known, but did not think it could be an implementation specific thing. Thanks for the tip and for the answer.

I got more information on the matter if anyone is interested. Looks like the value for the max uniform size is not for any uniform array, but basically the whole memory that can be used by uniforms.

I needed to pass in an extra matrix, as soon as i added it my shader started to crash or better, give errors at compile time etc. Reducing the array size of matrices to 252 solved the problem. If i add one more matrix I need to lower to 251 and so on (doesnt matter if mat3 or mat4).

This makes sense , I am having 4 matrices + the array in my uniforms , so 252+4 = 256, which is the GPU limit.

I thought it was interesting to know

Cheers