diff options
author | marha <marha@users.sourceforge.net> | 2012-06-15 08:55:18 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-15 08:55:18 +0200 |
commit | d6f64084b9bc07d0bdd527f9354f2d1d962ed16d (patch) | |
tree | 81b2652d421992fd63143a04885e332e83e18d07 /mesalib/src/glsl/opt_algebraic.cpp | |
parent | 669b562a737c9418c53bfae69c0dbf1aabe318b4 (diff) | |
parent | 7a2af605c2c2b0d2e9bbb0b161eba8842acefbcb (diff) | |
download | vcxsrv-d6f64084b9bc07d0bdd527f9354f2d1d962ed16d.tar.gz vcxsrv-d6f64084b9bc07d0bdd527f9354f2d1d962ed16d.tar.bz2 vcxsrv-d6f64084b9bc07d0bdd527f9354f2d1d962ed16d.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
fontconfig/src/fcint.h
fontconfig/src/fcstat.c
mesalib/src/mapi/glapi/gen/GL3x.xml
xorg-server/glx/glxext.h
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])) { |