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

index 809ea60..c832081 100644 (file)
@@ -1013,7 +1013,10 @@ ir_call::constant_expression_value()
       for (unsigned c = 0; c < op[0]->type->components(); c++)
         data.f[c] = M_PI/180.0 * op[0]->value.f[c];
    } else if (strcmp(callee, "reflect") == 0) {
-      return NULL; /* FINISHME: implement this */
+      assert(op[0]->type->is_float());
+      float dot_NI = dot(op[1], op[0]);
+      for (unsigned c = 0; c < op[0]->type->components(); c++)
+        data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c];
    } else if (strcmp(callee, "refract") == 0) {
       return NULL; /* FINISHME: implement this */
    } else if (strcmp(callee, "sign") == 0) {