Skip to content
Snippets Groups Projects
Commit ef78df8d authored by Kenneth Graunke's avatar Kenneth Graunke
Browse files

glsl: Make lower_const_arrays_to_uniforms work directly on constants.


There's really no point in looking at ir_dereference_array of a
constant.  It also misses cases like:

  (assign () (var_ref tmp) (constant (array ...) ...))

No changes in shader-db, but keeps it working after the next commit.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
Reviewed-by: default avatarTimothy Arceri <timothy.arceri@collabora.com>
parent f7741c52
No related branches found
No related tags found
No related merge requests found
...@@ -70,17 +70,13 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue) ...@@ -70,17 +70,13 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
if (!*rvalue) if (!*rvalue)
return; return;
ir_dereference_array *dra = (*rvalue)->as_dereference_array(); ir_constant *con = (*rvalue)->as_constant();
if (!dra)
return;
ir_constant *con = dra->array->as_constant();
if (!con || !con->type->is_array()) if (!con || !con->type->is_array())
return; return;
void *mem_ctx = ralloc_parent(con); void *mem_ctx = ralloc_parent(con);
char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", dra); char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%p", con);
ir_variable *uni = ir_variable *uni =
new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform); new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
...@@ -93,8 +89,7 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue) ...@@ -93,8 +89,7 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
uni->data.max_array_access = uni->type->length - 1; uni->data.max_array_access = uni->type->length - 1;
instructions->push_head(uni); instructions->push_head(uni);
ir_dereference_variable *varref = new(mem_ctx) ir_dereference_variable(uni); *rvalue = new(mem_ctx) ir_dereference_variable(uni);
*rvalue = new(mem_ctx) ir_dereference_array(varref, dra->array_index);
progress = true; progress = true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment