diff options
author | Ian Romanick <[email protected]> | 2010-06-11 16:52:09 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2010-06-11 17:12:23 -0700 |
commit | b74b43e4ba27a9b2e9da0f3499af261a4b997b00 (patch) | |
tree | 1c8e542557c73cebc9a9fa522de084c74e9829a3 /ast_function.cpp | |
parent | 4976e57448b2d4ca753e95ef2162758542a69a77 (diff) |
Use statically typed ir_constant constructors wherever possible
Diffstat (limited to 'ast_function.cpp')
-rw-r--r-- | ast_function.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ast_function.cpp b/ast_function.cpp index d89266b9cc7..279c45eac0e 100644 --- a/ast_function.cpp +++ b/ast_function.cpp @@ -170,8 +170,13 @@ convert_component(ir_rvalue *src, const glsl_type *desired_type) } break; case GLSL_TYPE_BOOL: { - int z = 0; - ir_constant *const zero = new ir_constant(src->type, &z); + ir_constant *zero = NULL; + + switch (b) { + case GLSL_TYPE_UINT: zero = new ir_constant(unsigned(0)); break; + case GLSL_TYPE_INT: zero = new ir_constant(int(0)); break; + case GLSL_TYPE_FLOAT: zero = new ir_constant(0.0f); break; + } result = new ir_expression(ir_binop_nequal, desired_type, src, zero); } @@ -211,7 +216,7 @@ dereference_component(ir_rvalue *src, unsigned component) */ const int c = component / src->type->column_type()->vector_elements; const int r = component % src->type->column_type()->vector_elements; - ir_constant *const col_index = new ir_constant(glsl_type::int_type, &c); + ir_constant *const col_index = new ir_constant(c); ir_dereference *const col = new ir_dereference_array(src, col_index); col->type = src->type->column_type(); |