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.

f81ede4699 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>
This commit is contained in:
Timothy Arceri
2017-08-10 20:42:29 +10:00
parent d4f79e995f
commit 77f5221233
22 changed files with 168 additions and 90 deletions

View File

@@ -154,7 +154,8 @@ ir_constant_propagation_visitor::constant_folding(ir_rvalue **rvalue)
ir_dereference_variable *var_ref = (*rvalue)->as_dereference_variable();
if (var_ref && !var_ref->type->is_array()) {
ir_constant *constant = var_ref->constant_expression_value();
ir_constant *constant =
var_ref->constant_expression_value(ralloc_parent(var_ref));
if (constant) {
*rvalue = constant;
this->progress = true;