if (!*rvalue)
return;
- ir_constant *con = (*rvalue)->as_constant();
+ ir_dereference_array *dra = (*rvalue)->as_dereference_array();
+ if (!dra)
+ return;
+
+ ir_constant *con = dra->array->as_constant();
if (!con || !con->type->is_array())
return;
void *mem_ctx = ralloc_parent(con);
+ char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", dra);
+
ir_variable *uni =
- new(mem_ctx) ir_variable(con->type, "constarray", ir_var_uniform);
+ new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
uni->constant_initializer = con;
uni->constant_value = con;
uni->data.has_initializer = true;
uni->data.max_array_access = uni->type->length - 1;
instructions->push_head(uni);
- *rvalue = new(mem_ctx) ir_dereference_variable(uni);
+ ir_dereference_variable *varref = new(mem_ctx) ir_dereference_variable(uni);
+ *rvalue = new(mem_ctx) ir_dereference_array(varref, dra->array_index);
progress = true;
}