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: Max Varying float?

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    21

    Max Varying float?

    I have a shader with 41 varying float. When I queried the MAX_VARYING_FLOATS from my driver with glGet it returned a 44.

    However when the program goes to link it says that I have too many varying floats. Obviously, there's too many, but is there an accurate way to gauge what the real maximum is.

    My varying variable are:
    Code :
    varying vec4 LightDir[8];
    varying vec3 n1;
    varying vec3 t1;
    varying vec3 b1;
    Running on a Radeon 9600 Pro, using the latest catalyst drivers.

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    21

    Re: Max Varying float?

    I dropped the number of elements in in LightDir down to 2, for a grand total of 13 varying variables. And I'm starting to wonder if, since the minimum number of allowed varying floats in 32, there isn't something wrong with my shader program or something else.

    help please.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: Max Varying float?

    The number of varying floats is a querryable limitation, as you know. This means the number of total floats that you ask for in all your varying variables, not the number of varying variables you delcare. A "varying vec4" takes 4 floats.

    Add to this that, for the sake of easy compilation, plenty of glslang compilers restrict you to a specific number of varying variables as well. This is typically 8, though I think NV40's give you 10.

    So, a "varying vec4 Foo[8]" takes 8 variables worth of floats, as well as 32 total varying floats.

  4. #4
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: Max Varying float?

    keep in mind varying is practically everything that u pass from vertex shader->fragment not just the varying ... stuff
    thus texture coord etc are counted
    eg (quasi syntax)
    vs
    gl_TexCoord = texcoord0; // bang thats 4 varying floats used

    fs
    texcoord[0]

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2003
    Posts
    21

    Re: Max Varying float?

    Well it looks like my 9600 Pro only let's me have ten.

    It works with

    Code :
    varying vec4 LighPos;
    varying vec4 SpotPos;
    varying vec2 foo;
    But not with:
    Code :
    varying vec4 LighPos;
    varying vec4 SpotPos;
    varying vec3 foo;
    Anyway around this?

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: Max Varying float?

    adamnation,

    you must be using built in varyings as well. On The 9x00, the usable varying amount seems to be 32.

    So, a "varying vec4 Foo[8]" takes 8 variables worth of floats, as well as 32 total varying floats.
    I think the hw (9x00) support 8 vec4 interpolators and the NV40, 10.
    glGet(GL_MAX_TEXTURE_COORDS) will probably tell you that.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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