I am writing a fragment shader for WebGL (GLSL ES 1.0) using the latest version of Chrome (and Firefox), and I wrote an iterative algorithm.
So, first of all, I found that the length of the loop is quite limited (doc says that it should be guessed at compile time, which means that it should be constant or very close).
In addition, I have to write a loop ( forbecause it is the only one that should be implemented in accordance with the standard), which is potentially long, but which is interrupted almost every time until the end.
Now I noticed that if I set a higher maximum number, compiling and binding the shader takes more time. So, if I'm not mistaken, the compiler does a unwinding cycle.
I'm not sure if something can be done, but I tried a few things and the compiler also seems to be inline even when called in a loop.
It doesn't seem to me that it usually takes a whole minute for a shader to compile almost a hundred loop iterations. Or am I doing wrong? Is a hundred iterations alternating a fragment too much for the GPU? Since it seems to work very well after compiling it.
Manux source
share