summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-06-24 12:16:03 -0700
committerEric Anholt <[email protected]>2011-06-29 15:09:27 -0700
commita47fd5c27de2b2d61776faa524f9b7ab1c915cde (patch)
treefce0b62872cfdc6dea9712268f8b11b07b5a97a9 /src
parente75b5954db52723a8590cd321b1998a079e9c1d4 (diff)
glsl: Move get_{column,element} to expression args.
I think this makes the code more obvious by moving the declarations to their single usage (now that we aren't using them to get at the ->type field for expression constructors). Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/lower_mat_op_to_vec.cpp65
1 files changed, 22 insertions, 43 deletions
diff --git a/src/glsl/lower_mat_op_to_vec.cpp b/src/glsl/lower_mat_op_to_vec.cpp
index bf3915ef95f..cda72ae91c3 100644
--- a/src/glsl/lower_mat_op_to_vec.cpp
+++ b/src/glsl/lower_mat_op_to_vec.cpp
@@ -139,24 +139,18 @@ ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_variable *result_var,
ir_expression *expr;
for (b_col = 0; b_col < b_var->type->matrix_columns; b_col++) {
- ir_rvalue *a = get_column(a_var, 0);
- ir_rvalue *b = get_element(b_var, b_col, 0);
-
/* first column */
expr = new(mem_ctx) ir_expression(ir_binop_mul,
- a,
- b);
+ get_column(a_var, 0),
+ get_element(b_var, b_col, 0));
/* following columns */
for (i = 1; i < a_var->type->matrix_columns; i++) {
ir_expression *mul_expr;
- a = get_column(a_var, i);
- b = get_element(b_var, b_col, i);
-
mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
- a,
- b);
+ get_column(a_var, i),
+ get_element(b_var, b_col, i));
expr = new(mem_ctx) ir_expression(ir_binop_add,
expr,
mul_expr);
@@ -176,26 +170,21 @@ ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var,
ir_variable *b_var)
{
int i;
- ir_rvalue *a = get_column(a_var, 0);
- ir_rvalue *b = get_element(b_var, 0, 0);
ir_assignment *assign;
ir_expression *expr;
/* first column */
expr = new(mem_ctx) ir_expression(ir_binop_mul,
- a,
- b);
+ get_column(a_var, 0),
+ get_element(b_var, 0, 0));
/* following columns */
for (i = 1; i < a_var->type->matrix_columns; i++) {
ir_expression *mul_expr;
- a = get_column(a_var, i);
- b = get_element(b_var, 0, i);
-
mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
- a,
- b);
+ get_column(a_var, i),
+ get_element(b_var, 0, i));
expr = new(mem_ctx) ir_expression(ir_binop_add, expr, mul_expr);
}
@@ -214,8 +203,6 @@ ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var,
int i;
for (i = 0; i < b_var->type->matrix_columns; i++) {
- ir_rvalue *a = new(mem_ctx) ir_dereference_variable(a_var);
- ir_rvalue *b = get_column(b_var, i);
ir_rvalue *result;
ir_expression *column_expr;
ir_assignment *column_assign;
@@ -224,8 +211,8 @@ ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var,
result = new(mem_ctx) ir_swizzle(result, i, 0, 0, 0, 1);
column_expr = new(mem_ctx) ir_expression(ir_binop_dot,
- a,
- b);
+ new(mem_ctx) ir_dereference_variable(a_var),
+ get_column(b_var, i));
column_assign = new(mem_ctx) ir_assignment(result,
column_expr,
@@ -242,17 +229,14 @@ ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var,
int i;
for (i = 0; i < a_var->type->matrix_columns; i++) {
- ir_rvalue *a = get_column(a_var, i);
- ir_rvalue *b = new(mem_ctx) ir_dereference_variable(b_var);
- ir_rvalue *result = get_column(result_var, i);
ir_expression *column_expr;
ir_assignment *column_assign;
column_expr = new(mem_ctx) ir_expression(ir_binop_mul,
- a,
- b);
+ get_column(a_var, i),
+ new(mem_ctx) ir_dereference_variable(b_var));
- column_assign = new(mem_ctx) ir_assignment(result,
+ column_assign = new(mem_ctx) ir_assignment(get_column(result_var, i),
column_expr,
NULL);
base_ir->insert_before(column_assign);
@@ -293,11 +277,10 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
this->base_ir->insert_before(tmp_bvec);
for (unsigned i = 0; i < columns; i++) {
- ir_dereference *const op0 = get_column(a_var, i);
- ir_dereference *const op1 = get_column(b_var, i);
-
ir_expression *const cmp =
- new(this->mem_ctx) ir_expression(ir_binop_any_nequal, op0, op1);
+ new(this->mem_ctx) ir_expression(ir_binop_any_nequal,
+ get_column(a_var, i),
+ get_column(b_var, i));
ir_dereference *const lhs =
new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
@@ -384,14 +367,13 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
/* Apply the operation to each column.*/
for (i = 0; i < matrix_columns; i++) {
- ir_rvalue *op0 = get_column(op_var[0], i);
- ir_dereference *result = get_column(result_var, i);
ir_expression *column_expr;
ir_assignment *column_assign;
- column_expr = new(mem_ctx) ir_expression(orig_expr->operation, op0);
+ column_expr = new(mem_ctx) ir_expression(orig_expr->operation,
+ get_column(op_var[0], i));
- column_assign = new(mem_ctx) ir_assignment(result,
+ column_assign = new(mem_ctx) ir_assignment(get_column(result_var, i),
column_expr,
NULL,
mask);
@@ -411,17 +393,14 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
* if available.
*/
for (i = 0; i < matrix_columns; i++) {
- ir_rvalue *op0 = get_column(op_var[0], i);
- ir_rvalue *op1 = get_column(op_var[1], i);
- ir_dereference *result = get_column(result_var, i);
ir_expression *column_expr;
ir_assignment *column_assign;
column_expr = new(mem_ctx) ir_expression(orig_expr->operation,
- op0,
- op1);
+ get_column(op_var[0], i),
+ get_column(op_var[1], i));
- column_assign = new(mem_ctx) ir_assignment(result,
+ column_assign = new(mem_ctx) ir_assignment(get_column(result_var, i),
column_expr,
NULL,
mask);