Mesa (7.10): i965: Fix alpha testing when there is no color buffer in the FBO.

Ian Romanick idr at kemper.freedesktop.org
Thu Mar 24 20:54:49 UTC 2011


Module: Mesa
Branch: 7.10
Commit: 78fa94f091382fad15554e83d0a841bc8651ccd3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=78fa94f091382fad15554e83d0a841bc8651ccd3

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Mar 11 17:39:49 2011 -0800

i965: Fix alpha testing when there is no color buffer in the FBO.

We were alpha testing against an unwritten value, resulting in garbage.
(part of) Bug #35073.
(cherry picked from commit a99447314ca1cfce60f2a22285398fb222b2a440)

---

 src/mesa/drivers/dri/i965/brw_fs.cpp |   11 +++++++++++
 src/mesa/drivers/dri/i965/brw_wm.c   |    1 +
 src/mesa/drivers/dri/i965/brw_wm.h   |    1 +
 3 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 5c40723..12ac7a4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2094,6 +2094,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;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 4f4cd9d..de8e3af 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index e7f3cfb..85bb7fb 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -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;




More information about the mesa-commit mailing list