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

index c4a416aa355bd8aca03c499a916b83e588a32f71..83d1b34bed6712fe273e1ce670e05d0d5f31af9c 100644 (file)
@@ -925,7 +925,7 @@ ir_call::constant_expression_value()
    } else if (strcmp(callee, "inversesqrt") == 0) {
       expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL);
    } else if (strcmp(callee, "length") == 0) {
-      return NULL; /* FINISHME: implement this */
+      return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0])));
    } else if (strcmp(callee, "lessThan") == 0) {
       assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
       for (unsigned c = 0; c < op[0]->type->components(); c++) {