Mesa (master): i965: Always emit alpha when nr_color_buffers == 0.
Kenneth Graunke
kwg at kemper.freedesktop.org
Thu Jul 12 20:40:19 UTC 2012
Module: Mesa
Branch: master
Commit: 86e401b771ce4a6f9a728f76c5061c339f012d0a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=86e401b771ce4a6f9a728f76c5061c339f012d0a
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Thu Jul 12 11:25:58 2012 -0700
i965: Always emit alpha when nr_color_buffers == 0.
If alpha-testing is enabled, we need to send alpha down the pipeline
even if nr_color_buffers == 0. However, tracking whether alpha-testing
is enabled in the WM program key is expensive: it causes us to compile
multiple specializations of the same shader, using program cache space.
This patch removes the check for alpha-testing, and simply emits alpha
whenever nr_color_buffers == 0. We believe this will also be necessary
for alpha-to-coverage, and it should add minimal overhead to an uncommon
case. Saving the recompiles should more than make up the difference.
Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 12 +++++-------
src/mesa/drivers/dri/i965/brw_wm.c | 4 +---
src/mesa/drivers/dri/i965/brw_wm.h | 1 -
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 7224cbe..08c0130 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2141,13 +2141,11 @@ fs_visitor::emit_fb_writes()
}
if (c->key.nr_color_regions == 0) {
- if (c->key.alpha_test) {
- /* 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.
- */
- emit_color_write(0, 3, color_mrf);
- }
+ /* Even if there's no color buffers enabled, we still need to send
+ * alpha out the pipeline to our null renderbuffer to support
+ * alpha-testing, alpha-to-coverage, and so on.
+ */
+ emit_color_write(0, 3, color_mrf);
fs_inst *inst = emit(FS_OPCODE_FB_WRITE);
inst->base_mrf = base_mrf;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 8805646..7194a73 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -449,10 +449,8 @@ 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 (intel->gen < 6) {
+ /* _NEW_COLOR */
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 2cde2a0..b976a60 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -65,7 +65,6 @@ struct brw_wm_prog_key {
GLuint flat_shade:1;
GLuint nr_color_regions:5;
GLuint render_to_fbo:1;
- GLuint alpha_test:1;
GLuint clamp_fragment_color:1;
GLuint line_aa:2;
More information about the mesa-commit
mailing list