Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: GLSL while (someFunction) ... infinite loop

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2011

    GLSL while (someFunction) ... infinite loop

    I've had this issue a few times now. I'm trying to create a generator style function for iteration. A basic example would be:

    bool iter(inout int i)
    if (++i >= 10)
    return false;
    return true;

    void main()
    int i = 0;
    int canary = 100;
    while (iter(i))
    if (--canary < 0)
    ... //some code to show the value of canary

    without canary, the while loop would be infinite,
    however if I change it to
    while (iter(i) == true)
    the loop runs as expected and the canary is not triggered

    is this a known bug, am I doing something stupid, or is the
    "== true" test just the correct way to write it?
    Has anyone else experienced this?

    this happens with nvidia 460GT (290.10). I just tested with ATI 5850 (catalyst 12.3) which doesn't appear to have the issue. I'll test with 295 shortly.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007

    Re: GLSL while (someFunction) ... infinite loop

    Sounds like a driver bug as while(iter(i)) should be equivalent with while(iter(i)==true) no matter what iter does as long as iter returns a bool result.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog:

Posting Permissions

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