glsl: Don't trust loop analysis in the presence of function calls.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 28 Mar 2012 21:00:42 +0000 (14:00 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 2 Apr 2012 21:15:19 +0000 (14:15 -0700)
commit0405bd08ca0e01ebc68891ee1ff47d320983f775
tree1b4691509a43bad878dc622b754dee5f952d5c4a
parent252d3118dd40e9e3c577702b4c65a2d6cfd343b6
glsl: Don't trust loop analysis in the presence of function calls.

Function calls may have side effects that alter variables used inside
the loop.  In the fragment shader, they may even terminate the shader.
This means our analysis about loop-constant or induction variables may
be completely wrong.

In general it's impossible to determine whether they actually do or not
(due to the halting problem), so we'd need to perform conservative
static analysis.  For now, it's not worth the complexity: most functions
will be inlined, at which point we can unroll them successfully.

Fixes Piglit tests:
- shaders/glsl-fs-unroll-out-param
- shaders/glsl-fs-unroll-side-effect

NOTE: This is a candidate for release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/loop_analysis.cpp
src/glsl/loop_analysis.h