diff options
author | Kenneth Graunke <[email protected]> | 2012-10-08 10:45:08 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2012-11-01 14:29:21 -0700 |
commit | 1f0093720de41ca23c408f11784fcc39d58271d2 (patch) | |
tree | fb05217196eeacfc636d3a1f76f86ce0150b331a /src/mesa/drivers | |
parent | fd8655aa7a78f3ded44e9dee572f17309a44a945 (diff) |
i965/vs: Refactor min/max handling to share code.
v2: Properly use "conditionalmod" pre-Gen6, rather than the incorrectly
copy-and-pasted "BRW_CONDITIONAL_G".
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 37 |
2 files changed, 21 insertions, 18 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 402e67ab818..e4dcbc43309 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -373,6 +373,8 @@ public: void emit_bool_comparison(unsigned int op, dst_reg dst, src_reg src0, src_reg src1); void emit_if_gen6(ir_if *ir); + void emit_minmax(uint32_t condmod, dst_reg dst, src_reg src0, src_reg src1); + void emit_block_move(dst_reg *dst, src_reg *src, const struct glsl_type *type, uint32_t predicate); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index f2bf35f7e34..713427b66da 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -999,6 +999,23 @@ vec4_visitor::emit_bool_comparison(unsigned int op, } void +vec4_visitor::emit_minmax(uint32_t conditionalmod, dst_reg dst, + src_reg src0, src_reg src1) +{ + vec4_instruction *inst; + + if (intel->gen >= 6) { + inst = emit(BRW_OPCODE_SEL, dst, src0, src1); + inst->conditional_mod = conditionalmod; + } else { + emit(CMP(dst, src0, src1, conditionalmod)); + + inst = emit(BRW_OPCODE_SEL, dst, src0, src1); + inst->predicate = BRW_PREDICATE_NORMAL; + } +} + +void vec4_visitor::visit(ir_expression *ir) { unsigned int operand; @@ -1272,26 +1289,10 @@ vec4_visitor::visit(ir_expression *ir) break; case ir_binop_min: - if (intel->gen >= 6) { - inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]); - inst->conditional_mod = BRW_CONDITIONAL_L; - } else { - emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_L)); - - inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]); - inst->predicate = BRW_PREDICATE_NORMAL; - } + emit_minmax(BRW_CONDITIONAL_L, result_dst, op[0], op[1]); break; case ir_binop_max: - if (intel->gen >= 6) { - inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]); - inst->conditional_mod = BRW_CONDITIONAL_G; - } else { - emit(CMP(result_dst, op[0], op[1], BRW_CONDITIONAL_G)); - - inst = emit(BRW_OPCODE_SEL, result_dst, op[0], op[1]); - inst->predicate = BRW_PREDICATE_NORMAL; - } + emit_minmax(BRW_CONDITIONAL_G, result_dst, op[0], op[1]); break; case ir_binop_pow: |