[Mesa-dev] [PATCH 03/12] glsl: Refactor part of convert_vec_index_to_cond_assign
Kenneth Graunke
kenneth at whitecape.org
Sat Apr 27 23:57:10 PDT 2013
On 04/08/2013 03:24 PM, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Use a first function that extract the vector being indexed and the index
> from the deref. Call the second function that does the real work.
>
> Coming patches will add a new ir_expression for variable indexing into a
> vector. Having the lowering pass split into two functions will make it
> much easier to lower the new ir_expression.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/glsl/lower_vec_index_to_cond_assign.cpp | 47 ++++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 17 deletions(-)
>
> diff --git a/src/glsl/lower_vec_index_to_cond_assign.cpp b/src/glsl/lower_vec_index_to_cond_assign.cpp
> index f85875f..6572cc4 100644
> --- a/src/glsl/lower_vec_index_to_cond_assign.cpp
> +++ b/src/glsl/lower_vec_index_to_cond_assign.cpp
> @@ -53,6 +53,9 @@ public:
> }
>
> ir_rvalue *convert_vec_index_to_cond_assign(ir_rvalue *val);
> + ir_rvalue *convert_vec_index_to_cond_assign(void *mem_ctx,
> + ir_rvalue *orig_vector,
> + ir_rvalue *orig_index);
>
> virtual ir_visitor_status visit_enter(ir_expression *);
> virtual ir_visitor_status visit_enter(ir_swizzle *);
> @@ -65,24 +68,15 @@ public:
> };
>
> ir_rvalue *
> -ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir)
> +ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(void *mem_ctx,
> + ir_rvalue *orig_vector,
> + ir_rvalue *orig_index)
> {
> - ir_dereference_array *orig_deref = ir->as_dereference_array();
> ir_assignment *assign, *value_assign;
> ir_variable *index, *var, *value;
> ir_dereference *deref, *deref_value;
> unsigned i;
>
> - if (!orig_deref)
> - return ir;
> -
> - if (orig_deref->array->type->is_matrix() ||
> - orig_deref->array->type->is_array())
> - return ir;
> -
> - void *mem_ctx = ralloc_parent(ir);
> -
> - assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT);
>
> exec_list list;
>
> @@ -92,15 +86,15 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue
> ir_var_temporary);
> list.push_tail(index);
> deref = new(base_ir) ir_dereference_variable(index);
> - assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL);
> + assign = new(base_ir) ir_assignment(deref, orig_index, NULL);
> list.push_tail(assign);
>
> /* Store the value inside a temp, thus avoiding matrixes duplication */
> - value = new(base_ir) ir_variable(orig_deref->array->type, "vec_value_tmp",
> + value = new(base_ir) ir_variable(orig_vector->type, "vec_value_tmp",
> ir_var_temporary);
> list.push_tail(value);
> deref_value = new(base_ir) ir_dereference_variable(value);
> - value_assign = new(base_ir) ir_assignment(deref_value, orig_deref->array);
> + value_assign = new(base_ir) ir_assignment(deref_value, orig_vector);
> list.push_tail(value_assign);
>
> /* Temporary where we store whichever value we swizzle out. */
Right below this line, the code reads:
var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v",
ir_var_temporary);
which fails to compile because you removed the variable called "ir".
Please make this compile. Perhaps you want to introduce your extra
glsl_type parameter in this patch rather than patch 5?
--Ken
More information about the mesa-dev
mailing list