Mesa (master): mesa: fix frag shader generation for alpha test with no color buffers
Brian Paul
brianp at kemper.freedesktop.org
Mon Nov 28 15:16:30 UTC 2011
Module: Mesa
Branch: master
Commit: e68994494b159d4f44e34b6b6c1d489a184a2dfe
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e68994494b159d4f44e34b6b6c1d489a184a2dfe
Author: Brian Paul <brianp at vmware.com>
Date: Sat Nov 26 08:54:57 2011 -0700
mesa: fix frag shader generation for alpha test with no color buffers
If alpha test is enabled and there's no color buffers we still need the
fragment shader to emit a color.
v2: add _NEW_COLOR flag in _mesa_update_state_locked()
Fixes piglit fbo-alphatest-nocolor-ff failures with Gallium drivers.
Reviewed-by: Eric Anholt <eric at anholt.net>
Tested-by: Eric Anholt <eric at anholt.net> (i965)
---
src/mesa/main/ff_fragment_shader.cpp | 6 ++++++
src/mesa/main/state.c | 2 +-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 2ce81fe..3d7947b 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -489,6 +489,12 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
/* _NEW_BUFFERS */
key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+ /* _NEW_COLOR */
+ if (ctx->Color.AlphaEnabled && key->num_draw_buffers == 0) {
+ /* if alpha test is enabled we need to emit at least one color */
+ key->num_draw_buffers = 1;
+ }
+
key->inputs_available = (inputs_available & inputs_referenced);
/* compute size of state key, ignoring unused texture units */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 80fd03b..bed6c89 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -589,7 +589,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
if (ctx->FragmentProgram._MaintainTexEnvProgram) {
prog_flags |= (_NEW_BUFFERS | _NEW_TEXTURE | _NEW_FOG |
_NEW_ARRAY | _NEW_LIGHT | _NEW_POINT | _NEW_RENDERMODE |
- _NEW_PROGRAM | _NEW_FRAG_CLAMP);
+ _NEW_PROGRAM | _NEW_FRAG_CLAMP | _NEW_COLOR);
}
if (ctx->VertexProgram._MaintainTnlProgram) {
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
More information about the mesa-commit
mailing list