mesa: add some debug assertions to detect null current texture object pointers
authorBrian Paul <brianp@vmware.com>
Wed, 21 Jan 2009 15:18:07 +0000 (08:18 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 21 Jan 2009 15:18:07 +0000 (08:18 -0700)
See bug #17895.  These assertions could be removed when this is resolved.

src/mesa/main/texobj.c
src/mesa/main/texstate.c

index d8e8b559f53a604328898183fb1013d270186358..7848f0be354c88b9fd907e8ff1e39ebf9a4bfc3a 100644 (file)
@@ -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 */
index 29955d76cbe43a9c04f1b4408f5958e857a2143f..9bfb7e0ec2af4e1270d8d5ebeaa5bfed4e035039 100644 (file)
@@ -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.