i965: Add support for KIL_NV in brw_wm_emit.c
authorEric Anholt <eric@anholt.net>
Thu, 3 Sep 2009 16:11:44 +0000 (09:11 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 4 Sep 2009 21:20:08 +0000 (14:20 -0700)
I ran into this lack of support when writing a shader that always discarded
the fragments.

src/mesa/drivers/dri/i965/brw_wm_emit.c
src/mesa/drivers/dri/i965/brw_wm_pass1.c

index 268f7965c002d1c3e2bca809c2fde8d8f855c876..981864323ec114f32b3a72ca195eadbdf7882453 100644 (file)
@@ -908,6 +908,20 @@ static void emit_kil( struct brw_wm_compile *c,
    }
 }
 
+/* KIL_NV kills the pixels that are currently executing, not based on a test
+ * of the arguments.
+ */
+static void emit_kil_nv( struct brw_wm_compile *c )
+{
+   struct brw_compile *p = &c->func;
+   struct brw_reg r0uw = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
+
+   brw_push_insn_state(p);
+   brw_set_mask_control(p, BRW_MASK_DISABLE);
+   brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
+   brw_AND(p, r0uw, c->emit_mask_reg, r0uw);
+   brw_pop_insn_state(p);
+}
 
 static void fire_fb_write( struct brw_wm_compile *c,
                           GLuint base_reg,
@@ -1387,6 +1401,10 @@ void brw_wm_emit( struct brw_wm_compile *c )
         emit_kil(c, args[0]);
         break;
 
+      case OPCODE_KIL_NV:
+        emit_kil_nv(c);
+        break;
+
       default:
         _mesa_printf("Unsupported opcode %i (%s) in fragment shader\n",
                      inst->opcode, inst->opcode < MAX_OPCODE ?
index 3436a2471709fddf3ff15e1c472343322cc4209a..9c68bfd78b2e7f4c8fd08a8dd4797851db96347c 100644 (file)
@@ -270,6 +270,7 @@ void brw_wm_pass1( struct brw_wm_compile *c )
 
       case OPCODE_DST:
       case WM_FRONTFACING:
+      case OPCODE_KIL_NV:
       default:
         break;
       }