[Mesa-dev] [PATCH] i965: Set brw_wm_prog_key::alpha_test only if nr_color_buffers == 0.
Kenneth Graunke
kenneth at whitecape.org
Sat Jun 16 21:27:14 PDT 2012
If alpha testing is enabled, we need to include alpha in the FB write.
Normally, this occurs as part of a color buffer write, but it's possible
to use alpha testing without any color buffers. The alpha_test flag
lets brw_fs.cpp know that the shader needs to send alpha anyway.
Since the flag's only use occurs when nr_color_buffers == 0, we don't
need to set it in the general case; in fact, doing so will result in two
indentical shaders being compiled, wasting time and program cache space.
This patch also renames it to "alpha_only", since it no longer
represents when alpha testing is enabled or disabled.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 2 +-
src/mesa/drivers/dri/i965/brw_wm.c | 7 ++++---
src/mesa/drivers/dri/i965/brw_wm.h | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 4f27a81..3db346c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2193,7 +2193,7 @@ fs_visitor::emit_fb_writes()
}
if (c->key.nr_color_regions == 0) {
- if (c->key.alpha_test) {
+ if (c->key.alpha_only) {
/* 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.
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index a169fd5..10f1dce 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -431,10 +431,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;
@@ -529,6 +527,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
/* _NEW_BUFFERS */
key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
+ /* _NEW_COLOR */
+ key->alpha_only = ctx->Color.AlphaEnabled && key->nr_color_regions == 0;
+
/* CACHE_NEW_VS_PROG */
key->vp_outputs_written = brw->vs.prog_data->outputs_written;
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index 8f1cb8c..88f21d0 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -65,7 +65,7 @@ struct brw_wm_prog_key {
GLuint flat_shade:1;
GLuint nr_color_regions:5;
GLuint render_to_fbo:1;
- GLuint alpha_test:1;
+ GLuint alpha_only:1; /**< No color regions, but alpha testing enabled */
GLuint clamp_fragment_color:1;
GLuint line_aa:2;
--
1.7.10.4
More information about the mesa-dev
mailing list