i965: Fix alpha testing when there is no color buffer in the FBO.
authorEric Anholt <eric@anholt.net>
Sat, 12 Mar 2011 01:39:49 +0000 (17:39 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 15 Mar 2011 17:14:52 +0000 (10:14 -0700)
We were alpha testing against an unwritten value, resulting in garbage.
(part of) Bug #35073.

src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm.h

index 7329f309f0fe31a81438359b58bf5057948c65d9..2c997b4eb3aedcabbdb3c47c4319d30909da3921 100644 (file)
@@ -2140,6 +2140,17 @@ fs_visitor::emit_fb_writes()
    }
 
    if (c->key.nr_color_regions == 0) {
+      if (c->key.alpha_test && (this->frag_color || this->frag_data)) {
+        /* If the alpha test is enabled but there's no color buffer,
+         * we still need to send alpha out the pipeline to our null
+         * renderbuffer.
+         */
+        color.reg_offset += 3;
+        emit(fs_inst(BRW_OPCODE_MOV,
+                     fs_reg(MRF, color_mrf + 3),
+                     color));
+      }
+
       fs_inst *inst = emit(fs_inst(FS_OPCODE_FB_WRITE,
                                   reg_undef, reg_undef));
       inst->base_mrf = 0;
index ca17e80c8da5d9421157876ec0450b24cf61c8c2..ca51d1599a4a372479682c80b46a6070f3f8b84b 100644 (file)
@@ -284,6 +284,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
    /* Build the index for table lookup
     */
    /* _NEW_COLOR */
+   key->alpha_test = ctx->Color.AlphaEnabled;
    if (fp->program.UsesKill ||
        ctx->Color.AlphaEnabled)
       lookup |= IZ_PS_KILL_ALPHATEST_BIT;
index d9cae75ab5b7861ce06d9b643d9eb7eeac7adb47..90771e1f503e73fef245192b19ed989d92113388 100644 (file)
@@ -64,6 +64,7 @@ struct brw_wm_prog_key {
    GLuint linear_color:1;  /**< linear interpolation vs perspective interp */
    GLuint nr_color_regions:5;
    GLuint render_to_fbo:1;
+   GLuint alpha_test:1;
 
    GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
    GLuint shadowtex_mask:16;