Loop unroll count limit

Hi shader touchdesigners!

Today i was tweaking a fractal noise inside touchdesigner GLSL TOP and, in a line where i’ve tried to put a for loop function, the info text pops me up this warning:

What it is mean with “unrolling loop”?
There is a way to break up that limit count?
If not, this behavior depends on what?

Warnings like this come from the driver, so it’s entirely dependent on your GPU/driver version.

Unrolling a loop basically means copying the code N times, once for each loop. It’s a compiler optimization that can occur. It can be faster than a real loop since there is no comparison to determine when the loop is done, and the compiler can potentially optimized some of the operation between the loops, instead of doing one loop at a time.
Likely you can split your loop into two smaller ones, or just ignore the warning.

Thanks malcolm for this answer!

So if it relates to driver version this behaviour could change with updates?
Or you could customize it in some way with some driver settings that i ignore?

About:

You mean something like this?

for(int i = 1; i < 4096; i++) { a *= b; c = ceil(d * a); e = func(a, c); return e; } for(int i = 1; i < 4096; i++) { a *= b; c = ceil(d * a); e = func(a, c); return e; }

To do a “for loop” 8192 times avoiding that driver bound?
Sorry if this could be a dumb or a nonsense question, it is just for me a simple clarification example. Thanks anyway for your time!

This behavior could change between driver versions, and will most certainly change between GPU models. Yes, potentially you could avoid the warning doing what you wrote below, but that is still driver dependent how it compiles/optimizes that code.
Unless you really need the performance of loop unrolling, I’d likely just say you should ignore the warning.
There is nothing I can do in this case, this is entirely between your code and the driver :slight_smile: