* index is not a constant expression, ensure that the array has a
* declared size.
*/
- ir_constant *const const_index = idx->constant_expression_value();
+ ir_constant *const const_index = idx->constant_expression_value(mem_ctx);
if (const_index != NULL && idx->type->is_integer()) {
const int idx = const_index->value.i[0];
const char *type_name = "error";
exec_list *parameters,
struct _mesa_glsl_parse_state *state)
{
+ void *mem_ctx = state;
unsigned count = 0;
foreach_list_typed(ast_node, ast, link, parameters) {
ast->set_is_lhs(true);
ir_rvalue *result = ast->hir(instructions, state);
- ir_constant *const constant = result->constant_expression_value();
+ ir_constant *const constant =
+ result->constant_expression_value(mem_ctx);
+
if (constant != NULL)
result = constant;
* instructions; just generate an ir_constant.
*/
if (state->is_version(120, 100)) {
- ir_constant *value = sig->constant_expression_value(actual_parameters,
+ ir_constant *value = sig->constant_expression_value(ctx,
+ actual_parameters,
NULL);
if (value != NULL) {
return value;
assert(result->type == desired_type);
/* Try constant folding; it may fold in the conversion we just added. */
- ir_constant *const constant = result->constant_expression_value();
+ ir_constant *const constant = result->constant_expression_value(ctx);
return (constant != NULL) ? (ir_rvalue *) constant : (ir_rvalue *) result;
}
implicitly_convert_component(ir_rvalue * &from, const glsl_base_type to,
struct _mesa_glsl_parse_state *state)
{
+ void *mem_ctx = state;
ir_rvalue *result = from;
if (to != from->type->base_type) {
}
}
- ir_rvalue *const constant = result->constant_expression_value();
+ ir_rvalue *const constant = result->constant_expression_value(mem_ctx);
if (constant != NULL)
result = constant;
instructions->push_tail(
new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
matrix, NULL));
- var->constant_value = matrix->constant_expression_value();
+ var->constant_value = matrix->constant_expression_value(ctx);
/* Replace the matrix with dereferences of its columns. */
for (int i = 0; i < matrix->type->matrix_columns; i++) {
* After doing so, track whether or not all the parameters to the
* constructor are trivially constant valued expressions.
*/
- ir_rvalue *const constant = result->constant_expression_value();
+ ir_rvalue *const constant = result->constant_expression_value(ctx);
if (constant != NULL)
result = constant;
error_emitted = true;
}
- ir_constant *cond_val = op[0]->constant_expression_value();
+ ir_constant *cond_val = op[0]->constant_expression_value(ctx);
if (then_instructions.is_empty()
&& else_instructions.is_empty()
process_array_size(exec_node *node,
struct _mesa_glsl_parse_state *state)
{
+ void *mem_ctx = state;
+
exec_list dummy_instructions;
ast_node *array_size = exec_node_data(ast_node, node, link);
return 0;
}
- ir_constant *const size = ir->constant_expression_value();
+ ir_constant *const size = ir->constant_expression_value(mem_ctx);
if (size == NULL ||
(state->is_version(120, 300) &&
array_size->has_sequence_subexpression())) {
exec_list *initializer_instructions,
struct _mesa_glsl_parse_state *state)
{
+ void *mem_ctx = state;
ir_rvalue *result = NULL;
YYLTYPE initializer_loc = decl->initializer->get_location();
* GLSL ES 3.00.4 spec. This is a new limitation for these GLSL
* versions.
*/
- ir_constant *constant_value = rhs->constant_expression_value();
+ ir_constant *constant_value =
+ rhs->constant_expression_value(mem_ctx);
+
if (!constant_value ||
(state->is_version(430, 300) &&
decl->initializer->has_sequence_subexpression())) {
} else
initializer_type = rhs->type;
- var->constant_initializer = rhs->constant_expression_value();
+ var->constant_initializer = rhs->constant_expression_value(mem_ctx);
var->data.has_initializer = true;
/* If the declared variable is an unsized array, it must inherrit
* comparison of cached test expression value to case label.
*/
ir_rvalue *const label_rval = this->test_value->hir(instructions, state);
- ir_constant *label_const = label_rval->constant_expression_value();
+ ir_constant *label_const = label_rval->constant_expression_value(ctx);
if (!label_const) {
YYLTYPE loc = this->test_value->get_location();
ir_rvalue *const ir = const_expression->hir(&dummy_instructions, state);
- ir_constant *const const_int = ir->constant_expression_value();
+ ir_constant *const const_int =
+ ir->constant_expression_value(ralloc_parent(ir));
+
if (const_int == NULL || !const_int->type->is_integer()) {
YYLTYPE loc = const_expression->get_location();
_mesa_glsl_error(&loc, state, "%s must be an integral constant "
ir_rvalue *const ir = const_expression->hir(&dummy_instructions, state);
- ir_constant *const const_int = ir->constant_expression_value();
+ ir_constant *const const_int =
+ ir->constant_expression_value(ralloc_parent(ir));
if (const_int == NULL || !const_int->type->is_integer()) {
_mesa_glsl_error(loc, state, "%s must be an integral constant "
"expression", qual_indentifier);
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();
* 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
* 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);
};
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)
{
* 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
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)
{
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)
{
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.
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;
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;
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
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)
{
ir_constant *
-ir_rvalue::constant_expression_value(struct hash_table *)
+ir_rvalue::constant_expression_value(void *mem_ctx, struct hash_table *)
{
assert(this->type->is_error());
return NULL;
}
ir_constant *
-ir_expression::constant_expression_value(struct hash_table *variable_context)
+ir_expression::constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context)
{
+ assert(mem_ctx);
+
if (this->type->is_error())
return NULL;
memset(&data, 0, sizeof(data));
for (unsigned operand = 0; operand < this->num_operands; operand++) {
- op[operand] = this->operands[operand]->constant_expression_value(variable_context);
+ op[operand] =
+ this->operands[operand]->constant_expression_value(mem_ctx,
+ variable_context);
if (!op[operand])
return NULL;
}
components = op[1]->type->components();
}
- void *ctx = ralloc_parent(this);
-
/* Handle array operations here, rather than below. */
if (op[0]->type->is_array()) {
assert(op[1] != NULL && op[1]->type->is_array());
switch (this->operation) {
case ir_binop_all_equal:
- return new(ctx) ir_constant(op[0]->has_value(op[1]));
+ return new(mem_ctx) ir_constant(op[0]->has_value(op[1]));
case ir_binop_any_nequal:
- return new(ctx) ir_constant(!op[0]->has_value(op[1]));
+ return new(mem_ctx) ir_constant(!op[0]->has_value(op[1]));
default:
break;
}
#include "ir_expression_operation_constant.h"
- return new(ctx) ir_constant(this->type, &data);
+ return new(mem_ctx) ir_constant(this->type, &data);
}
ir_constant *
-ir_texture::constant_expression_value(struct hash_table *)
+ir_texture::constant_expression_value(void *mem_ctx, struct hash_table *)
{
/* texture lookups aren't constant expressions */
return NULL;
ir_constant *
-ir_swizzle::constant_expression_value(struct hash_table *variable_context)
+ir_swizzle::constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context)
{
- ir_constant *v = this->val->constant_expression_value(variable_context);
+ assert(mem_ctx);
+
+ ir_constant *v = this->val->constant_expression_value(mem_ctx,
+ variable_context);
if (v != NULL) {
ir_constant_data data = { { 0 } };
}
}
- void *ctx = ralloc_parent(this);
- return new(ctx) ir_constant(this->type, &data);
+ return new(mem_ctx) ir_constant(this->type, &data);
}
return NULL;
}
ir_constant *
-ir_dereference_variable::constant_expression_value(struct hash_table *variable_context)
+ir_dereference_variable::constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context)
{
assert(var);
+ assert(mem_ctx);
/* Give priority to the context hashtable, if it exists */
if (variable_context) {
if (!var->constant_value)
return NULL;
- return var->constant_value->clone(ralloc_parent(var), NULL);
+ return var->constant_value->clone(mem_ctx, NULL);
}
ir_constant *
-ir_dereference_array::constant_expression_value(struct hash_table *variable_context)
+ir_dereference_array::constant_expression_value(void *mem_ctx,
+ struct hash_table *variable_context)
{
- ir_constant *array = this->array->constant_expression_value(variable_context);
- ir_constant *idx = this->array_index->constant_expression_value(variable_context);
+ assert(mem_ctx);
+
+ ir_constant *array = this->array->constant_expression_value(mem_ctx, variable_context);
+ ir_constant *idx = this->array_index->constant_expression_value(mem_ctx, variable_context);
if ((array != NULL) && (idx != NULL)) {
- void *ctx = ralloc_parent(this);
if (array->type->is_matrix()) {
/* Array access of a matrix results in a vector.
*/
break;
}
- return new(ctx) ir_constant(column_type, &data);
+ return new(mem_ctx) ir_constant(column_type, &data);
} else if (array->type->is_vector()) {
const unsigned component = idx->value.u[0];
- return new(ctx) ir_constant(array, component);
+ return new(mem_ctx) ir_constant(array, component);
} else {
const unsigned index = idx->value.u[0];
- return array->get_array_element(index)->clone(ctx, NULL);
+ return array->get_array_element(index)->clone(mem_ctx, NULL);
}
}
return NULL;
ir_constant *
-ir_dereference_record::constant_expression_value(struct hash_table *)
+ir_dereference_record::constant_expression_value(void *mem_ctx,
+ struct hash_table *)
{
- ir_constant *v = this->record->constant_expression_value();
+ assert(mem_ctx);
+
+ ir_constant *v = this->record->constant_expression_value(mem_ctx);
return (v != NULL) ? v->get_record_field(this->field_idx) : NULL;
}
ir_constant *
-ir_assignment::constant_expression_value(struct hash_table *)
+ir_assignment::constant_expression_value(void *mem_ctx, struct hash_table *)
{
/* FINISHME: Handle CEs involving assignment (return RHS) */
return NULL;
ir_constant *
-ir_constant::constant_expression_value(struct hash_table *)
+ir_constant::constant_expression_value(void *mem_ctx, struct hash_table *)
{
return this;
}
ir_constant *
-ir_call::constant_expression_value(struct hash_table *variable_context)
+ir_call::constant_expression_value(void *mem_ctx, struct hash_table *variable_context)
{
- return this->callee->constant_expression_value(&this->actual_parameters, variable_context);
+ assert(mem_ctx);
+
+ return this->callee->constant_expression_value(mem_ctx,
+ &this->actual_parameters,
+ variable_context);
}
-bool ir_function_signature::constant_expression_evaluate_expression_list(const struct exec_list &body,
+bool ir_function_signature::constant_expression_evaluate_expression_list(void *mem_ctx,
+ const struct exec_list &body,
struct hash_table *variable_context,
ir_constant **result)
{
+ assert(mem_ctx);
+
foreach_in_list(ir_instruction, inst, &body) {
switch(inst->ir_type) {
case ir_type_assignment: {
ir_assignment *asg = inst->as_assignment();
if (asg->condition) {
- ir_constant *cond = asg->condition->constant_expression_value(variable_context);
+ ir_constant *cond =
+ asg->condition->constant_expression_value(mem_ctx,
+ variable_context);
if (!cond)
return false;
if (!cond->get_bool_component(0))
if (!constant_referenced(asg->lhs, variable_context, store, offset))
return false;
- ir_constant *value = asg->rhs->constant_expression_value(variable_context);
+ ir_constant *value =
+ asg->rhs->constant_expression_value(mem_ctx, variable_context);
if (!value)
return false;
/* (return (expression)) */
case ir_type_return:
assert (result);
- *result = inst->as_return()->value->constant_expression_value(variable_context);
+ *result =
+ inst->as_return()->value->constant_expression_value(mem_ctx,
+ variable_context);
return *result != NULL;
/* (call name (ref) (params))*/
store, offset))
return false;
- ir_constant *value = call->constant_expression_value(variable_context);
+ ir_constant *value =
+ call->constant_expression_value(mem_ctx, variable_context);
if(!value)
return false;
case ir_type_if: {
ir_if *iif = inst->as_if();
- ir_constant *cond = iif->condition->constant_expression_value(variable_context);
+ ir_constant *cond =
+ iif->condition->constant_expression_value(mem_ctx,
+ variable_context);
if (!cond || !cond->type->is_boolean())
return false;
exec_list &branch = cond->get_bool_component(0) ? iif->then_instructions : iif->else_instructions;
*result = NULL;
- if (!constant_expression_evaluate_expression_list(branch, variable_context, result))
+ if (!constant_expression_evaluate_expression_list(mem_ctx, branch,
+ variable_context,
+ result))
return false;
/* If there was a return in the branch chosen, drop out now. */
}
ir_constant *
-ir_function_signature::constant_expression_value(exec_list *actual_parameters, struct hash_table *variable_context)
+ir_function_signature::constant_expression_value(void *mem_ctx,
+ exec_list *actual_parameters,
+ struct hash_table *variable_context)
{
+ assert(mem_ctx);
+
const glsl_type *type = this->return_type;
if (type == glsl_type::void_type)
return NULL;
const exec_node *parameter_info = origin ? origin->parameters.get_head_raw() : parameters.get_head_raw();
foreach_in_list(ir_rvalue, n, actual_parameters) {
- ir_constant *constant = n->constant_expression_value(variable_context);
+ ir_constant *constant =
+ n->constant_expression_value(mem_ctx, variable_context);
if (constant == NULL) {
_mesa_hash_table_destroy(deref_hash, NULL);
return NULL;
/* Now run the builtin function until something non-constant
* happens or we get the result.
*/
- if (constant_expression_evaluate_expression_list(origin ? origin->body : body, deref_hash, &result) && result)
- result = result->clone(ralloc_parent(this), NULL);
+ if (constant_expression_evaluate_expression_list(mem_ctx, origin ? origin->body : body, deref_hash, &result) &&
+ result)
+ result = result->clone(mem_ctx, NULL);
_mesa_hash_table_destroy(deref_hash, NULL);
if (!ir->variable_referenced()->type->contains_sampler())
return visit_continue;
- if (!ir->array_index->constant_expression_value()) {
+ if (!ir->array_index->constant_expression_value(ralloc_parent(ir))) {
dynamic_sampler_array_indexing = true;
return visit_stop;
}
ir_expression *const div =
new(mem_ctx) ir_expression(ir_binop_div, sub->type, sub, increment);
- ir_constant *iter = div->constant_expression_value();
+ ir_constant *iter = div->constant_expression_value(mem_ctx);
if (iter == NULL) {
ralloc_free(mem_ctx);
return -1;
ir_rvalue *cast =
new(mem_ctx) ir_expression(op, glsl_type::int_type, iter, NULL);
- iter = cast->constant_expression_value();
+ iter = cast->constant_expression_value(mem_ctx);
}
int iter_value = iter->get_int_component(0);
ir_expression *const cmp =
new(mem_ctx) ir_expression(op, glsl_type::bool_type, add, to);
- ir_constant *const cmp_result = cmp->constant_expression_value();
+ ir_constant *const cmp_result = cmp->constant_expression_value(mem_ctx);
assert(cmp_result != NULL);
if (cmp_result->get_bool_component(0)) {
if (options->EmitNoIndirectSampler) {
if ((ir->array->type->is_array() &&
ir->array->type->contains_sampler()) &&
- !ir->array_index->constant_expression_value()) {
+ !ir->array_index->constant_expression_value(ralloc_parent(ir))) {
unsupported_variable_indexing = true;
return visit_continue;
}
array_index = i2u(array_index);
ir_constant *const_index =
- array_index->constant_expression_value(NULL);
+ array_index->constant_expression_value(mem_ctx, NULL);
if (const_index) {
*const_offset += array_stride * const_index->value.u[0];
} else {
old_index = new(ctx) ir_expression(ir_unop_u2i, old_index);
}
- ir_constant *old_index_constant = old_index->constant_expression_value();
+ ir_constant *old_index_constant =
+ old_index->constant_expression_value(ctx);
if (old_index_constant) {
/* gl_ClipDistance is being accessed via a constant index. Don't bother
* creating expressions to calculate the lowered indices. Just create
ir_dereference *const new_lhs = (ir_dereference *) expr->operands[0];
- ir_constant *old_index_constant = expr->operands[1]->constant_expression_value();
+ ir_constant *old_index_constant =
+ expr->operands[1]->constant_expression_value(mem_ctx);
if (!old_index_constant) {
ir->rhs = new(mem_ctx) ir_expression(ir_triop_vector_insert,
expr->operands[0]->type,
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:
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
ir_dereference *const new_lhs = (ir_dereference *) deref->array;
ir->set_lhs(new_lhs);
- ir_constant *old_index_constant = deref->array_index->constant_expression_value();
void *mem_ctx = ralloc_parent(ir);
+ ir_constant *old_index_constant =
+ deref->array_index->constant_expression_value(mem_ctx);
if (!old_index_constant) {
ir->rhs = new(mem_ctx) ir_expression(ir_triop_vector_insert,
new_lhs->type,
factory.mem_ctx = ralloc_parent(expr);
- ir_constant *const idx = expr->operands[2]->constant_expression_value();
+ ir_constant *const idx =
+ expr->operands[2]->constant_expression_value(factory.mem_ctx);
if (idx != NULL) {
/* Replace (vector_insert (vec) (scalar) (index)) with a dereference of
* a new temporary. The new temporary gets assigned as
ir2->operands[1]->type->is_matrix())
return false;
+ void *mem_ctx = ralloc_parent(ir2);
+
ir_constant *ir2_const[2];
- ir2_const[0] = ir2->operands[0]->constant_expression_value();
- ir2_const[1] = ir2->operands[1]->constant_expression_value();
+ ir2_const[0] = ir2->operands[0]->constant_expression_value(mem_ctx);
+ ir2_const[1] = ir2->operands[1]->constant_expression_value(mem_ctx);
if (ir2_const[0] && ir2_const[1])
return false;
if (ir->operands[i]->type->is_matrix())
return ir;
- op_const[i] = ir->operands[i]->constant_expression_value();
+ op_const[i] =
+ ir->operands[i]->constant_expression_value(ralloc_parent(ir));
op_expr[i] = ir->operands[i]->as_expression();
}
if (var_ref)
return false;
- ir_constant *constant = (*rvalue)->constant_expression_value();
+ ir_constant *constant =
+ (*rvalue)->constant_expression_value(ralloc_parent(*rvalue));
if (constant) {
*rvalue = constant;
return true;
}
/* Next, see if the call can be replaced with an assignment of a constant */
- ir_constant *const_val = ir->constant_expression_value();
+ ir_constant *const_val = ir->constant_expression_value(ralloc_parent(ir));
if (const_val != NULL) {
ir_assignment *assignment =
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;
var->data.mode == ir_var_shader_shared)
return visit_continue;
- constval = ir->rhs->constant_expression_value();
+ constval = ir->rhs->constant_expression_value(ralloc_parent(ir));
if (!constval)
return visit_continue;
* FINISHME: This can probably be done with some flags, but it would take
* FINISHME: some work to get right.
*/
- ir_constant *condition_constant = ir->condition->constant_expression_value();
+ ir_constant *condition_constant =
+ ir->condition->constant_expression_value(ralloc_parent(ir));
if (condition_constant) {
/* Move the contents of the one branch of the conditional
* that matters out.
src_reg src;
int element_size = type_size(ir->type);
- index = ir->array_index->constant_expression_value();
+ index = ir->array_index->constant_expression_value(ralloc_parent(ir));
ir->array->accept(this);
src = this->result;
switch (deref->ir_type) {
case ir_type_dereference_array: {
ir_dereference_array *deref_arr = deref->as_dereference_array();
+
+ void *mem_ctx = ralloc_parent(deref_arr);
ir_constant *array_index =
- deref_arr->array_index->constant_expression_value();
+ deref_arr->array_index->constant_expression_value(mem_ctx);
if (!array_index) {
/* GLSL 1.10 and 1.20 allowed variable sampler array indices,
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;
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;