Indexing of sampler arrays

This topic contains 0 replies, has 1 voice, and was last updated by  SuneT 6 years, 5 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #30517

    SuneT
    Member

    I’m running the OpenGL ES 2.0 PC Emulator v2.08.28.0634 and have found what I think is a bug in the shader compiler. This is example fragment shader code that triggers it:

    #ifdef GL_ES
    precision mediump float;
    #endif
    uniform sampler2D uni[8];
    void main()
    {
       vec4 c = vec4(0,0,0,0);
       for (int ii = 0; ii < 8; ++ii) {
         c += texture2D(uni[ii], vec2(0.5, 0.5));
       }
       gl_FragColor = c;
    }

    [/CODE]

    Compiling this code with PVRUniSCo produces the following error:

    [CODE]

    ERROR: 0:9: ‘[ii]’ : arrays of samplers may only be indexed by a constant integer expression
    ERROR: 1 compilation errors. No code generated.
    [/CODE]

    The GLSL[1] spec mandates support for indexing arrays of samplers using “constant-index-expression”, it also provides a definition of constant-index-expression as quoted below:

    Definition:
    constant-index-expressions are a superset of constant-expressions. Constant-index-expressions can include loop indices as defined in Appendix A section 4.
    The following are constant-index-expressions:
    • Constant expressions
    • Loop indices as defined in section 4
    • Expressions composed of both of the above
    When used as an index, a constant-index-expression must have integral type.

    [1] http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf

    So I think that since loop indices are used in the TC above it should not fail to compile. Or am I missing something here?

    [CODE]

    #ifdef GL_ES
    precision mediump float;
    #endif
    uniform sampler2D uni[8];
    void main()
    {
       vec4 c = vec4(0,0,0,0);
       for (int ii = 0; ii < 8; ++ii) {
         c += texture2D(uni[ii], vec2(0.5, 0.5));
       }
       gl_FragColor = c;
    }

    [/CODE]

    Compiling this code with PVRUniSCo produces the following error:

    ERROR: 0:9: ‘[ii]’ : arrays of samplers may only be indexed by a constant integer expression
    ERROR: 1 compilation errors. No code generated.
    [/CODE]

    The GLSL[1] spec mandates support for indexing arrays of samplers using “constant-index-expression”, it also provides a definition of constant-index-expression as quoted below:

    Definition:
    constant-index-expressions are a superset of constant-expressions. Constant-index-expressions can include loop indices as defined in Appendix A section 4.
    The following are constant-index-expressions:
    • Constant expressions
    • Loop indices as defined in section 4
    • Expressions composed of both of the above
    When used as an index, a constant-index-expression must have integral type.

    [1] http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf

    So I think that since loop indices are used in the TC above it should not fail to compile. Or am I missing something here?

    [CODE]

    ERROR: 0:9: ‘[ii]’ : arrays of samplers may only be indexed by a constant integer expression
    ERROR: 1 compilation errors. No code generated.
    [/CODE]

    The GLSL[1] spec mandates support for indexing arrays of samplers using “constant-index-expression”, it also provides a definition of constant-index-expression as quoted below:

    Quote:

    Definition:
    constant-index-expressions are a superset of constant-expressions. Constant-index-expressions can include loop indices as defined in Appendix A section 4.
    The following are constant-index-expressions:
    • Constant expressions
    • Loop indices as defined in section 4
    • Expressions composed of both of the above
    When used as an index, a constant-index-expression must have integral type.

    [1] http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf

    So I think that since loop indices are used in the TC above it should not fail to compile. Or am I missing something here?

Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.