glsl: Fix DIV_TO_MUL_RCP lowering for uint result types.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 15 Jun 2011 05:47:04 +0000 (22:47 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 29 Jun 2011 23:07:13 +0000 (16:07 -0700)
f2i results in an int/ivec; we need i2u to get a uint/uvec.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/lower_instructions.cpp

index a5f61f213d056d8098083bdd2a479c292861b1e7..94b8c4a6836d292b2c718b42a33d4f26e25f6102 100644 (file)
@@ -168,8 +168,13 @@ lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
 
       op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
 
-      ir->operation = ir_unop_f2i;
-      ir->operands[0] = op0;
+      if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) {
+        ir->operation = ir_unop_f2i;
+        ir->operands[0] = op0;
+      } else {
+        ir->operation = ir_unop_i2u;
+        ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0);
+      }
       ir->operands[1] = NULL;
    }