"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:

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?

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.

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)

1 Like

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+.

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.