From 0fbc4c51a07a5980956d62b3f70c46c65f6c7a57 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 11 Jun 2007 17:16:18 -0600 Subject: Rework _mesa_update_texture_compare_function() to only be called during state validation/update. Note that we're still temporarily skipping the test for an active fragment program. Need to fix shadow2D() ... --- src/mesa/main/texstate.c | 82 +++++++++++++++++++++++--------------------- src/mesa/main/texstate.h | 7 ++-- src/mesa/swrast/s_fragprog.c | 20 ----------- 3 files changed, 44 insertions(+), 65 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index ed82f8028d..c9f8a0656e 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1181,39 +1181,6 @@ _mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param ) } -/** - * Update derived compare function state. - */ -void -_mesa_update_texture_compare_function(struct gl_texture_object *tObj, - GLboolean in_frag_prog) -{ - if (in_frag_prog) { - /* Texel/coordinate comparison is ignored for programs. - * See GL_ARB_fragment_program/shader spec for details. - */ - tObj->_Function = GL_NONE; - } - else if (tObj->CompareFlag) { - /* GL_SGIX_shadow */ - if (tObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) { - tObj->_Function = GL_LEQUAL; - } - else { - ASSERT(tObj->CompareOperator == GL_TEXTURE_GEQUAL_R_SGIX); - tObj->_Function = GL_GEQUAL; - } - } - else if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) { - /* GL_ARB_shadow */ - tObj->_Function = tObj->CompareFunc; - } - else { - tObj->_Function = GL_NONE; /* pass depth through as grayscale */ - } -} - - void GLAPIENTRY _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) { @@ -1421,7 +1388,6 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) if (ctx->Extensions.SGIX_shadow) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); texObj->CompareFlag = params[0] ? GL_TRUE : GL_FALSE; - _mesa_update_texture_compare_function(texObj, GL_FALSE); } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -1436,7 +1402,6 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) op == GL_TEXTURE_GEQUAL_R_SGIX) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); texObj->CompareOperator = op; - _mesa_update_texture_compare_function(texObj, GL_FALSE); } else { _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)"); @@ -1475,7 +1440,6 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) if (mode == GL_NONE || mode == GL_COMPARE_R_TO_TEXTURE_ARB) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); texObj->CompareMode = mode; - _mesa_update_texture_compare_function(texObj, GL_FALSE); } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -1511,8 +1475,6 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)"); return; } - - _mesa_update_texture_compare_function(texObj, GL_FALSE); } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -1533,8 +1495,6 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)"); return; } - - _mesa_update_texture_compare_function(texObj, GL_FALSE); } else { _mesa_error(ctx, GL_INVALID_ENUM, @@ -2835,6 +2795,47 @@ update_texture_matrices( GLcontext *ctx ) } +/** + * Update texture object's _Function field. We need to do this + * whenever any of the texture object's shadow-related fields change + * or when we start/stop using a fragment program. + * + * This function could be expanded someday to update additional per-object + * fields that depend on assorted state changes. + */ +static void +update_texture_compare_function(GLcontext *ctx, + struct gl_texture_object *tObj) +{ + /* XXX temporarily disable this test since it breaks the GLSL + * shadow2D(), etc. functions. + */ + if (0 /*ctx->FragmentProgram._Current*/) { + /* Texel/coordinate comparison is ignored for programs. + * See GL_ARB_fragment_program/shader spec for details. + */ + tObj->_Function = GL_NONE; + } + else if (tObj->CompareFlag) { + /* GL_SGIX_shadow */ + if (tObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) { + tObj->_Function = GL_LEQUAL; + } + else { + ASSERT(tObj->CompareOperator == GL_TEXTURE_GEQUAL_R_SGIX); + tObj->_Function = GL_GEQUAL; + } + } + else if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) { + /* GL_ARB_shadow */ + tObj->_Function = tObj->CompareFunc; + } + else { + tObj->_Function = GL_NONE; /* pass depth through as grayscale */ + } +} + + /** * Helper function for determining which texture object (1D, 2D, cube, etc) * should actually be used. @@ -2851,6 +2852,7 @@ texture_override(GLcontext *ctx, if (texObj->_Complete) { texUnit->_ReallyEnabled = textureBit; texUnit->_Current = texObj; + update_texture_compare_function(ctx, texObj); } } } diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h index df468ecf9b..60145691b8 100644 --- a/src/mesa/main/texstate.h +++ b/src/mesa/main/texstate.h @@ -5,9 +5,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -41,9 +41,6 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ); extern void _mesa_print_texunit_state( GLcontext *ctx, GLuint unit ); -extern void -_mesa_update_texture_compare_function(struct gl_texture_object *tObj, - GLboolean in_frag_prog); /** diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 1cbcde3c0a..923b67e78e 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -200,7 +200,6 @@ void _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span ) { const struct gl_fragment_program *program = ctx->FragmentProgram._Current; - GLuint i; /* incoming colors should be floats */ if (program->Base.InputsRead & FRAG_BIT_COL0) { @@ -209,27 +208,8 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span ) ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */ -#if 0 - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._Current != NULL) { - const GLboolean enable_shadow = ((1 << i) & program->Base.ShadowSamplers); - _mesa_update_texture_compare_function(ctx->Texture.Unit[i]._Current, - !enable_shadow); - } - } -#endif - run_program(ctx, span, 0, span->end); -#if 0 - for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { - if (ctx->Texture.Unit[i]._Current != NULL) { - _mesa_update_texture_compare_function(ctx->Texture.Unit[i]._Current, - GL_FALSE); - } - } -#endif - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_COLR)) { span->interpMask &= ~SPAN_RGBA; span->arrayMask |= SPAN_RGBA; -- cgit v1.2.3