summaryrefslogtreecommitdiffstats
path: root/src/glsl/lower_mat_op_to_vec.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2011-06-24 14:19:57 -0700
committerEric Anholt <[email protected]>2011-06-29 15:09:32 -0700
commit408377aed1dfae30605709fe1a134880a0386aa8 (patch)
tree223176c4a214beb9b266a6faaca83bb4522dfd25 /src/glsl/lower_mat_op_to_vec.cpp
parenta47fd5c27de2b2d61776faa524f9b7ab1c915cde (diff)
glsl: Rename lower_mat_op_to_vec operands/results to be less hungarian.
This awkward typing was to avoid shadowing the function argument (the matrix) with the temporary deref (the column) before the get_column()/get_element()s were moved into the expression/assignment constructors. They're about to become not-variables, so the current names had to go. This change is almost mechanical (other than column_expr), so it should make the next diff clearer. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/lower_mat_op_to_vec.cpp')
-rw-r--r--src/glsl/lower_mat_op_to_vec.cpp148
1 files changed, 74 insertions, 74 deletions
diff --git a/src/glsl/lower_mat_op_to_vec.cpp b/src/glsl/lower_mat_op_to_vec.cpp
index cda72ae91c3..6d2bc0100f8 100644
--- a/src/glsl/lower_mat_op_to_vec.cpp
+++ b/src/glsl/lower_mat_op_to_vec.cpp
@@ -48,16 +48,16 @@ public:
ir_dereference *get_column(ir_variable *var, int col);
ir_rvalue *get_element(ir_variable *var, int col, int row);
- void do_mul_mat_mat(ir_variable *result_var,
- ir_variable *a_var, ir_variable *b_var);
- void do_mul_mat_vec(ir_variable *result_var,
- ir_variable *a_var, ir_variable *b_var);
- void do_mul_vec_mat(ir_variable *result_var,
- ir_variable *a_var, ir_variable *b_var);
- void do_mul_mat_scalar(ir_variable *result_var,
- ir_variable *a_var, ir_variable *b_var);
- void do_equal_mat_mat(ir_variable *result_var, ir_variable *a_var,
- ir_variable *b_var, bool test_equal);
+ void do_mul_mat_mat(ir_variable *result,
+ ir_variable *a, ir_variable *b);
+ void do_mul_mat_vec(ir_variable *result,
+ ir_variable *a, ir_variable *b);
+ void do_mul_vec_mat(ir_variable *result,
+ ir_variable *a, ir_variable *b);
+ void do_mul_mat_scalar(ir_variable *result,
+ ir_variable *a, ir_variable *b);
+ void do_equal_mat_mat(ir_variable *result, ir_variable *a,
+ ir_variable *b, bool test_equal);
void *mem_ctx;
bool made_progress;
@@ -131,26 +131,26 @@ ir_mat_op_to_vec_visitor::get_column(ir_variable *var, int row)
void
ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_variable *result_var,
- ir_variable *a_var,
- ir_variable *b_var)
+ ir_variable *a,
+ ir_variable *b)
{
int b_col, i;
ir_assignment *assign;
ir_expression *expr;
- for (b_col = 0; b_col < b_var->type->matrix_columns; b_col++) {
+ for (b_col = 0; b_col < b->type->matrix_columns; b_col++) {
/* first column */
expr = new(mem_ctx) ir_expression(ir_binop_mul,
- get_column(a_var, 0),
- get_element(b_var, b_col, 0));
+ get_column(a, 0),
+ get_element(b, b_col, 0));
/* following columns */
- for (i = 1; i < a_var->type->matrix_columns; i++) {
+ for (i = 1; i < a->type->matrix_columns; i++) {
ir_expression *mul_expr;
mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
- get_column(a_var, i),
- get_element(b_var, b_col, i));
+ get_column(a, i),
+ get_element(b, b_col, i));
expr = new(mem_ctx) ir_expression(ir_binop_add,
expr,
mul_expr);
@@ -166,8 +166,8 @@ ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_variable *result_var,
void
ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var,
- ir_variable *a_var,
- ir_variable *b_var)
+ ir_variable *a,
+ ir_variable *b)
{
int i;
ir_assignment *assign;
@@ -175,16 +175,16 @@ ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var,
/* first column */
expr = new(mem_ctx) ir_expression(ir_binop_mul,
- get_column(a_var, 0),
- get_element(b_var, 0, 0));
+ get_column(a, 0),
+ get_element(b, 0, 0));
/* following columns */
- for (i = 1; i < a_var->type->matrix_columns; i++) {
+ for (i = 1; i < a->type->matrix_columns; i++) {
ir_expression *mul_expr;
mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
- get_column(a_var, i),
- get_element(b_var, 0, i));
+ get_column(a, i),
+ get_element(b, 0, i));
expr = new(mem_ctx) ir_expression(ir_binop_add, expr, mul_expr);
}
@@ -196,25 +196,25 @@ ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_variable *result_var,
}
void
-ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var,
- ir_variable *a_var,
- ir_variable *b_var)
+ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result,
+ ir_variable *a,
+ ir_variable *b)
{
int i;
- for (i = 0; i < b_var->type->matrix_columns; i++) {
- ir_rvalue *result;
+ for (i = 0; i < b->type->matrix_columns; i++) {
+ ir_rvalue *column_result;
ir_expression *column_expr;
ir_assignment *column_assign;
- result = new(mem_ctx) ir_dereference_variable(result_var);
- result = new(mem_ctx) ir_swizzle(result, i, 0, 0, 0, 1);
+ column_result = new(mem_ctx) ir_dereference_variable(result);
+ column_result = new(mem_ctx) ir_swizzle(column_result, i, 0, 0, 0, 1);
column_expr = new(mem_ctx) ir_expression(ir_binop_dot,
- new(mem_ctx) ir_dereference_variable(a_var),
- get_column(b_var, i));
+ new(mem_ctx) ir_dereference_variable(a),
+ get_column(b, i));
- column_assign = new(mem_ctx) ir_assignment(result,
+ column_assign = new(mem_ctx) ir_assignment(column_result,
column_expr,
NULL);
base_ir->insert_before(column_assign);
@@ -222,21 +222,21 @@ ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_variable *result_var,
}
void
-ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var,
- ir_variable *a_var,
- ir_variable *b_var)
+ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result,
+ ir_variable *a,
+ ir_variable *b)
{
int i;
- for (i = 0; i < a_var->type->matrix_columns; i++) {
+ for (i = 0; i < a->type->matrix_columns; i++) {
ir_expression *column_expr;
ir_assignment *column_assign;
column_expr = new(mem_ctx) ir_expression(ir_binop_mul,
- get_column(a_var, i),
- new(mem_ctx) ir_dereference_variable(b_var));
+ get_column(a, i),
+ new(mem_ctx) ir_dereference_variable(b));
- column_assign = new(mem_ctx) ir_assignment(get_column(result_var, i),
+ column_assign = new(mem_ctx) ir_assignment(get_column(result, i),
column_expr,
NULL);
base_ir->insert_before(column_assign);
@@ -245,8 +245,8 @@ ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_variable *result_var,
void
ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
- ir_variable *a_var,
- ir_variable *b_var,
+ ir_variable *a,
+ ir_variable *b,
bool test_equal)
{
/* This essentially implements the following GLSL:
@@ -267,7 +267,7 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
* a[3] != b[3]);
* }
*/
- const unsigned columns = a_var->type->matrix_columns;
+ const unsigned columns = a->type->matrix_columns;
const glsl_type *const bvec_type =
glsl_type::get_instance(GLSL_TYPE_BOOL, columns, 1);
@@ -279,8 +279,8 @@ ir_mat_op_to_vec_visitor::do_equal_mat_mat(ir_variable *result_var,
for (unsigned i = 0; i < columns; i++) {
ir_expression *const cmp =
new(this->mem_ctx) ir_expression(ir_binop_any_nequal,
- get_column(a_var, i),
- get_column(b_var, i));
+ get_column(a, i),
+ get_column(b, i));
ir_dereference *const lhs =
new(this->mem_ctx) ir_dereference_variable(tmp_bvec);
@@ -324,7 +324,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
{
ir_expression *orig_expr = orig_assign->rhs->as_expression();
unsigned int i, matrix_columns = 1;
- ir_variable *op_var[2];
+ ir_variable *op[2];
if (!orig_expr)
return visit_continue;
@@ -340,7 +340,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
orig_assign->lhs->as_dereference_variable();
assert(lhs_deref);
- ir_variable *result_var = lhs_deref->var;
+ ir_variable *result = lhs_deref->var;
/* Store the expression operands in temps so we can use them
* multiple times.
@@ -348,12 +348,12 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
for (i = 0; i < orig_expr->get_num_operands(); i++) {
ir_assignment *assign;
- op_var[i] = new(mem_ctx) ir_variable(orig_expr->operands[i]->type,
- "mat_op_to_vec",
- ir_var_temporary);
- base_ir->insert_before(op_var[i]);
+ op[i] = new(mem_ctx) ir_variable(orig_expr->operands[i]->type,
+ "mat_op_to_vec",
+ ir_var_temporary);
+ base_ir->insert_before(op[i]);
- lhs_deref = new(mem_ctx) ir_dereference_variable(op_var[i]);
+ lhs_deref = new(mem_ctx) ir_dereference_variable(op[i]);
assign = new(mem_ctx) ir_assignment(lhs_deref,
orig_expr->operands[i],
NULL);
@@ -363,7 +363,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
/* OK, time to break down this matrix operation. */
switch (orig_expr->operation) {
case ir_unop_neg: {
- const unsigned mask = (1U << result_var->type->vector_elements) - 1;
+ const unsigned mask = (1U << result->type->vector_elements) - 1;
/* Apply the operation to each column.*/
for (i = 0; i < matrix_columns; i++) {
@@ -371,9 +371,9 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
ir_assignment *column_assign;
column_expr = new(mem_ctx) ir_expression(orig_expr->operation,
- get_column(op_var[0], i));
+ get_column(op[0], i));
- column_assign = new(mem_ctx) ir_assignment(get_column(result_var, i),
+ column_assign = new(mem_ctx) ir_assignment(get_column(result, i),
column_expr,
NULL,
mask);
@@ -386,7 +386,7 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
case ir_binop_sub:
case ir_binop_div:
case ir_binop_mod: {
- const unsigned mask = (1U << result_var->type->vector_elements) - 1;
+ const unsigned mask = (1U << result->type->vector_elements) - 1;
/* For most operations, the matrix version is just going
* column-wise through and applying the operation to each column
@@ -397,10 +397,10 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
ir_assignment *column_assign;
column_expr = new(mem_ctx) ir_expression(orig_expr->operation,
- get_column(op_var[0], i),
- get_column(op_var[1], i));
+ get_column(op[0], i),
+ get_column(op[1], i));
- column_assign = new(mem_ctx) ir_assignment(get_column(result_var, i),
+ column_assign = new(mem_ctx) ir_assignment(get_column(result, i),
column_expr,
NULL,
mask);
@@ -410,29 +410,29 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *orig_assign)
break;
}
case ir_binop_mul:
- if (op_var[0]->type->is_matrix()) {
- if (op_var[1]->type->is_matrix()) {
- do_mul_mat_mat(result_var, op_var[0], op_var[1]);
- } else if (op_var[1]->type->is_vector()) {
- do_mul_mat_vec(result_var, op_var[0], op_var[1]);
+ if (op[0]->type->is_matrix()) {
+ if (op[1]->type->is_matrix()) {
+ do_mul_mat_mat(result, op[0], op[1]);
+ } else if (op[1]->type->is_vector()) {
+ do_mul_mat_vec(result, op[0], op[1]);
} else {
- assert(op_var[1]->type->is_scalar());
- do_mul_mat_scalar(result_var, op_var[0], op_var[1]);
+ assert(op[1]->type->is_scalar());
+ do_mul_mat_scalar(result, op[0], op[1]);
}
} else {
- assert(op_var[1]->type->is_matrix());
- if (op_var[0]->type->is_vector()) {
- do_mul_vec_mat(result_var, op_var[0], op_var[1]);
+ assert(op[1]->type->is_matrix());
+ if (op[0]->type->is_vector()) {
+ do_mul_vec_mat(result, op[0], op[1]);
} else {
- assert(op_var[0]->type->is_scalar());
- do_mul_mat_scalar(result_var, op_var[1], op_var[0]);
+ assert(op[0]->type->is_scalar());
+ do_mul_mat_scalar(result, op[1], op[0]);
}
}
break;
case ir_binop_all_equal:
case ir_binop_any_nequal:
- do_equal_mat_mat(result_var, op_var[1], op_var[0],
+ do_equal_mat_mat(result, op[1], op[0],
(orig_expr->operation == ir_binop_all_equal));
break;