PDA

View Full Version : Looping in GLSL



lemme_say_it
08-02-2005, 04:09 AM
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 ?

xfigpower
08-02-2005, 04:40 AM
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?

lemme_say_it
08-02-2005, 05:31 AM
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 ?

xfigpower
08-02-2005, 05:59 AM
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!

V-man
08-02-2005, 06:41 AM
"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.

lemme_say_it
08-02-2005, 07:05 AM
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 ??

Korval
08-02-2005, 10:26 AM
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.

Humus
08-02-2005, 03:35 PM
Could you post the loop in question? Some loops will work, such as for instance:


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:


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

}

Obli
08-05-2005, 08:17 AM
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.

V-man
08-05-2005, 08:26 PM
[quote]Originally posted by Obli:
[B]
// 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);
}

Megalomaniac
08-12-2005, 05:19 AM
As Humus stated looping is definitely possible in SM2 however it has to be static (i.e. the conditions are known at compile time) not dynamic (i.e. the conditions are NOT known at compile time) as the compiler unrolls the loop. My guess would be you’re trying to loop on a variable whose value is not known at compile time. There is another potential problem you can get because loops are unrolled. The final ASM will contain the same set of instructions repeated however many times the loop specified. Therefore the loop will eat up a many more instructions than you may expect. So a loop which compiles to say 3 ASM instructions, when repeated 10 times suddenly becomes 30 ASM instructions which you might not expect if you’re familiar with dynamic loops on SM3.