Mesa (master): glsl: Don't support integer types for operations that can' t handle them

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


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

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

glsl: Don't support integer types for operations that can't handle them

ir_unop_fract already forbade integer types in ir_validate.  ir_unop_rcp,
ir_unop_rsq, and ir_unop_sqrt should also forbid them in ir_validate.

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 | 14 --------------
 src/compiler/glsl/ir_validate.cpp            |  2 ++
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/compiler/glsl/ir_constant_expression.cpp b/src/compiler/glsl/ir_constant_expression.cpp
index 2d7895e..6f9d18d 100644
--- a/src/compiler/glsl/ir_constant_expression.cpp
+++ b/src/compiler/glsl/ir_constant_expression.cpp
@@ -729,12 +729,6 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
    case ir_unop_fract:
       for (unsigned c = 0; c < op[0]->type->components(); c++) {
          switch (this->type->base_type) {
-         case GLSL_TYPE_UINT:
-            data.u[c] = 0;
-            break;
-         case GLSL_TYPE_INT:
-            data.i[c] = 0;
-            break;
          case GLSL_TYPE_FLOAT:
             data.f[c] = op[0]->value.f[c] - floor(op[0]->value.f[c]);
             break;
@@ -823,14 +817,6 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
    case ir_unop_rcp:
       for (unsigned c = 0; c < op[0]->type->components(); c++) {
          switch (this->type->base_type) {
-         case GLSL_TYPE_UINT:
-            if (op[0]->value.u[c] != 0.0)
-               data.u[c] = 1 / op[0]->value.u[c];
-            break;
-         case GLSL_TYPE_INT:
-            if (op[0]->value.i[c] != 0.0)
-               data.i[c] = 1 / op[0]->value.i[c];
-            break;
          case GLSL_TYPE_FLOAT:
             if (op[0]->value.f[c] != 0.0)
                data.f[c] = 1.0F / op[0]->value.f[c];
diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
index 3ded202..7e294f9 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -260,6 +260,8 @@ ir_validate::visit_leave(ir_expression *ir)
    case ir_unop_rcp:
    case ir_unop_rsq:
    case ir_unop_sqrt:
+      assert(ir->type->base_type == GLSL_TYPE_FLOAT ||
+             ir->type->base_type == GLSL_TYPE_DOUBLE);
       assert(ir->type == ir->operands[0]->type);
       break;
 




More information about the mesa-commit mailing list