This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Issue with array of uniforms in Shader Code

I am working on GLES program using ARM GLES3.0 Emulator ver 1.4.

I want to print all active uniform detail.


I ahve 25 active Uniform in my shader code, out of these 25 uniforms, second uniform is array of uniform 'uniformArray[100]'.


But when I iterate through active uniforms to see detail of each uniform, itstarts giving garbage values after first 25 uniforms( i.e after activeUniform1, uniformArray[0], uniformArray[1], uniformArray[2],... uniformArray[23] )


Please confirm if it was an issue with EGL 1.4


Parents
  • Hello SUNIL!,

    From the information you've submitted, I cannot confirm a problem with querying active uniforms in Emulator 1.4.0 and 1.4.1 releases.

    Can you give us more information about how you iterate over it?

    Relevant portions of your shaders and application code maybe?

    Please also let us know which exactly version of the Emulator you are using. When unsure, use glGetString(GL_RENDERER) to get the version info.

    In addition, please include and run he following code right after you've linked you program:

        GLint numUniforms = 0;
        GL_CHECK(glGetProgramiv(uiProgram, GL_ACTIVE_UNIFORMS, &numUniforms));
        printf("--------------------\nList of active uniforms:\n");
        for (int i = 0; i < numUniforms; i++)
        {
            // now -iteratuing through uniforms
            GLchar name[256] = { 0 };
            GLsizei len = 0;
            GLint size = 0;
            GLenum type = 0;
            GL_CHECK(glGetActiveUniform(uiProgram, i, 256, &len, &size, &type, name));
            printf("Uniform: %s, size: %d\n", name, size);
        }
    

    And let us know console output printed,

    This will help us to get closer to you particular problem.

    Thanks

    Adam

Reply
  • Hello SUNIL!,

    From the information you've submitted, I cannot confirm a problem with querying active uniforms in Emulator 1.4.0 and 1.4.1 releases.

    Can you give us more information about how you iterate over it?

    Relevant portions of your shaders and application code maybe?

    Please also let us know which exactly version of the Emulator you are using. When unsure, use glGetString(GL_RENDERER) to get the version info.

    In addition, please include and run he following code right after you've linked you program:

        GLint numUniforms = 0;
        GL_CHECK(glGetProgramiv(uiProgram, GL_ACTIVE_UNIFORMS, &numUniforms));
        printf("--------------------\nList of active uniforms:\n");
        for (int i = 0; i < numUniforms; i++)
        {
            // now -iteratuing through uniforms
            GLchar name[256] = { 0 };
            GLsizei len = 0;
            GLint size = 0;
            GLenum type = 0;
            GL_CHECK(glGetActiveUniform(uiProgram, i, 256, &len, &size, &type, name));
            printf("Uniform: %s, size: %d\n", name, size);
        }
    

    And let us know console output printed,

    This will help us to get closer to you particular problem.

    Thanks

    Adam

Children
  • Hi Sunil,

    can you provide the shader where the uniform array is declared?

    Thanks,

    Chris

  • What version of emulator you get reported by calling glGetString(GL_RENDERER); ?

  • pseudo code -

    GLint numUniforms = 0;
    GL_CHECK(glGetProgramiv(uiProgram, GL_ACTIVE_UNIFORMS, &numUniforms));
    
    
    printf("--------------------\nList of active uniforms:\n"); // numUniforms is 25 for my problem
    for (int i = 0; i < numUniforms; i++) {
        // now -iteratuing through uniforms
        GLchar name[256] = { 0 };
        GLsizei len = 0;
        GLint size = 0;
        GLenum type = 0;
        GL_CHECK(glGetActiveUniform(uiProgram, i, 256, &len, &size, &type, name));
        printf("Uniform: %s, size: %d\n", name, size);
        std::string modifiedName = getUniformName(name, size); // replaces uniformArray[0] by uniformArray
    
    
        for (i = 0; i < size; ++i) {
            std::stringstream ss;
            ss << modifiedName;
            if (size > 1) {
               ss << '[' << i << ']';
            }
    
    
        std::string elemName = ss.str();
        float uniformValue = 0.0f;
        GLint location = glGetUniformLocation(program, elemName.c_str());
        assert(location != -1);
        if (location == -1) {
            continue;
        }
        
        switch (elemType) {
            case GL_FLOAT:
            glGetUniformfv(uiProgram, location, uniformValue);
            std::cout << elemName << ":"  << uniformValue << std::endl;
    .....
    ....
    
        }
    
    
    
    
    }
    }
    
    
    
    
    Output:
    fltUniform1:1.7
    uniformArray[0]:1.5
    uniformArray[1]:1.6
    uniformArray[2]:1.3
    uniformArray[3]:1.8
    ..
    ..
    uniformArray[22]:4.8
    uniformArray[23]:4.3
    uniformArray[24]:4.3
    uniformArray[25]:4.3
    uniformArray[26]:4.3
    uniformArray[27]:4.3
    ...
    //repeats total printed uniforms become 25
    ...
    uniformArray[98]:4.3
    uniformArray[99]:4.3
    fltUniform2:-1.073742e+008
    intUniform3:-858993460
    intUniform4:-858993460
    ...