Mesa (master): glsl: Don' t support ir_unop_abs or ir_unop_sign for unsigned integers

Ian Romanick idr at kemper.freedesktop.org
Wed Aug 17 10:01:29 UTC 2016


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jul  8 17:34:53 2016 -0700

glsl: Don't support ir_unop_abs or ir_unop_sign for unsigned integers

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/compiler/glsl/ir_constant_expression.cpp | 6 ------
 src/compiler/glsl/ir_validate.cpp            | 9 +++++++++
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp
index 6329acd..2d7895e 100644
--- a/src/compiler/glsl/ir_constant_expression.cpp
+++ b/src/compiler/glsl/ir_constant_expression.cpp
@@ -785,9 +785,6 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
    case ir_unop_abs:
       for (unsigned c = 0; c < op[0]->type->components(); c++) {
          switch (this->type->base_type) {
-         case GLSL_TYPE_UINT:
-            data.u[c] = op[0]->value.u[c];
-            break;
          case GLSL_TYPE_INT:
             data.i[c] = op[0]->value.i[c];
             if (data.i[c] < 0)
@@ -808,9 +805,6 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
    case ir_unop_sign:
       for (unsigned c = 0; c < op[0]->type->components(); c++) {
          switch (this->type->base_type) {
-         case GLSL_TYPE_UINT:
-            data.u[c] = op[0]->value.i[c] > 0;
-            break;
          case GLSL_TYPE_INT:
             data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
             break;
diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
index bade45a..3ded202 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -246,8 +246,17 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
 
    case ir_unop_neg:
+      assert(ir->type == ir->operands[0]->type);
+      break;
+
    case ir_unop_abs:
    case ir_unop_sign:
+      assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT ||
+             ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
+      assert(ir->type == ir->operands[0]->type);
+      break;
+
    case ir_unop_rcp:
    case ir_unop_rsq:
    case ir_unop_sqrt:




More information about the mesa-commit mailing list