From 1412dea94953243b5cd3a452f676afd046101192 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 6 Dec 2010 16:00:24 -0800 Subject: glsl: Add type inference support for remaining expression opcodes. --- src/glsl/ir.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/glsl/ir.cpp') diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index b8b0fed9d1..742dd41b9f 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -261,12 +261,38 @@ ir_expression::ir_expression(int op, ir_rvalue *op0) case ir_unop_floor: case ir_unop_fract: case ir_unop_round_even: + case ir_unop_sin: case ir_unop_cos: + case ir_unop_sin_reduced: + case ir_unop_cos_reduced: case ir_unop_dFdx: case ir_unop_dFdy: this->type = op0->type; break; + case ir_unop_f2i: + case ir_unop_b2i: + this->type = glsl_type::get_instance(GLSL_TYPE_INT, + op0->type->vector_elements, 1); + break; + + case ir_unop_b2f: + case ir_unop_i2f: + case ir_unop_u2f: + this->type = glsl_type::get_instance(GLSL_TYPE_FLOAT, + op0->type->vector_elements, 1); + break; + + case ir_unop_f2b: + case ir_unop_i2b: + this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, + op0->type->vector_elements, 1); + break; + + case ir_unop_noise: + this->type = glsl_type::float_type; + break; + case ir_unop_any: this->type = glsl_type::bool_type; break; @@ -302,6 +328,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) case ir_binop_max: case ir_binop_pow: case ir_binop_mul: + case ir_binop_div: + case ir_binop_mod: if (op0->type->is_scalar()) { this->type = op1->type; } else if (op1->type->is_scalar()) { @@ -315,7 +343,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) break; case ir_binop_logic_and: + case ir_binop_logic_xor: case ir_binop_logic_or: + case ir_binop_bit_and: + case ir_binop_bit_xor: + case ir_binop_bit_or: if (op0->type->is_scalar()) { this->type = op1->type; } else if (op1->type->is_scalar()) { @@ -323,10 +355,26 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) } break; + case ir_binop_equal: + case ir_binop_nequal: + case ir_binop_lequal: + case ir_binop_gequal: + case ir_binop_less: + case ir_binop_greater: + assert(op0->type == op1->type); + this->type = glsl_type::get_instance(GLSL_TYPE_BOOL, + op0->type->vector_elements, 1); + break; + case ir_binop_dot: this->type = glsl_type::float_type; break; + case ir_binop_lshift: + case ir_binop_rshift: + this->type = op0->type; + break; + default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = glsl_type::float_type; -- cgit v1.2.3