diff options
author | marha <marha@users.sourceforge.net> | 2012-06-15 08:28:24 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-15 08:28:24 +0200 |
commit | 7a2af605c2c2b0d2e9bbb0b161eba8842acefbcb (patch) | |
tree | 4b28c371be2077a3a6127cbc0694c80a84100699 /mesalib/src/glsl/opt_algebraic.cpp | |
parent | 925b68a7b26823fdfa1cb25d3edc3545fc2175b1 (diff) | |
download | vcxsrv-7a2af605c2c2b0d2e9bbb0b161eba8842acefbcb.tar.gz vcxsrv-7a2af605c2c2b0d2e9bbb0b161eba8842acefbcb.tar.bz2 vcxsrv-7a2af605c2c2b0d2e9bbb0b161eba8842acefbcb.zip |
fontconfig mesa pixman xserver git update 15 juni 2012
Diffstat (limited to 'mesalib/src/glsl/opt_algebraic.cpp')
-rw-r--r-- | mesalib/src/glsl/opt_algebraic.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp index d39761260..75948db16 100644 --- a/mesalib/src/glsl/opt_algebraic.cpp +++ b/mesalib/src/glsl/opt_algebraic.cpp @@ -84,6 +84,12 @@ is_vec_one(ir_constant *ir) return (ir == NULL) ? false : ir->is_one(); } +static inline bool +is_vec_basis(ir_constant *ir) +{ + return (ir == NULL) ? false : ir->is_basis(); +} + static void update_type(ir_expression *ir) { @@ -309,6 +315,31 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) } break; + case ir_binop_dot: + if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) { + this->progress = true; + return ir_constant::zero(mem_ctx, ir->type); + } + if (is_vec_basis(op_const[0])) { + this->progress = true; + unsigned component = 0; + for (unsigned c = 0; c < op_const[0]->type->vector_elements; c++) { + if (op_const[0]->value.f[c] == 1.0) + component = c; + } + return new(mem_ctx) ir_swizzle(ir->operands[1], component, 0, 0, 0, 1); + } + if (is_vec_basis(op_const[1])) { + this->progress = true; + unsigned component = 0; + for (unsigned c = 0; c < op_const[1]->type->vector_elements; c++) { + if (op_const[1]->value.f[c] == 1.0) + component = c; + } + return new(mem_ctx) ir_swizzle(ir->operands[0], component, 0, 0, 0, 1); + } + break; + case ir_binop_logic_and: /* FINISHME: Also simplify (a && a) to (a). */ if (is_vec_one(op_const[0])) { |