View Full Version : for/while statements
05-18-2004, 01:56 PM
It says my profile doesn't support for or while statements in a fragment shader.
I'm using an fx5600. most of the shader code has to run in software but am I at a loss for using fors and whiles in a fragment shader?
what do I do about this?
05-18-2004, 02:29 PM
Loops are supported in ShaderModel 3.0 (new GF 6800 support it). You have to do manual loop unrolling.
Lets someone confirm following...
In some cases compilers can do loop unrolling, but current GLSL compilers can't do this.
05-18-2004, 02:49 PM
GeForce FX hardware only supports loops in the fragment shader that can be unrolled by the compiler. So the number of iterations must be known at compile time.
In the vertex shader, you will be able to loop based off a per-vertex attribute or uniform value. This should be supported in current drivers already on all GeForce FX GPUs, see the glsl_skinning demo in SDK 7.0 for an example of this.
05-18-2004, 02:56 PM
The 3Dlabs Wildcat VP (http://www.3dlabs.com/product/wildcatvp/index.htm) series of video cards do support for/while loops.
05-18-2004, 03:40 PM
Thanks, I'm not working with the vp990 however nor have intentions to.
I have manually unrolled the loops, i was just trying to avoid that.
In my implementation the loop iteration is known at compile time, but alas...I still can't get it to compile.
A 6800 might be out of my reach at the moment. Does anyone have any knowledge of whether I'd run into the same problem on a 5950?
05-18-2004, 03:44 PM
Please post the code for your loop, it may be a simple problem that is preventing the compiler from unrolling it and giving you that error message.
05-18-2004, 05:49 PM
Does anyone have any knowledge of whether I'd run into the same problem on a 5950?The 5950 is no different functionally than the 5900. It's just a performance revision.
05-19-2004, 06:33 AM
sure, here's the loop...
//loop through all lights, compute contribution from each.
for(int i=0; i < 8.0; i++)
if(lightEnabled[i] != 0)
if(gl_LightSource[i].position.w == 0.0)
else if(gl_LightSource[i].spotCutoff == 180.0)
PointLight(i,normal, amb, diff, spec);
SpotLight(i,normal, amb, diff, spec);
}this is the exact same loop I have in a vertex shader and it works. It just doesn't like being in a fragment shader.
it's sort of weird though, if I change the 8.0 to 8 it doesn't compile.
things behave rather strangely and I'm assuming it's just due to beta drivers.
Korval - do you know if I would run into these problems on a 5900 then?
05-19-2004, 09:24 AM
I can get it too compile as long as I use "8" not "8.0" in the for loop. Are you saying it only works for you if you use "8.0"?
05-19-2004, 10:11 AM
yup, that's what I'm saying.
Interesting isn't it?
05-19-2004, 10:43 AM
Korval - do you know if I would run into these problems on a 5900 then? Nvidia uses what they call the Unified driver architecture.
That probably means you will get the same behavior across the board except they may provide the hardware support but not the software fallback in some cases.
You should all have the same driver version too!
05-19-2004, 12:50 PM
Aelund, can you send me your app? I'd like to test it against our latest GLSL implementation and see if the problem still persists.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.