Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Looping in GLSL

  1. #1
    Junior Member Newbie
    Join Date
    May 2005
    Location
    India
    Posts
    7

    Looping in GLSL

    Hi
    Am writing a fragment shader and used a for loop in it which seemed to have caused the problem .
    The info messages states :
    Link Successful. The shader will now in software - unsupported language element used.

    I have Suse9.3 installed on my PC with ATI Radeon X800 graphics subsystem on it.

    Can anybody help me in figuring out the possible problem ?

  2. #2
    Junior Member Newbie
    Join Date
    Jun 2005
    Location
    France
    Posts
    11

    Re: Looping in GLSL

    flow control is very much like C++. Just "goto", label and "switch" aren't be supported. I use for-statement and there is no problem.

    can you give us more details about what is doing this looping?

  3. #3
    Junior Member Newbie
    Join Date
    May 2005
    Location
    India
    Posts
    7

    Re: Looping in GLSL

    Hi
    Thanks for replying.
    Am trying to implement tricubic interpolation and thought it w'ld be better if i sampled texture values in a "for" loop.
    Then the error (unsupported language element) came, after which i tried a simple for-loop in another shader which was working fine otherwise , the error came in the second shader too.
    I tried the same shader on NVidia Geforce6600 graphics subsystem and it is working fine...
    So can the problem be with ATI graphics card ??
    On which graphics card did u tried implementing for loop ?

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2005
    Location
    France
    Posts
    11

    Re: Looping in GLSL

    Sorry, I use NVidia geForceFX5700 and it seems to be due to your graphics subsystem.
    I have ATI Radeon 9800 and lots of my shaders run only on software. For example, with a basic Phong shading, I had 0,15 FPS against 30 with my NVidia...

    In a nutshell, I can't help you Sorry!

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

    Re: Looping in GLSL

    "unsupported language element used."

    This means the X800 can't do it. The X800 and the like don't support looping.
    The compiler tries to expand when it can, but basically it's telling you it can't expand.
    ------------------------------
    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);

  6. #6
    Junior Member Newbie
    Join Date
    May 2005
    Location
    India
    Posts
    7

    Re: Looping in GLSL

    Hi
    It seems like X800 doesnt support "for loop" but can it be confirmed because using a for loop is a basic need of writing any modularized shader.
    And if ATI doesnt supports it then we should take care about not using for loop while writing shaders in GLSL.

    And c'ld there be any reason to not support "for Loop" by ATI ??

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

    Re: Looping in GLSL

    And c'ld there be any reason to not support "for Loop" by ATI ??
    Because their fragment-shader hardware doesn't support conditional branches. It's really that simple.

    Neither does the hardware on GeForceFX 5xxx cards. But GeForce 6xxx and 7xxx cards do.

    No currently available ATi card supports looping in fragment shaders. Only R520 based cards will, and those may not see a release this year.

  8. #8
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,444

    Re: Looping in GLSL

    Could you post the loop in question? Some loops will work, such as for instance:

    Code :
    for (int i = 0; i < 5; i++){
     
    }
    In this case it's static and can be unrolled by the driver. If it on the other hand looks something like this it's not going to work because the driver can't know the value of texCoord.x at compile time:

    Code :
    for (int i = 0; i < int(texCoord.x); i++){
     
    }

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    628

    Re: Looping in GLSL

    Originally posted by V-man:
    This means the X800 can't do it. The X800 and the like don't support looping.
    I'm quite surprised from that. I was pretty sure it could. Isn't X800 Shader model 2? I was thinking Shader model 3 was only instancing and longer execution with higher precision... well, I obviously was wrong.

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

    Re: Looping in GLSL

    [quote]Originally posted by Obli:
    [B]
    Code :
    // perform procedural mandelbrot
        for (iter = 0.0; iter < MaxIterations &amp;&amp; r2 < 4.0; ++iter)
        {
            float tempreal = real;
     
            real = (tempreal * tempreal) - (imag * imag) + cReal;
            imag = 2.0 * tempreal * imag + cImag;
            r2   = (real * real) + (imag * imag);
        }
    ------------------------------
    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
  •