PDA

View Full Version : "varying in / out"



hound
04-28-2011, 05:43 AM
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?

arekkusu
04-28-2011, 08:46 AM
Read the EXT_gpu_shader4 specification.

dorbie
04-28-2011, 10:45 AM
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.

dorbie
04-28-2011, 10:48 AM
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)

Alfonse Reinheart
04-28-2011, 11:07 AM
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+.

hound
04-28-2011, 11:18 AM
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.