[Mesa-dev] [PATCH 2/2] mesa: Fix ff alpha testing even when there is no color buffer in the FBO.
Eric Anholt
eric at anholt.net
Fri Mar 11 17:49:44 PST 2011
Bug #35073.
---
src/mesa/main/ff_fragment_shader.cpp | 6 +++++-
src/mesa/main/state.c | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index e113cdb..45969a5 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -104,6 +104,7 @@ struct state_key {
GLuint fog_mode:2; /**< FOG_x */
GLuint inputs_available:12;
GLuint num_draw_buffers:4;
+ GLuint alpha_test:1;
/* NOTE: This array of structs must be last! (see "keySize" below) */
struct {
@@ -489,6 +490,9 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
/* _NEW_BUFFERS */
key->num_draw_buffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+ /* _NEW_COLOR */
+ key->alpha_test = ctx->Color.AlphaEnabled;
+
key->inputs_available = (inputs_available & inputs_referenced);
/* compute size of state key, ignoring unused texture units */
@@ -1424,7 +1428,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
main_f->add_signature(main_sig);
p.instructions = &main_sig->body;
- if (key->num_draw_buffers)
+ if (key->num_draw_buffers || key->alpha_test)
emit_instructions(&p);
validate_ir_tree(p.shader->ir);
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index cf9fe89..7dd865e 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -574,7 +574,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_PROGRAM | _NEW_COLOR);
}
if (ctx->VertexProgram._MaintainTnlProgram) {
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
--
1.7.4.1
More information about the mesa-dev
mailing list