summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-06-11 17:16:18 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-06-11 17:16:18 -0600
commit0fbc4c51a07a5980956d62b3f70c46c65f6c7a57 (patch)
tree39ff25e61e45ce71e7b33a93e9226268c90f20de /src/mesa/main
parent495e2c8327ad4b5b7e01971bb3dacf4fd812aedf (diff)
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() ...
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/texstate.c82
-rw-r--r--src/mesa/main/texstate.h7
2 files changed, 44 insertions, 45 deletions
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,
@@ -2836,6 +2796,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);
/**