Mesa (glsl2): glsl2: Add support for ir_unop_neg to ir_mat_op_to_vec

Eric Anholt anholt at kemper.freedesktop.org
Sat Aug 14 00:55:43 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 013bbbbb0ac52a12d1e4413700dc40dee70186f8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=013bbbbb0ac52a12d1e4413700dc40dee70186f8

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 10 19:52:02 2010 -0700

glsl2: Add support for ir_unop_neg to ir_mat_op_to_vec

---

 src/glsl/ir_mat_op_to_vec.cpp |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir_mat_op_to_vec.cpp b/src/glsl/ir_mat_op_to_vec.cpp
index 880454c..80e0579 100644
--- a/src/glsl/ir_mat_op_to_vec.cpp
+++ b/src/glsl/ir_mat_op_to_vec.cpp
@@ -311,6 +311,30 @@ ir_mat_op_to_vec_visitor::visit_leave(ir_assignment *assign)
 
    /* OK, time to break down this matrix operation. */
    switch (expr->operation) {
+   case ir_unop_neg: {
+      const unsigned mask = (1U << result_var->type->vector_elements) - 1;
+
+      /* 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(base_ir) ir_expression(expr->operation,
+						  result->type,
+						  op0,
+						  NULL);
+
+	 column_assign = new(base_ir) ir_assignment(result,
+						    column_expr,
+						    NULL,
+						    mask);
+	 assert(column_assign->write_mask != 0);
+	 base_ir->insert_before(column_assign);
+      }
+      break;
+   }
    case ir_binop_add:
    case ir_binop_sub:
    case ir_binop_div:




More information about the mesa-commit mailing list