glsl: pass mem_ctx to constant_expression_value(...) and friends
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 10 Aug 2017 10:42:29 +0000 (20:42 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 11 Aug 2017 05:44:08 +0000 (15:44 +1000)
commit77f5221233ea427b622af46831feed438e0dd59e
tree01b42678b12c9fb954a4fb79f176d7f594498d46
parentd4f79e995f180239c5d14e8493de9aac5a9e6833
glsl: pass mem_ctx to constant_expression_value(...) and friends

The main motivation for this is that threaded compilation can fall
over if we were to allocate IR inside constant_expression_value()
when calling it on a builtin. This is because builtins are shared
across the whole OpenGL context.

f81ede469910d worked around the problem by cloning the entire
builtin before constant_expression_value() could be called on
it. However cloning the whole function each time we referenced
it lead to a significant reduction in the GLSL IR compiler
performance. This change along with the following patch
helps fix that performance regression.

Other advantages are that we reduce the number of calls to
ralloc_parent(), and for loop unrolling we free constants after
they are used rather than leaving them hanging around.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
22 files changed:
src/compiler/glsl/ast_array_index.cpp
src/compiler/glsl/ast_function.cpp
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/ast_type.cpp
src/compiler/glsl/ir.h
src/compiler/glsl/ir_constant_expression.cpp
src/compiler/glsl/linker.cpp
src/compiler/glsl/loop_controls.cpp
src/compiler/glsl/loop_unroll.cpp
src/compiler/glsl/lower_buffer_access.cpp
src/compiler/glsl/lower_distance.cpp
src/compiler/glsl/lower_tess_level.cpp
src/compiler/glsl/lower_vec_index_to_swizzle.cpp
src/compiler/glsl/lower_vector_derefs.cpp
src/compiler/glsl/lower_vector_insert.cpp
src/compiler/glsl/opt_algebraic.cpp
src/compiler/glsl/opt_constant_folding.cpp
src/compiler/glsl/opt_constant_propagation.cpp
src/compiler/glsl/opt_constant_variable.cpp
src/compiler/glsl/opt_if_simplification.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp