summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-08-10 20:42:29 +1000
committerTimothy Arceri <[email protected]>2017-08-11 15:44:08 +1000
commit77f5221233ea427b622af46831feed438e0dd59e (patch)
tree01b42678b12c9fb954a4fb79f176d7f594498d46 /src/mesa/state_tracker
parentd4f79e995f180239c5d14e8493de9aac5a9e6833 (diff)
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 <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index bada7f4ea80..e8f7ecac929 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2835,7 +2835,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_array *ir)
int element_size = type_size(ir->type);
bool is_2D = false;
- index = ir->array_index->constant_expression_value();
+ index = ir->array_index->constant_expression_value(ralloc_parent(ir));
ir->array->accept(this);
src = this->result;
@@ -4137,7 +4137,10 @@ glsl_to_tgsi_visitor::calc_deref_offsets(ir_dereference *tail,
case ir_type_dereference_array: {
ir_dereference_array *deref_arr = tail->as_dereference_array();
- ir_constant *array_index = deref_arr->array_index->constant_expression_value();
+
+ void *mem_ctx = ralloc_parent(deref_arr);
+ ir_constant *array_index =
+ deref_arr->array_index->constant_expression_value(mem_ctx);
if (!array_index) {
st_src_reg temp_reg;