Mesa (master): glsl: Check for zero vectors in ir_binop_dot

Matt Turner mattst88 at kemper.freedesktop.org
Tue Jun 12 22:51:45 UTC 2012


Module: Mesa
Branch: master
Commit: d7bef19c7ff40f0b83a42fdb8509eed3ad1e40a3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d7bef19c7ff40f0b83a42fdb8509eed3ad1e40a3

Author: Matt Turner <mattst88 at gmail.com>
Date:   Mon Jun  4 16:17:12 2012 -0400

glsl: Check for zero vectors in ir_binop_dot

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/opt_algebraic.cpp |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index d397612..5a9881d 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -309,6 +309,13 @@ 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);
+      }
+      break;
+
    case ir_binop_logic_and:
       /* FINISHME: Also simplify (a && a) to (a). */
       if (is_vec_one(op_const[0])) {




More information about the mesa-commit mailing list