Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Value of __VERSION__?

  1. #1
    Junior Member Regular Contributor
    Join Date
    May 2002
    Location
    Portland, OR
    Posts
    221

    Value of __VERSION__?

    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:

    Code :
    #if __VERSION__ >= 120
    #define USE_TRANSPOSE_PATH
    #version 120
    #endif
    However, 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?

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,932

    Re: Value of __VERSION__?

    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...ease_notes.pdf

  3. #3
    Senior Member OpenGL Pro sqrt[-1]'s Avatar
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    1,000

    Re: Value of __VERSION__?

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2005
    Location
    Poland
    Posts
    29

    Re: Value of __VERSION__?

    It is the version you define.

  5. #5
    Senior Member OpenGL Pro sqrt[-1]'s Avatar
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    1,000

    Re: Value of __VERSION__?

    Perhaps the spec should be updated to make this clearer. (as both idr and myself were confused about this)

  6. #6
    Junior Member Regular Contributor
    Join Date
    May 2002
    Location
    Portland, OR
    Posts
    221

    Re: Value of __VERSION__?

    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.

  7. #7
    Advanced Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    739

    Re: Value of __VERSION__?

    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 ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •