With catalyst 4.10 and something like the following I get this error:
for (int i=0;i<8;i++)
color+=gl_LightSource[i].diffuse
ERROR: 0:39: '[' : array must be redeclared with a size before being indexed with a variable
If I use my own declared uniform array in the same way it works fine, and the compiler does not allow me to redeclare the gl_LightSource array. Ofcourse constant indices works fine too (and IMHO this kind of indexing is quite “constant”/unrollable too - as least as long it looks like this).
Can I somehow set the size of the gl_LightSource array or is it simply a driver bug?
This is a compiler issue. ATI hardware is not able to run dynamic loops so the compiler gives you an error because you use a loop. It seems that ATIs compiler doesn’t check if the loop can be statically unrolled as it is the case in you example.
No, It is able to do dynamic branching in the vertex shader (and also able to unroll loops in the fragment shader), and as said, if I use my own similar uniform array instead of gl_LightSource it works fine, even with more dynamic indexing. So unless I am missing something it seems there is something wrong with the built in gl_LightSource declaration.