From 4683cab29a74d6b3cefdd915aaf91e6b4f667d27 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 21 Jan 2009 08:18:07 -0700 Subject: mesa: add some debug assertions to detect null current texture object pointers See bug #17895. These assertions could be removed when this is resolved. --- src/mesa/main/texobj.c | 14 ++++++++++++++ src/mesa/main/texstate.c | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index d8e8b559f5..7848f0be35 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -762,24 +762,31 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; if (texObj == unit->Current1D) { _mesa_reference_texobj(&unit->Current1D, ctx->Shared->Default1D); + ASSERT(unit->Current1D); } else if (texObj == unit->Current2D) { _mesa_reference_texobj(&unit->Current2D, ctx->Shared->Default2D); + ASSERT(unit->Current2D); } else if (texObj == unit->Current3D) { _mesa_reference_texobj(&unit->Current3D, ctx->Shared->Default3D); + ASSERT(unit->Current3D); } else if (texObj == unit->CurrentCubeMap) { _mesa_reference_texobj(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); + ASSERT(unit->CurrentCubeMap); } else if (texObj == unit->CurrentRect) { _mesa_reference_texobj(&unit->CurrentRect, ctx->Shared->DefaultRect); + ASSERT(unit->CurrentRect); } else if (texObj == unit->Current1DArray) { _mesa_reference_texobj(&unit->Current1DArray, ctx->Shared->Default1DArray); + ASSERT(unit->Current1DArray); } else if (texObj == unit->Current2DArray) { _mesa_reference_texobj(&unit->Current2DArray, ctx->Shared->Default2DArray); + ASSERT(unit->Current2DArray); } } } @@ -953,24 +960,31 @@ _mesa_BindTexture( GLenum target, GLuint texName ) switch (target) { case GL_TEXTURE_1D: _mesa_reference_texobj(&texUnit->Current1D, newTexObj); + ASSERT(texUnit->Current1D); break; case GL_TEXTURE_2D: _mesa_reference_texobj(&texUnit->Current2D, newTexObj); + ASSERT(texUnit->Current2D); break; case GL_TEXTURE_3D: _mesa_reference_texobj(&texUnit->Current3D, newTexObj); + ASSERT(texUnit->Current3D); break; case GL_TEXTURE_CUBE_MAP_ARB: _mesa_reference_texobj(&texUnit->CurrentCubeMap, newTexObj); + ASSERT(texUnit->CurrentCubeMap); break; case GL_TEXTURE_RECTANGLE_NV: _mesa_reference_texobj(&texUnit->CurrentRect, newTexObj); + ASSERT(texUnit->CurrentRect); break; case GL_TEXTURE_1D_ARRAY_EXT: texUnit->Current1DArray = newTexObj; + ASSERT(texUnit->Current1DArray); break; case GL_TEXTURE_2D_ARRAY_EXT: texUnit->Current2DArray = newTexObj; + ASSERT(texUnit->Current2DArray); break; default: /* Bad target should be caught above */ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 29955d76cb..9bfb7e0ec2 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -517,6 +517,14 @@ update_texture_state( GLcontext *ctx ) enableBits = texUnit->Enabled; } + ASSERT(texUnit->Current1D); + ASSERT(texUnit->Current2D); + ASSERT(texUnit->Current3D); + ASSERT(texUnit->CurrentCubeMap); + ASSERT(texUnit->CurrentRect); + ASSERT(texUnit->Current1DArray); + ASSERT(texUnit->Current2DArray); + /* Look for the highest-priority texture target that's enabled and * complete. That's the one we'll use for texturing. If we're using * a fragment program we're guaranteed that bitcount(enabledBits) <= 1. -- cgit v1.2.3