From 9be7f638130f46a9df2bfbcd4a03b36de9e4f3aa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 13 Jul 2010 15:37:57 -0700 Subject: 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. --- src/glsl/ir_constant_expression.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/glsl/ir_constant_expression.cpp') diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index c0fe47067bd..ca834978f47 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -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; -- cgit v1.2.3