From 00e203fe17cbf2127abc422c785cf9fad3232adb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 1 May 2009 09:30:32 -0600 Subject: mesa: create/use a fallback texture when bound texture is incomplete When a GLSL sampler reads from an incomplete texture it should return (0,0,0,1). Instead of jumping through hoops in all the drivers to make this happen, just create/install a fallback texture with those texel values. Fixes piglit/fp-incomplete-tex on i965 and more importantly, fixes some GPU lockups when trying to sample from missing surfaces. If a binding table entry is NULL, it seems that sampling sometimes works, but not always (lockup). Todo: create a fallback texture for each type of texture target? (cherry picked from commit 3f25219c7bf0f090502489928f0f018e62c4f6cf) --- src/mesa/main/texstate.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/texstate.c') diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index cef58d7a49..89da4335a2 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -561,8 +561,13 @@ update_texture_state( GLcontext *ctx ) } if (!texUnit->_ReallyEnabled) { - _mesa_reference_texobj(&texUnit->_Current, NULL); - continue; + /* If we get here it means the shader (or fixed-function state) + * is expecting a texture object, but there isn't one (or it's + * incomplete). Use the fallback texture. + */ + struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx); + texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX; + _mesa_reference_texobj(&texUnit->_Current, texObj); } /* if we get here, we know this texture unit is enabled */ -- cgit v1.2.3