summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2005-05-23 09:50:34 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2005-05-23 09:50:34 +0000
commit241b6b7ab1a1a11c7fc516d1b6ff2c1bc8aba238 (patch)
tree112829beb72d9b18e92da2d8aa05d55ba8731106
parent2dea6df80b51ad8c5e2e88c2eb214b55889821c6 (diff)
Detect use of disabled textures as tex_env_crossbar sources.
-rw-r--r--src/mesa/main/texenvprogram.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 6676d3cfa9..b3fbb0a9ce 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -772,7 +772,7 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit )
}
}
-static void load_texenv_source( struct texenv_fragment_program *p,
+static GLboolean load_texenv_source( struct texenv_fragment_program *p,
GLenum src, GLuint unit )
{
switch (src) {
@@ -787,23 +787,29 @@ static void load_texenv_source( struct texenv_fragment_program *p,
case GL_TEXTURE4:
case GL_TEXTURE5:
case GL_TEXTURE6:
- case GL_TEXTURE7:
+ case GL_TEXTURE7:
+ if (!p->ctx->Texture.Unit[src - GL_TEXTURE0]._ReallyEnabled)
+ return GL_FALSE;
load_texture(p, src - GL_TEXTURE0);
break;
default:
break;
}
+
+ return GL_TRUE;
}
-static void load_texunit_sources( struct texenv_fragment_program *p, int unit )
+static GLboolean load_texunit_sources( struct texenv_fragment_program *p, int unit )
{
struct gl_texture_unit *texUnit = &p->ctx->Texture.Unit[unit];
int i, nr = nr_args(texUnit->_CurrentCombine->ModeRGB);
for (i = 0; i < nr; i++) {
- load_texenv_source( p, texUnit->_CurrentCombine->SourceRGB[i], unit);
- load_texenv_source( p, texUnit->_CurrentCombine->SourceA[i], unit );
+ if (!load_texenv_source( p, texUnit->_CurrentCombine->SourceRGB[i], unit) ||
+ !load_texenv_source( p, texUnit->_CurrentCombine->SourceA[i], unit ))
+ return GL_FALSE;
}
+ return GL_TRUE;
}
void _mesa_UpdateTexEnvProgram( GLcontext *ctx )
@@ -862,20 +868,24 @@ void _mesa_UpdateTexEnvProgram( GLcontext *ctx )
release_temps(&p);
if (ctx->Texture._EnabledUnits) {
+ GLuint tex_env_enabled = 0;
+
/* First pass - to support texture_env_crossbar, first identify
* all referenced texture sources and emit texld instructions
* for each:
*/
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- load_texunit_sources( &p, unit );
- p.last_tex_stage = unit;
+ if (load_texunit_sources( &p, unit )) {
+ tex_env_enabled |= 1<<unit;
+ p.last_tex_stage = unit;
+ }
}
/* Second pass - emit combine instructions to build final color:
*/
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ if (tex_env_enabled & (1<<unit)) {
p.src_previous = emit_texenv( &p, unit );
release_temps(&p); /* release all temps */
}