ir_constant_expression: Add support for the "outerProduct" builtin.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 23 Jul 2010 20:24:09 +0000 (13:24 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 28 Jul 2010 22:46:29 +0000 (15:46 -0700)
src/glsl/ir_constant_expression.cpp

index 9fc37b37779c5bdeb589ce03325977eb1930254a..f02cd3127eeeb4baf39c63600d45167117e09147 100644 (file)
@@ -1043,7 +1043,14 @@ ir_call::constant_expression_value()
         }
       }
    } else if (strcmp(callee, "outerProduct") == 0) {
-      return NULL; /* FINISHME: implement this */
+      assert(op[0]->type->is_vector() && op[1]->type->is_vector());
+      const unsigned m = op[0]->type->vector_elements;
+      const unsigned n = op[1]->type->vector_elements;
+      for (unsigned j = 0; j < n; j++) {
+        for (unsigned i = 0; i < m; i++) {
+           data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j];
+        }
+      }
    } else if (strcmp(callee, "pow") == 0) {
       expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]);
    } else if (strcmp(callee, "radians") == 0) {