Add conversion of bool to float as an IR operation to match int to float.

This commit is contained in:
Eric Anholt
2010-04-02 02:13:43 -10:00
committed by Ian Romanick
parent 106d122318
commit dc58b3f8cc
5 changed files with 9 additions and 2 deletions

View 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: {

View 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);
}

2
ir.cpp
View File

@@ -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 */

2
ir.h
View File

@@ -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. */
/**

View File

@@ -100,6 +100,8 @@ void ir_print_visitor::visit(ir_expression *ir)
"log2",
"f2i",
"i2f",
"f2b",
"b2f",
"u2f",
"trunc",
"ceil",