PDA

View Full Version : GL_MAX_VARYING_FLOATS_ARB



eyebex
05-25-2005, 01:31 AM
The value of GL_MAX_VARYING_FLOATS_ARB is 32 on my hardware. That means I can use up to 32 varying float variables in the vertex shader that are interpolated and passed into the pixel shader. Does "32" only refer to user-defined varying varibles, or does "32" get reduced to "28" if I use gl_Color (or any of the other built-in varying variables) in the pixel shader?

Relic
05-25-2005, 01:39 AM
I found that gl_TexCoord[0-7] share slots with general varyings on NVIDIA's implementation.
The other inbuilt varyings have own slots.
Means, the 32 floats are implemented as 8*vec4 there. Depending on how clever the varying packing is (didn't check) you might not get more than 8 varyings altogether and need to do the packing yourself or use only inbuilt varyings throughout.

eyebex
05-25-2005, 03:17 AM
Thanks. From what I know, my hardware (Quadro FX 4400) has 10 interpolators in hardware, each capable of handling float4 / vec4. That totals in 40 floats. Where are the other 40-32=8 floats gone? I guess these are always used for gl_Color and gl_SecondaryColor, right? What about gl_FogFragCoord then? This is only a single float, but no interpolators are left for it (until it shares slots like gl_TexCoord[]).

Relic
05-25-2005, 03:49 AM
Quadro FX 4400? :cool:
I don't think 10 is correct. According to the fragment program or GLSL specs it has at least 12: gl_FragCoord, gl_Color, gl_SecondaryColor, gl_FogFragCoord, gl_TexCoord[0-7].

Korval
05-25-2005, 01:21 PM
FragCoord and FogFragCoord are both scalars, not vectors.

The reason gl_Color and gl_SecondaryColor aren't listed is two-fold. First, these are special varyings, which exist explicitly by the specification outside of the regular float interpolators. Second, some hardware (possibly not an issue anymore, but I know it was on GeForce3/4's) uses fewer bits for interpolating the two colors, as these are specifically for color values, rather than arbitrary floats. I don't know if the second issue still stands today, though.

Humus
05-25-2005, 02:21 PM
Originally posted by Relic:
I found that gl_TexCoord[0-7] share slots with general varyings on NVIDIA's implementation.I expect that to be true on all implementations.

Humus
05-25-2005, 02:26 PM
Originally posted by Korval:
Second, some hardware (possibly not an issue anymore, but I know it was on GeForce3/4's) uses fewer bits for interpolating the two colors, as these are specifically for color values, rather than arbitrary floats. I don't know if the second issue still stands today, though.It's true on ATI cards at least. Also, the hardware can interpolate one regular interpolator and one color per cycle. So in some obscure situations where you manage to consume more than one interpolator per instruction it can be a performance benefit to use a color interpolator instead of another generic interpolator.

Relic
05-29-2005, 10:23 PM
Originally posted by Korval:
FragCoord and FogFragCoord are both scalars, not vectors.
Not true. GLSL spec:
"The variable gl_FragCoord is available as a read-only variable from within fragment shaders and it holds the window relative coordinates x, y, z, and 1/w values for the fragment."