i965/fs: Fix the gen6-specific if handling for 80ecb8f15b9ad7d6edc
authorEric Anholt <eric@anholt.net>
Mon, 12 Nov 2012 21:13:55 +0000 (13:13 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 30 Jan 2013 20:14:31 +0000 (12:14 -0800)
Fixes oglconform shad-compiler advanced.TestLessThani.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=48629
NOTE: This is a candidate for the 9.0 branch.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 0482998ccc205a9d29953c7a8b33f41ae3584935)

Conflicts: fs_inst doesn't have a "predicate" field on the 9.0 branch,
so convert it to "predicated = true".  See 54679fcbcae7a2d41cb43.

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

index d3cbde3..6fe468c 100644 (file)
@@ -1609,28 +1609,14 @@ fs_visitor::emit_if_gen6(ir_if *ir)
 
       switch (expr->operation) {
       case ir_unop_logic_not:
-        inst = emit(BRW_OPCODE_IF, temp, op[0], fs_reg(0));
-        inst->conditional_mod = BRW_CONDITIONAL_Z;
-        return;
-
       case ir_binop_logic_xor:
-        inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], op[1]);
-        inst->conditional_mod = BRW_CONDITIONAL_NZ;
-        return;
-
       case ir_binop_logic_or:
-        temp = fs_reg(this, glsl_type::bool_type);
-        emit(BRW_OPCODE_OR, temp, op[0], op[1]);
-        inst = emit(BRW_OPCODE_IF, reg_null_d, temp, fs_reg(0));
-        inst->conditional_mod = BRW_CONDITIONAL_NZ;
-        return;
-
       case ir_binop_logic_and:
-        temp = fs_reg(this, glsl_type::bool_type);
-        emit(BRW_OPCODE_AND, temp, op[0], op[1]);
-        inst = emit(BRW_OPCODE_IF, reg_null_d, temp, fs_reg(0));
-        inst->conditional_mod = BRW_CONDITIONAL_NZ;
-        return;
+         /* For operations on bool arguments, only the low bit of the bool is
+          * valid, and the others are undefined.  Fall back to the condition
+          * code path.
+          */
+         break;
 
       case ir_unop_f2b:
         inst = emit(BRW_OPCODE_IF, reg_null_f, op[0], fs_reg(0));
@@ -1650,6 +1636,9 @@ fs_visitor::emit_if_gen6(ir_if *ir)
       case ir_binop_all_equal:
       case ir_binop_nequal:
       case ir_binop_any_nequal:
+        resolve_bool_comparison(expr->operands[0], &op[0]);
+        resolve_bool_comparison(expr->operands[1], &op[1]);
+
         inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], op[1]);
         inst->conditional_mod =
            brw_conditional_for_comparison(expr->operation);
@@ -1661,13 +1650,11 @@ fs_visitor::emit_if_gen6(ir_if *ir)
         fail("bad condition\n");
         return;
       }
-      return;
    }
 
-   ir->condition->accept(this);
-
-   fs_inst *inst = emit(BRW_OPCODE_IF, reg_null_d, this->result, fs_reg(0));
-   inst->conditional_mod = BRW_CONDITIONAL_NZ;
+   emit_bool_to_cond_code(ir->condition);
+   fs_inst *inst = emit(BRW_OPCODE_IF);
+   inst->predicated = true;
 }
 
 void