View Full Version : Value of __VERSION__?

02-05-2007, 06:46 AM
I've either discovered a bug in Nvidia's GLSL compiler, or I'm misunderstanding the intention of __VERSION__. I have a shader that I want to compile differently depending on the supported shading language version. One path uses transpose (introduced in 1.20), and the other path does not. I have the following at the start of my shader:

#if __VERSION__ >= 120
#version 120
#endifHowever, even on a compiler that supports 1.20, this path is never activiated. If I move the #version statement before the #if, it gets activated. This seems counter intuitive, and somewhat useless. I looked at the GLSL 1.20 spec, and it seems to indicate that __VERSION__ should be 120 regardless of any #version statement.

What's the real scoop?

02-05-2007, 11:23 AM
It is the "special" about the nvidia implementation, it is not GLSL-conformant by default. You can read it here: http://developer.download.nvidia.com/opengl/glsl/glsl_release_notes.pdf

02-05-2007, 04:44 PM
From the spec:
The #version directive must occur in a shader before anything else, except for comments and white space.

One thing I would like to know is if the __VERSION__ define is based on what is at the top of the file (the #version) or if it is based on what the compiler supports.

02-06-2007, 06:11 AM
It is the version you define.

02-06-2007, 04:29 PM
Perhaps the spec should be updated to make this clearer. (as both idr and myself were confused about this)

02-07-2007, 08:12 AM
That and it seems pretty much useless. Gosh, if I have to tell it the version, why do I need a variable to tell me what I told it? I don't see how that helps developers write shaders that support different code paths on different compiler versions. :(

02-08-2007, 01:27 AM
Maybe the idea is to give the developer some control over the compile from the shader itself, analogous to being able to specify the shader model compile target in a D3D effect. I've not even used this feature yet, but that's my guess.

It does seem a bit backwards ;-)