diff options
author | Kenneth Graunke <[email protected]> | 2012-03-28 14:00:42 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2012-04-02 14:15:19 -0700 |
commit | 0405bd08ca0e01ebc68891ee1ff47d320983f775 (patch) | |
tree | 1b4691509a43bad878dc622b754dee5f952d5c4a /src/glsl/loop_analysis.h | |
parent | 252d3118dd40e9e3c577702b4c65a2d6cfd343b6 (diff) |
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 <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/loop_analysis.h')
-rw-r--r-- | src/glsl/loop_analysis.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h index 229730836a8..8bed1db0210 100644 --- a/src/glsl/loop_analysis.h +++ b/src/glsl/loop_analysis.h @@ -122,10 +122,16 @@ public: */ unsigned num_loop_jumps; + /** + * Whether this loop contains any function calls. + */ + bool contains_calls; + loop_variable_state() { this->max_iterations = -1; this->num_loop_jumps = 0; + this->contains_calls = false; this->var_hash = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); } |