gl_LightSource[i] and catalyst 4.10

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.

I haven’t been able to reproduce the problem. Could you post the entire shader and the fragment shader as well?

Vertex shader:

void main()
{	
  gl_Position = ftransform(); 
  for (int i=0;i<8;i++)
    gl_FrontColor+=gl_LightSource[i].diffuse;
}

Fragment shader:

void main()
{
	gl_FragColor = gl_Color;
}

While for instance this vertex shader compiles fine:

uniform gl_LightSourceParameters my_LightSource[gl_MaxLights];

void main()
{	
  gl_Position = ftransform(); 
  for (int i=0;i<8;i++)
    gl_FrontColor+=my_LightSource[i].diffuse;
}

This particular example is on the 8.07/4702 drivers

Well, it works just fine for me so I don’t know what’s wrong. Do you have a sample application you could send me at epersson ‘at’ ati.com?

Hi,

I get excatly the same problem with two different computers
1- Ati X800XT 4.11
2- Ati X600XT 4.12

Any Idea ?
Thanks
Cedric

It turned out that it works for the very first shader compilation in a context but not after that, and it’s still there in the 8.09 beta.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.