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 6 of 6

Thread: "varying in / out"

  1. #1
    Intern Newbie
    Join Date
    Jul 2010
    Posts
    31

    "varying in / out"

    I keep seeing shader code (often related to geometry shaders) posted around the place with varying variables specified with both varying and in / out qualifiers:

    Code :
    varying out float foo;

    The specifications (at least 4.0 which I have to hand) don't say anything about being able to use both in / out and the deprecated varying keyword. They do say "Variable declarations may have one storage qualifier specified in front of the type." Does "varying out" or "varying in" count as just one storage qualifier?

    Is there a version where this is / was valid?

  2. #2
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    871

    Re: "varying in / out"

    Read the EXT_gpu_shader4 specification.

  3. #3
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,962

    Re: "varying in / out"

    Quote Originally Posted by arekkusu
    Read the EXT_gpu_shader4 specification.
    The purpose of this forum is not to direct users at massive documents instead of answering the question.

    If you do not know the answer and cannot help then do not reply.

  4. #4
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,962

    Re: "varying in / out"

    Varying is replaced with the in and out qualifiers.

    It makes for code that is probably more consistent and more portable between vertex and fragment shaders.

    An "out" from a vertex shader becomes an "in" to a fragment shader. These are interpolated to fragment values during rasterization and so are implicitly varying. (Flat shading qualifiers aside)

  5. #5
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,932

    Re: "varying in / out"

    But that's not the answer to his question. The reason he sees shaders using syntax like "varying out" (which is not legal in 3.0+ core) is because those shaders are using EXT_gpu_shader4, which does use that syntax.

    "varying out" has the same semantic meaning as "out" in 3.0+.

  6. #6
    Intern Newbie
    Join Date
    Jul 2010
    Posts
    31

    Re: "varying in / out"

    Thanks for the replies.

    After some more digging, it appears that EXT_gpu_shader4 says:
    The fragment shader will compute values per fragment and write them to variables declared with the varying out qualifier.
    It also gives an example which has "varying out" as a declaration.

    While ARB_geometry_shader4 says:
    Additionally, the "varying in" and "varying out" qualifiers can only be used in a geometry shader.
    So I guess the use of both keywords is added purely as an extension thing, since it's only mentioned there, rather than in the core docs.

Posting Permissions

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