-
GLSL while (someFunction) ... infinite loop
Hi,
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)
break;
}
... //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?
[EDIT]
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.
-
Advanced Member
Frequent Contributor
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:
http://www.rastergrid.com/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
-
Forum Rules