i965/fs: Make an emit_discard_jump() function to reduce duplication.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 5 Mar 2015 23:48:39 +0000 (15:48 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 19 Mar 2015 23:14:51 +0000 (16:14 -0700)
This is already copied in two places, and I want to copy it to a third
place.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index 10084675c836bbb9caf99ada82abe9563426a560..780be80e6a7be97c98c98fe32c7f3467f90ba3bb 100644 (file)
@@ -1693,6 +1693,21 @@ fs_visitor::emit_math(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1)
    return inst;
 }
 
+void
+fs_visitor::emit_discard_jump()
+{
+   /* For performance, after a discard, jump to the end of the
+    * shader if all relevant channels have been discarded.
+    */
+   fs_inst *discard_jump = emit(FS_OPCODE_DISCARD_JUMP);
+   discard_jump->flag_subreg = 1;
+
+   discard_jump->predicate = (dispatch_width == 8)
+                             ? BRW_PREDICATE_ALIGN1_ANY8H
+                             : BRW_PREDICATE_ALIGN1_ANY16H;
+   discard_jump->predicate_inverse = true;
+}
+
 void
 fs_visitor::assign_curb_setup()
 {
index 83178311a7cbbec56dc74eeedc9b97ab13652a0e..608262fd24640c86417e86e0efb8ffe98c241966 100644 (file)
@@ -307,6 +307,7 @@ public:
                  const fs_reg &a);
    void emit_minmax(enum brw_conditional_mod conditionalmod, const fs_reg &dst,
                     const fs_reg &src0, const fs_reg &src1);
+   void emit_discard_jump();
    bool try_emit_b2f_of_comparison(ir_expression *ir);
    bool try_emit_saturate(ir_expression *ir);
    bool try_emit_line(ir_expression *ir);
index 05506f57e1218d8e229f77a3d2ed4d15b8bb4e63..5d88fe7ae6106e1010a96ee3a1d5c5c0a9355c71 100644 (file)
@@ -1363,18 +1363,8 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
       cmp->flag_subreg = 1;
 
       if (brw->gen >= 6) {
-         /* For performance, after a discard, jump to the end of the shader.
-         * Only jump if all relevant channels have been discarded.
-         */
-         fs_inst *discard_jump = emit(FS_OPCODE_DISCARD_JUMP);
-         discard_jump->flag_subreg = 1;
-
-         discard_jump->predicate = (dispatch_width == 8)
-                                 ? BRW_PREDICATE_ALIGN1_ANY8H
-                                 : BRW_PREDICATE_ALIGN1_ANY16H;
-         discard_jump->predicate_inverse = true;
+         emit_discard_jump();
       }
-
       break;
    }
 
index 60a7a97f0e07c8e9e49f52917fa3a5c159c02529..2920a82abc6e0625cfaf89b942313db1305bc291 100644 (file)
@@ -2497,16 +2497,7 @@ fs_visitor::visit(ir_discard *ir)
    cmp->flag_subreg = 1;
 
    if (brw->gen >= 6) {
-      /* For performance, after a discard, jump to the end of the shader.
-       * Only jump if all relevant channels have been discarded.
-       */
-      fs_inst *discard_jump = emit(FS_OPCODE_DISCARD_JUMP);
-      discard_jump->flag_subreg = 1;
-
-      discard_jump->predicate = (dispatch_width == 8)
-                                ? BRW_PREDICATE_ALIGN1_ANY8H
-                                : BRW_PREDICATE_ALIGN1_ANY16H;
-      discard_jump->predicate_inverse = true;
+      emit_discard_jump();
    }
 }