From 26b5d33dce37755a6a4a799a9edfcdff8c5ce3e5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 25 Jun 2010 16:19:45 -0700 Subject: glsl2: Use i2b and f2b IR opcodes for casting int or float to bool --- src/glsl/ast_function.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/glsl') diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp index 761af00b95..f431d1d015 100644 --- a/src/glsl/ast_function.cpp +++ b/src/glsl/ast_function.cpp @@ -172,17 +172,17 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) break; } break; - case GLSL_TYPE_BOOL: { - ir_constant *zero = NULL; - + case GLSL_TYPE_BOOL: switch (b) { - case GLSL_TYPE_UINT: zero = new(ctx) ir_constant(unsigned(0)); break; - case GLSL_TYPE_INT: zero = new(ctx) ir_constant(int(0)); break; - case GLSL_TYPE_FLOAT: zero = new(ctx) ir_constant(0.0f); break; + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + result = new(ctx) ir_expression(ir_unop_i2b, desired_type, src, NULL); + break; + case GLSL_TYPE_FLOAT: + result = new(ctx) ir_expression(ir_unop_f2b, desired_type, src, NULL); + break; } - - result = new(ctx) ir_expression(ir_binop_nequal, desired_type, src, zero); - } + break; } assert(result != NULL); -- cgit v1.2.3