From: Ian Romanick <ian.d.roman...@intel.com> Shader-db results:
Ivy Bridge (0x0166): total instructions in shared programs: 6291662 -> 6291642 (-0.00%) instructions in affected programs: 3383 -> 3363 (-0.59%) helped: 20 Haswell (0x0426): total instructions in shared programs: 5779036 -> 5779016 (-0.00%) instructions in affected programs: 3050 -> 3030 (-0.66%) helped: 20 Broadwell (0x162E): total instructions in shared programs: 6822830 -> 6822810 (-0.00%) instructions in affected programs: 3038 -> 3018 (-0.66%) helped: 20 No change on GM45, Iron Lake, Sandy Bridge, or any platform with NIR. Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index bde9492..f1e9fb5 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -2631,6 +2631,36 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) return; } + /* Try to generate the condition code more efficiently for gl_FrontFacing + * and !gl_FrontFacing. + */ + enum brw_conditional_mod cm; + ir_dereference_variable *deref; + + if (expr && expr->operation == ir_unop_logic_not) { + cm = BRW_CONDITIONAL_NZ; + deref = expr->operands[0]->as_dereference_variable(); + } else { + cm = BRW_CONDITIONAL_Z; + deref = ir->as_dereference_variable(); + } + + if (deref != NULL && strcmp(deref->var->name, "gl_FrontFacing") == 0) { + if (brw->gen >= 6) { + /* Bit 15 of g0.0 is 0 if the polygon is front facing. */ + emit(AND(reg_null_d, retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_D), + fs_reg(0x00008000))) + ->conditional_mod = cm; + } else { + /* Bit 31 of g1.6 is 0 if the polygon is front facing. */ + emit(AND(reg_null_d, retype(brw_vec1_grf(1, 6), BRW_REGISTER_TYPE_D), + fs_reg(0x80000000))) + ->conditional_mod = cm; + } + + return; + } + fs_reg op[3]; assert(expr->get_num_operands() <= 3); -- 2.1.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev