ir_constant_expression: Add support for the "transpose" builtin.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 22 Jul 2010 22:34:49 +0000 (15:34 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 28 Jul 2010 22:46:29 +0000 (15:46 -0700)
src/glsl/ir_constant_expression.cpp

index b6cb2d86726474da2de5c65cb5d3981030783b52..c4e6d837b02e37d145d64eb1fb3590ee6efebe2f 100644 (file)
@@ -1096,7 +1096,14 @@ ir_call::constant_expression_value()
       for (unsigned c = 0; c < op[0]->type->components(); c++)
         data.f[c] = tanhf(op[0]->value.f[c]);
    } else if (strcmp(callee, "transpose") == 0) {
-      return NULL; /* FINISHME: implement this */
+      assert(op[0]->type->is_matrix());
+      const unsigned n = op[0]->type->vector_elements;
+      const unsigned m = op[0]->type->matrix_columns;
+      for (unsigned j = 0; j < m; j++) {
+        for (unsigned i = 0; i < n; i++) {
+           data.f[m*i+j] += op[0]->value.f[i+n*j];
+        }
+      }
    } else {
       /* Unsupported builtin - some are not allowed in constant expressions. */
       return NULL;