grisha

12-07-2004, 11:45 AM

Simple question about glsl standard (or about generic compiler included in ShaderDesigner):

Why is it illegal to use expressions with built-in functions to initialize a constant? For example this shader:

const float f = sqrt( 0.5 ); // ERROR: 0: 1: '=' : assigning non-constant to 'const float'

void main()

{

gl_FragColor = vec4( f );

}In GLSLangSpec.Full.1.10.59.pdf sqrt function defined as

genType sqrt (genType x)so if x have type 'const float' so return type should also be 'const float', isn't it?

Yes, I can remove 'const' and it will compile, but I'm just curious - is this error correct according to standard?

PS. Nvidia compiler works fine with this code.

Why is it illegal to use expressions with built-in functions to initialize a constant? For example this shader:

const float f = sqrt( 0.5 ); // ERROR: 0: 1: '=' : assigning non-constant to 'const float'

void main()

{

gl_FragColor = vec4( f );

}In GLSLangSpec.Full.1.10.59.pdf sqrt function defined as

genType sqrt (genType x)so if x have type 'const float' so return type should also be 'const float', isn't it?

Yes, I can remove 'const' and it will compile, but I'm just curious - is this error correct according to standard?

PS. Nvidia compiler works fine with this code.