[Mesa-dev] [PATCH/RFC] glsl: Avoid excessive loop unrolling.

Mathias Fröhlich Mathias.Froehlich at gmx.net
Sun Jan 29 22:40:15 PST 2012


Hi,

I am trying to make the shaders from a sky scattering shader work with mesa.
One of the problems is that the shader contains a nested 16 x 32 loop with an 
instruction intensive body. The glsl loop unrolling pass is trying to unroll 
both loops since both of them have a fixed size <=32. Compiling this shader 
gets stuck in do_common_optimization (= takes more than 10 minutes) since 
unrolling and then optimizing that huge 16*32*(function body) intruction count 
kills the runtime behavour of other optimization passes.

Attached is a change that additionally skips loop unrolling if either the loop 
is a nested loop or the instruction count of the body times the constant 
iteration count exceeds the former max iteration count times 5 instructions.
This makes the above shaders at least compile within the usual fraction of a 
second.

Comments/Review?

Thanks

Mathias


More information about the mesa-dev mailing list