Add conversion of bool to float as an IR operation to match int to float.
authorEric Anholt <eric@anholt.net>
Fri, 2 Apr 2010 12:13:43 +0000 (02:13 -1000)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 2 Apr 2010 18:22:41 +0000 (11:22 -0700)
ast_function.cpp
ast_to_hir.cpp
ir.cpp
ir.h
ir_print_visitor.cpp

index 91d4f15a3b7b932839bd63c91b2aeeff80b33365..2ca8976d50828f108e024d56f5bcfb1c5d2c7eb9 100644 (file)
@@ -139,7 +139,7 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type)
       case GLSL_TYPE_INT:
         return new ir_expression(ir_unop_i2f, desired_type, src, NULL);
       case GLSL_TYPE_BOOL:
-        assert(!"FINISHME: Convert bool to float.");
+        return new ir_expression(ir_unop_b2f, desired_type, src, NULL);
       }
       break;
    case GLSL_TYPE_BOOL: {
index 5e0dcaae22739bffe6efa1649adc4e4df3acca2f..dd846740042c6660f406ef9fafe804ef8cddb3d1 100644 (file)
@@ -120,7 +120,8 @@ apply_implicit_conversion(const glsl_type *to, ir_rvalue * &from,
       from = new ir_expression(ir_unop_u2f, to, from, NULL);
       break;
    case GLSL_TYPE_BOOL:
-      assert(!"FINISHME: Convert bool to float.");
+      from = new ir_expression(ir_unop_b2f, to, from, NULL);
+      break;
    default:
       assert(0);
    }
diff --git a/ir.cpp b/ir.cpp
index d9faac03d460adb3e676b08f2c52e177f6c341a4..674ba10f57e34519395992e59500b252809d4b3a 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -64,6 +64,8 @@ ir_expression::get_num_operands(void)
       1, /* ir_unop_log2 */
       1, /* ir_unop_f2i */
       1, /* ir_unop_i2f */
+      1, /* ir_unop_f2b */
+      1, /* ir_unop_b2f */
       1, /* ir_unop_u2f */
 
       1, /* ir_unop_trunc */
diff --git a/ir.h b/ir.h
index 64ed8818431539d728aa51c3d78a83a372c76e2e..58aa63123b413a9401907f85cd05e5f877ef8acd 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -316,6 +316,8 @@ enum ir_expression_operation {
    ir_unop_log2,
    ir_unop_f2i,      /**< Float-to-integer conversion. */
    ir_unop_i2f,      /**< Integer-to-float conversion. */
+   ir_unop_f2b,      /**< Float-to-boolean conversion */
+   ir_unop_b2f,      /**< Boolean-to-float conversion */
    ir_unop_u2f,      /**< Unsigned-to-float conversion. */
 
    /**
index b207262044df0f08f3ea4b007f456ee08767ca86..e3aeb69a1e999bb2cc31179eecfca835644b2496 100644 (file)
@@ -100,6 +100,8 @@ void ir_print_visitor::visit(ir_expression *ir)
       "log2",
       "f2i",
       "i2f",
+      "f2b",
+      "b2f",
       "u2f",
       "trunc",
       "ceil",