i965: Share the sop opcodes between brw_wm_glsl.c and brw_wm_emit.c.
authorEric Anholt <eric@anholt.net>
Wed, 12 Aug 2009 04:17:14 +0000 (21:17 -0700)
committerEric Anholt <eric@anholt.net>
Sat, 7 Nov 2009 05:08:54 +0000 (21:08 -0800)
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/brw_wm_glsl.c

index e0445aa..df8e467 100644 (file)
@@ -357,5 +357,11 @@ void emit_mad(struct brw_compile *p,
              const struct brw_reg *arg0,
              const struct brw_reg *arg1,
              const struct brw_reg *arg2);
+void emit_sop(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             GLuint cond,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1);
 
 #endif
index 6cdc4f7..41ebadb 100644 (file)
@@ -447,21 +447,24 @@ void emit_lrp(struct brw_compile *p,
    }
 }
 
-static void emit_sop( struct brw_compile *p, 
-                     const struct brw_reg *dst,
-                     GLuint mask,
-                     GLuint cond,
-                     const struct brw_reg *arg0,
-                     const struct brw_reg *arg1 )
+void emit_sop(struct brw_compile *p,
+             const struct brw_reg *dst,
+             GLuint mask,
+             GLuint cond,
+             const struct brw_reg *arg0,
+             const struct brw_reg *arg1)
 {
    GLuint i;
 
    for (i = 0; i < 4; i++) {
       if (mask & (1<<i)) {     
-        brw_MOV(p, dst[i], brw_imm_f(0));
+        brw_push_insn_state(p);
         brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
+        brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+        brw_MOV(p, dst[i], brw_imm_f(0));
+        brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
         brw_MOV(p, dst[i], brw_imm_f(1.0));
-        brw_set_predicate_control_flag_value(p, 0xff);
+        brw_pop_insn_state(p);
       }
    }
 }
index 55e3e9f..2df4734 100644 (file)
@@ -1214,66 +1214,6 @@ static void emit_kil(struct brw_wm_compile *c)
     brw_pop_insn_state(p);
 }
 
-static void emit_sop(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst, GLuint cond)
-{
-    struct brw_compile *p = &c->func;
-    GLuint mask = inst->DstReg.WriteMask;
-    struct brw_reg dst, src0, src1;
-    int i;
-
-    for (i = 0; i < 4; i++) {
-       if (mask & (1<<i)) {
-           dst = get_dst_reg(c, inst, i);
-           src0 = get_src_reg(c, inst, 0, i);
-           src1 = get_src_reg_imm(c, inst, 1, i);
-           brw_push_insn_state(p);
-           brw_CMP(p, brw_null_reg(), cond, src0, src1);
-           brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-           brw_MOV(p, dst, brw_imm_f(0.0));
-           brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
-           brw_MOV(p, dst, brw_imm_f(1.0));
-           brw_pop_insn_state(p);
-       }
-    }
-}
-
-static void emit_slt(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_L);
-}
-
-static void emit_sle(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_LE);
-}
-
-static void emit_sgt(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_G);
-}
-
-static void emit_sge(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_GE);
-}
-
-static void emit_seq(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_EQ);
-}
-
-static void emit_sne(struct brw_wm_compile *c,
-                     const struct prog_instruction *inst)
-{
-    emit_sop(c, inst, BRW_CONDITIONAL_NEQ);
-}
-
 static INLINE struct brw_reg high_words( struct brw_reg reg )
 {
     return stride( suboffset( retype( reg, BRW_REGISTER_TYPE_W ), 1 ),
@@ -2687,22 +2627,28 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
                          args[0]);
                 break;
            case OPCODE_SLT:
-               emit_slt(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_L, args[0], args[1]);
                break;
            case OPCODE_SLE:
-               emit_sle(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_LE, args[0], args[1]);
                break;
            case OPCODE_SGT:
-               emit_sgt(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_G, args[0], args[1]);
                break;
            case OPCODE_SGE:
-               emit_sge(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_GE, args[0], args[1]);
                break;
            case OPCODE_SEQ:
-               emit_seq(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_EQ, args[0], args[1]);
                break;
            case OPCODE_SNE:
-               emit_sne(c, inst);
+               emit_sop(p, dst, dst_flags,
+                        BRW_CONDITIONAL_NEQ, args[0], args[1]);
                break;
            case OPCODE_MUL:
                emit_alu2(p, brw_MUL, dst, dst_flags, args[0], args[1]);