[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Unused varyings.

Before I go off and play with testing on a bunch of different
configurations...is this actually a legal thing to do?

It is legal to have a varying that you never use.  It is also "legal" for the compiler to remove it.  The behavior you describe, where a removed varying causes a link error, is not legal, and possibly a Chrome or driver bug.  Try and make sure that the shaders your passing into WebGL both have the varying defined.

The GL (and ES) specs doesn't talk about "active" varyings, as there is no way for the app to know what the compiler has done during link time.  The spec does contain this text hinting that the compiler may drop varyings or pack them,

"A program whose shaders access more than MAX_VARYING_-
VECTORS worth of varying variables may fail to link, unless device-dependent op-
timizations are able to make the program fit within available hardware resources."  -- GL-ES 2.0.24 section 2.10.4.

That said, because of the way DirectX works, you should probably try and avoid unused varyings.

For further reading about varyings you can take a look at "GL_NV_transform_feedback" and "GL_EXT_transform_feedback".  In the original NVIDIA extension you had to declare that you're interested in unused varyings before link, in the EXT extension (adopted in GL 3.0) you have to declare all of your feedback data prior to link.  The end result is the same in that the compiler can remove varyings at "link" time.

-- Kenneth Waters