summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir.h
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/compiler/glsl/ir.h
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/compiler/glsl/ir.h')
-rw-r--r--src/compiler/glsl/ir.h37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 170759abebd..e2b72772a26 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -229,7 +229,8 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
ir_rvalue *as_rvalue_to_saturate();
@@ -1170,7 +1171,9 @@ public:
* given a list of the actual parameters and the variable context.
* Returns NULL for non-built-ins.
*/
- ir_constant *constant_expression_value(exec_list *actual_parameters, struct hash_table *variable_context);
+ ir_constant *constant_expression_value(void *mem_ctx,
+ exec_list *actual_parameters,
+ struct hash_table *variable_context);
/**
* Get the name of the function for which this is a signature
@@ -1273,7 +1276,8 @@ private:
* Returns false if the expression is not constant, true otherwise,
* and the value in *result if result is non-NULL.
*/
- bool constant_expression_evaluate_expression_list(const struct exec_list &body,
+ bool constant_expression_evaluate_expression_list(void *mem_ctx,
+ const struct exec_list &body,
struct hash_table *variable_context,
ir_constant **result);
};
@@ -1429,7 +1433,8 @@ public:
virtual ir_assignment *clone(void *mem_ctx, struct hash_table *ht) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
virtual void accept(ir_visitor *v)
{
@@ -1535,7 +1540,8 @@ public:
* If the expression cannot be constant folded, this method will return
* \c NULL.
*/
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
/**
* This is only here for ir_reader to used for testing purposes please use
@@ -1616,7 +1622,8 @@ public:
virtual ir_call *clone(void *mem_ctx, struct hash_table *ht) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
virtual void accept(ir_visitor *v)
{
@@ -1838,7 +1845,8 @@ public:
virtual ir_texture *clone(void *mem_ctx, struct hash_table *) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
virtual void accept(ir_visitor *v)
{
@@ -1935,7 +1943,8 @@ public:
virtual ir_swizzle *clone(void *mem_ctx, struct hash_table *) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
/**
* Construct an ir_swizzle from the textual representation. Can fail.
@@ -2001,7 +2010,8 @@ public:
virtual ir_dereference_variable *clone(void *mem_ctx,
struct hash_table *) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
virtual bool equals(const ir_instruction *ir,
enum ir_node_type ignore = ir_type_unset) const;
@@ -2048,7 +2058,8 @@ public:
virtual ir_dereference_array *clone(void *mem_ctx,
struct hash_table *) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
virtual bool equals(const ir_instruction *ir,
enum ir_node_type ignore = ir_type_unset) const;
@@ -2085,7 +2096,8 @@ public:
virtual ir_dereference_record *clone(void *mem_ctx,
struct hash_table *) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
/**
* Get the variable that is ultimately referenced by an r-value
@@ -2156,7 +2168,8 @@ public:
virtual ir_constant *clone(void *mem_ctx, struct hash_table *) const;
- virtual ir_constant *constant_expression_value(struct hash_table *variable_context = NULL);
+ virtual ir_constant *constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context = NULL);
virtual void accept(ir_visitor *v)
{