KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.98k stars 823 forks source link

Validating Limitations for ES 2.0, Indexing of Arrays #348

Open tksuoran opened 8 years ago

tksuoran commented 8 years ago

In https://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf it is stated that

Strictly reading the specification, type-specifier is required. If I have the following fragment shader code

int i; for (i = 0; i < 2; ++i)

I cannot use i to index uniform arrays, because type-specifier is missing inside for. I have observed that glslang allows indexing uniform arrays in this case. I would like glslang to report an error.

tksuoran commented 8 years ago

Hmm, it turns out the device which rejected the shader was actually incorrectly rejecting indexing with loop index in fragment shader, no matter what form. So I no longer care about this issue, although it would be nice to know if it is valid issue or not.

arcady-lunarg commented 1 year ago

It was intended that glslangValidator check this, however it appears that the check was implemented incorrectly and is too lax. It also allows a global variable as a loop index, which the spec language clearly prohibits.