diff options
author | Timothy Arceri <[email protected]> | 2017-08-10 20:42:29 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-08-11 15:44:08 +1000 |
commit | 77f5221233ea427b622af46831feed438e0dd59e (patch) | |
tree | 01b42678b12c9fb954a4fb79f176d7f594498d46 /src/compiler/glsl/lower_vec_index_to_swizzle.cpp | |
parent | d4f79e995f180239c5d14e8493de9aac5a9e6833 (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/compiler/glsl/lower_vec_index_to_swizzle.cpp')
-rw-r--r-- | src/compiler/glsl/lower_vec_index_to_swizzle.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/compiler/glsl/lower_vec_index_to_swizzle.cpp b/src/compiler/glsl/lower_vec_index_to_swizzle.cpp index b49255e05d1..fdbad16a34f 100644 --- a/src/compiler/glsl/lower_vec_index_to_swizzle.cpp +++ b/src/compiler/glsl/lower_vec_index_to_swizzle.cpp @@ -63,11 +63,12 @@ ir_vec_index_to_swizzle_visitor::handle_rvalue(ir_rvalue **rv) if (expr == NULL || expr->operation != ir_binop_vector_extract) return; - ir_constant *const idx = expr->operands[1]->constant_expression_value(); + void *mem_ctx = ralloc_parent(expr); + ir_constant *const idx = + expr->operands[1]->constant_expression_value(mem_ctx); if (idx == NULL) return; - void *ctx = ralloc_parent(expr); this->progress = true; /* Page 40 of the GLSL 1.20 spec says: @@ -87,7 +88,7 @@ ir_vec_index_to_swizzle_visitor::handle_rvalue(ir_rvalue **rv) const int i = CLAMP(idx->value.i[0], 0, (int) expr->operands[0]->type->vector_elements - 1); - *rv = new(ctx) ir_swizzle(expr->operands[0], i, 0, 0, 0, 1); + *rv = new(mem_ctx) ir_swizzle(expr->operands[0], i, 0, 0, 0, 1); } bool |