diff options
author | Kenneth Graunke <[email protected]> | 2014-09-04 00:18:43 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2014-09-08 15:43:49 -0700 |
commit | 6272e60ca394a8da178d3352831a48f4c429a3bc (patch) | |
tree | df3f503136f9028c7290fb8c1e1854b223a7951c | |
parent | 12fb74fe895fe9954df127ca0ec6e4422fffb156 (diff) |
i965: Handle ir_triop_csel in emit_if_gen6().
ir_triop_csel can return a boolean expression, so we need to handle it
here; we simply forgot when we added ir_triop_csel, and forgot again
when adding it to emit_bool_to_cond_code.
Fixes Piglit's EXT_shader_integer_mix/{vs,fs}-mix-if-bool on Sandybridge.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Cc: [email protected]
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 19 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 18 |
2 files changed, 33 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 2a097f6588a..6ca4530ec76 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2364,11 +2364,11 @@ fs_visitor::emit_if_gen6(ir_if *ir) ir_expression *expr = ir->condition->as_expression(); if (expr) { - fs_reg op[2]; + fs_reg op[3]; fs_inst *inst; fs_reg temp; - assert(expr->get_num_operands() <= 2); + assert(expr->get_num_operands() <= 3); for (unsigned int i = 0; i < expr->get_num_operands(); i++) { assert(expr->operands[i]->type->is_scalar()); @@ -2412,6 +2412,21 @@ fs_visitor::emit_if_gen6(ir_if *ir) emit(IF(op[0], op[1], brw_conditional_for_comparison(expr->operation))); return; + + case ir_triop_csel: { + /* Expand the boolean condition into the flag register. */ + fs_inst *inst = emit(MOV(reg_null_d, op[0])); + inst->conditional_mod = BRW_CONDITIONAL_NZ; + + /* Select which boolean to use as the result. */ + fs_reg temp(this, expr->operands[1]->type); + inst = emit(SEL(temp, op[1], op[2])); + inst->predicate = BRW_PREDICATE_NORMAL; + + emit(IF(temp, fs_reg(0), BRW_CONDITIONAL_NZ)); + return; + } + default: unreachable("not reached"); } diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 7de77557a51..93ea63deffb 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -898,10 +898,10 @@ vec4_visitor::emit_if_gen6(ir_if *ir) ir_expression *expr = ir->condition->as_expression(); if (expr) { - src_reg op[2]; + src_reg op[3]; dst_reg temp; - assert(expr->get_num_operands() <= 2); + assert(expr->get_num_operands() <= 3); for (unsigned int i = 0; i < expr->get_num_operands(); i++) { expr->operands[i]->accept(this); op[i] = this->result; @@ -961,6 +961,20 @@ vec4_visitor::emit_if_gen6(ir_if *ir) emit(IF(BRW_PREDICATE_ALIGN16_ANY4H)); return; + case ir_triop_csel: { + /* Expand the boolean condition into the flag register. */ + vec4_instruction *inst = emit(MOV(dst_null_d(), op[0])); + inst->conditional_mod = BRW_CONDITIONAL_NZ; + + /* Select which boolean to return. */ + dst_reg temp(this, expr->operands[1]->type); + inst = emit(BRW_OPCODE_SEL, temp, op[1], op[2]); + inst->predicate = BRW_PREDICATE_NORMAL; + + emit(IF(src_reg(temp), src_reg(0), BRW_CONDITIONAL_NZ)); + return; + } + default: unreachable("not reached"); } |