You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#version100#define SAMPLER_COUNT 2uniformsampler2D samplers[SAMPLER_COUNT];
void main() {
vec4 sum =vec4(0.0);
for(int i =0; i < SAMPLER_COUNT; i++) {
sum += samplers[i];
}
gl_FragColor= sum;
}
$ glslopt -2 -f bug.glsl
Failed to compile bug.glsl:
(7,9): error: sampler arrays indexed with non-constant expressions is forbidden in GLSL 1.30 and later
(7,2): error: operands to arithmetic operators must be numeric
[...]
The following are constant-index-expressions:
Constant expressions
Loop indices as defined in section 4
[...]
Samplers
GLSL ES 1.00 supports both arrays of samplers and arrays of structures which contain samplers. In both these cases, for ES 2.0, support for indexing with a constant-index-expression is mandated but support for indexing with other values is not mandated.
So this is a bug, because I'm using a constant-index-expressions, for which support is mandated by the GLSL spec.
bug.glsl
However, according to the GLSL ES 2.0 spec Page 109 (115 in PDF): https://www.khronos.org/registry/OpenGL/specs/es/2.0/GLSL_ES_Specification_1.00.pdf:
So this is a bug, because I'm using a constant-index-expressions, for which support is mandated by the GLSL spec.
I did look into it, and the broken check is here:
glsl-optimizer/src/glsl/ast_array_index.cpp
Lines 230 to 250 in d78c3d2
This bug does not exist in a rebased fork with a more recent mesa: https://github.com/jamienicol/glsl-optimizer/
The fixed check is here.
The text was updated successfully, but these errors were encountered: