glsl: pass mem_ctx to constant_expression_value(...) and friends

Graphics / Mesa 3D Graphics Library / Mesa - Timothy Arceri [itsqueeze.com] - 11 August 2017 01:44 EDT

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.

77f5221 glsl: pass mem_ctx to constant_expression_value(...) and friends
src/compiler/glsl/ast_array_index.cpp | 2 +-
src/compiler/glsl/ast_function.cpp | 17 ++--
src/compiler/glsl/ast_to_hir.cpp | 15 ++-
src/compiler/glsl/ast_type.cpp | 7 +-
src/compiler/glsl/ir.h | 37 +++++---
src/compiler/glsl/ir_constant_expression.cpp | 114 +++++++++++++++--------
src/compiler/glsl/linker.cpp | 2 +-
src/compiler/glsl/loop_controls.cpp | 6 +-
src/compiler/glsl/loop_unroll.cpp | 2 +-
src/compiler/glsl/lower_buffer_access.cpp | 2 +-
src/compiler/glsl/lower_distance.cpp | 3 +-
src/compiler/glsl/lower_tess_level.cpp | 3 +-
src/compiler/glsl/lower_vec_index_to_swizzle.cpp | 7 +-
src/compiler/glsl/lower_vector_derefs.cpp | 3 +-
src/compiler/glsl/lower_vector_insert.cpp | 3 +-
src/compiler/glsl/opt_algebraic.cpp | 9 +-
src/compiler/glsl/opt_constant_folding.cpp | 5 +-
src/compiler/glsl/opt_constant_propagation.cpp | 3 +-
src/compiler/glsl/opt_constant_variable.cpp | 2 +-
src/compiler/glsl/opt_if_simplification.cpp | 3 +-
src/mesa/program/ir_to_mesa.cpp | 6 +-
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 +-
22 files changed, 168 insertions(+), 90 deletions(-)

Upstream: cgit.freedesktop.org


  • Share