i965: Mask out higher bits of the result of BRW_CMP producing a boolean.
authorEric Anholt <eric@anholt.net>
Fri, 27 Aug 2010 20:49:09 +0000 (13:49 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 27 Aug 2010 20:59:36 +0000 (13:59 -0700)
When it says it sets the LSB, that's not just a hint as to where the
result goes.  Only the LSB is modified.  Fixes 20 piglit cases.

src/mesa/drivers/dri/i965/brw_fs.cpp

index 98d5d65940808debd6e08e1577c97cf86bcd4dfc..3f41a5533151ab76f881c77759343f213e69d1a8 100644 (file)
@@ -710,26 +710,32 @@ fs_visitor::visit(ir_expression *ir)
    case ir_binop_less:
       inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1]));
       inst->conditional_mod = BRW_CONDITIONAL_L;
+      emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)));
       break;
    case ir_binop_greater:
       inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1]));
       inst->conditional_mod = BRW_CONDITIONAL_G;
+      emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)));
       break;
    case ir_binop_lequal:
       inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1]));
       inst->conditional_mod = BRW_CONDITIONAL_LE;
+      emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)));
       break;
    case ir_binop_gequal:
       inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1]));
       inst->conditional_mod = BRW_CONDITIONAL_GE;
+      emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)));
       break;
    case ir_binop_equal:
       inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1]));
       inst->conditional_mod = BRW_CONDITIONAL_Z;
+      emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)));
       break;
    case ir_binop_nequal:
       inst = emit(fs_inst(BRW_OPCODE_CMP, this->result, op[0], op[1]));
       inst->conditional_mod = BRW_CONDITIONAL_NZ;
+      emit(fs_inst(BRW_OPCODE_AND, this->result, this->result, fs_reg(0x1)));
       break;
 
    case ir_binop_logic_xor: