glsl2: Make cross() be an expression operation.

ARB_fp, ARB_vp, Mesa IR, and the 965 vertex shader all have
instructions for cross.  Shaves 12 Mesa instructions off of a
66-instruction shader I have.
This commit is contained in:
Eric Anholt
2010-07-13 15:37:57 -07:00
parent 87a2ee8db6
commit 9be7f63813
6 changed files with 22 additions and 23 deletions

View File

@@ -459,8 +459,19 @@ ir_constant_visitor::visit(ir_expression *ir)
assert(0);
}
}
break;
case ir_binop_cross:
assert(op[0]->type == glsl_type::vec3_type);
assert(op[1]->type == glsl_type::vec3_type);
data.f[0] = (op[0]->value.f[1] * op[1]->value.f[2] -
op[1]->value.f[1] * op[0]->value.f[2]);
data.f[1] = (op[0]->value.f[2] * op[1]->value.f[0] -
op[1]->value.f[2] * op[0]->value.f[0]);
data.f[2] = (op[0]->value.f[0] * op[1]->value.f[1] -
op[1]->value.f[0] * op[0]->value.f[1]);
break;
case ir_binop_add:
assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
for (unsigned c = 0, c0 = 0, c1 = 0;