From dc58b3f8ccd817fdee390a3df5b8e0fb29d5397c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 2 Apr 2010 02:13:43 -1000 Subject: [PATCH] Add conversion of bool to float as an IR operation to match int to float. --- ast_function.cpp | 2 +- ast_to_hir.cpp | 3 ++- ir.cpp | 2 ++ ir.h | 2 ++ ir_print_visitor.cpp | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ast_function.cpp b/ast_function.cpp index 91d4f15..2ca8976 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -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: { diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5e0dcaa..dd84674 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -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 d9faac0..674ba10 100644 --- 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 64ed881..58aa631 100644 --- 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. */ /** diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index b207262..e3aeb69 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -100,6 +100,8 @@ void ir_print_visitor::visit(ir_expression *ir) "log2", "f2i", "i2f", + "f2b", + "b2f", "u2f", "trunc", "ceil", -- 2.7.4