Uniform array length (OpenGL ES GLSL 1.00)

If anyone can confirm the following behaviour…

Upload:

glUniform1iv(GetUniformLocation(“g_Ints”), 8, (GLint*)&m_Ints[0]);
glUniform2fv(GetUniformLocation(“g_Vecs”), 8, (GLfloat*)&m_Floats[0]);

Shader:

uniform int g_Ints[8];
uniform vec2 g_Vecs[8];

main
{
int l_Int = g_Ints[0]; // Ok
l_Int = g_Ints[1]; // Not Ok. Generates link error: “internal error: inconsistent location assignment for uniform g_Ints[1]”
vec2 l_Vec = g_Vecs[4];// Ok!
}

So I can not index uniform arrays of standard types beyond the first element, but I can for vec arrays?!
I tried with floats and booleans, the same result.
This doesn’t make sense to me.

Thoughts anybody?

Thanks!

Ok, some further investigation unveiled the real problem:

#define INDEX 1
uniform int g_Ints[8];

main
{
int l_Int = g_Ints[0]; // Ok

int l_Int = g_Ints[1]; // Not Ok. Generates link error: “internal error: inconsistent location assignment for uniform g_Ints[1]”

int l_Int = g_Ints[INDEX]; // Not Ok. Generates link error: “internal error: inconsistent location assignment for uniform g_Ints[1]”

int l_Index = 1;
int l_Int = g_Ints[l_Index]; // Not Ok. Generates link error: “internal error: inconsistent location assignment for uniform g_Ints[1]”

for (int l_Index = 0; l_Index < 8; ++l_Index)
{
l_Int = g_Ints[l_Index]; // Ok!
}
}

Looks like a driver bug to me.
If the preprocessor/compiler produces resolvable code, a boundary check seems to be triggered that ignores the fact that the uniform is an array.

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