View Full Version : calculate index expressions at run-time?

10-26-2005, 02:54 AM
I try to access different textures with a sampler2D array. My code looks like this piece:

uniform sampler2D tex_[16];
int num = int(floor(gl_FragCoord.x/5.0));
gl_FragColor = texture2D(tex_[num], fragCoord.xy);
But with the nvidia driver (81.85) I get this compiler error:

<stdlib>(9750) : error C5043: profile requires index expression to be compile-time constant

The 3Dlabs GLSL Syntax Validator checks it successfully. So is calculating an index expression at run-time a GLSL feature but not yet
implemented by nvidia?

Zulfiqar Malik
10-26-2005, 05:42 AM
The 3DLabs GLSL validator only validates the syntax of a particular shader and does not tell whether a particular shader will run on a particular hardware or not. Your shader is syntactically correct, but the value of num variable is run-time dependent and pre G7x and R5xx cannot handle such scenarios.