diff options
| author | Ian Romanick <ian.d.romanick@intel.com> | 2010-06-11 13:46:30 -0700 | 
|---|---|---|
| committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-06-11 15:43:59 -0700 | 
| commit | 39d6dd3537ce436806dbb5e7f6fa7c5477babb8e (patch) | |
| tree | 013bf2319146ac2027429b17bbcb24c9977280f4 | |
| parent | 7825d3d15710fdfcfc503754862963aac8065480 (diff) | |
ir_constant_visitor: Handle bool-to-int and int-to-bool
| -rw-r--r-- | ir_constant_expression.cpp | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index 781166a8a2..a3ce6e7e59 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -183,6 +183,21 @@ ir_constant_visitor::visit(ir_expression *ir)  	 b[c] = bool(op[0]->value.f[c]);        }        break; +   case ir_unop_b2i: +      assert(op[0]->type->base_type == GLSL_TYPE_BOOL); +      type = ir->type; +      for (c = 0; c < ir->operands[0]->type->components(); c++) { +	 u[c] = op[0]->value.b[c] ? 1 : 0; +	 i[c] = u[c]; +      } +      break; +   case ir_unop_i2b: +      assert(op[0]->type->is_integer()); +      type = ir->type; +      for (c = 0; c < ir->operands[0]->type->components(); c++) { +	 b[c] = bool(op[0]->value.u[c]); +      } +      break;     case ir_unop_neg:        type = ir->type; | 
