VBO RefCount fix (David Reveman)
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 27 Sep 2004 16:19:17 +0000 (16:19 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 27 Sep 2004 16:19:17 +0000 (16:19 +0000)
src/mesa/main/bufferobj.c
src/mesa/main/varray.c

index 84af8158ad23941291cee49f22a8b21f314c3b00..0d0e5f4bcfdab48b752730a8d1fe0af706b0cfde 100644 (file)
@@ -539,41 +539,50 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
             if (ctx->Array.Vertex.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             if (ctx->Array.Normal.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             if (ctx->Array.Color.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             if (ctx->Array.SecondaryColor.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             if (ctx->Array.FogCoord.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             if (ctx->Array.Index.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             if (ctx->Array.EdgeFlag.BufferObj == bufObj) {
                bufObj->RefCount--;
                ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
+               ctx->Array.NullBufferObj->RefCount++;
             }
             for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
                if (ctx->Array.TexCoord[j].BufferObj == bufObj) {
                   bufObj->RefCount--;
                   ctx->Array.TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
+                  ctx->Array.NullBufferObj->RefCount++;
                }
             }
             for (j = 0; j < VERT_ATTRIB_MAX; j++) {
                if (ctx->Array.VertexAttrib[j].BufferObj == bufObj) {
                   bufObj->RefCount--;
                   ctx->Array.VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
+                  ctx->Array.NullBufferObj->RefCount++;
                }
             }
 
index 04d0a07e286e19ebbf25dcf6314a1a3980008a33..404302873b375a8964a5b9d483023a09bf1b463e 100644 (file)
@@ -60,6 +60,7 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
 #if FEATURE_ARB_vertex_buffer_object
    array->BufferObj->RefCount--;
    if (array->BufferObj->RefCount <= 0) {
+      ASSERT(array->BufferObj->Name);
       _mesa_remove_buffer_object( ctx, array->BufferObj );
       (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj );
    }