Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: uniform array length (OpenGL ES GLSL 1.00)

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    4

    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!
    Last edited by Serge van Keulen; 05-31-2013 at 07:42 AM.

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •