diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2004-03-03 15:35:08 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2004-03-03 15:35:08 +0000 |
commit | 26895aa797060a38b42dfad21301f4b34b7de0d2 (patch) | |
tree | 510426993946a13d62484701145e894151a7275e /src/mesa/main | |
parent | 5ee631c6ee0a7f60a310471df74d9bd24f40a261 (diff) |
more changes to VBO reference counting and deletion
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/bufferobj.c | 43 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 2 |
2 files changed, 9 insertions, 36 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 8b6ede65d5..0e417a2615 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -145,7 +145,7 @@ _mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target ) * Delete a buffer object. * * This function is intended to be called via - * \c dd_function_table::DeleteBufferObject. + * \c dd_function_table::DeleteBuffer. */ void _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj ) @@ -452,43 +452,14 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) _mesa_HashLookup(ctx->Shared->BufferObjects, ids[i]); if (bufObj) { /* unbind any vertex pointers bound to this buffer */ - GLuint j; - - ASSERT(bufObj->Name != 0); - - if (ctx->Array.Vertex.BufferObj == bufObj) - ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj; - if (ctx->Array.Normal.BufferObj == bufObj) - ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj; - if (ctx->Array.Color.BufferObj == bufObj) - ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj; - if (ctx->Array.SecondaryColor.BufferObj == bufObj) - ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj; - if (ctx->Array.FogCoord.BufferObj == bufObj) - ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj; - if (ctx->Array.Index.BufferObj == bufObj) - ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj; - if (ctx->Array.EdgeFlag.BufferObj == bufObj) - ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj; - for (j = 0; j < MAX_TEXTURE_UNITS; j++) { - if (ctx->Array.TexCoord[j].BufferObj == bufObj) - ctx->Array.TexCoord[j].BufferObj = ctx->Array.NullBufferObj; - } - for (j = 0; j < VERT_ATTRIB_MAX; j++) { - if (ctx->Array.VertexAttrib[j].BufferObj == bufObj) - ctx->Array.VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj; - } - - /* if deleting bound buffers, rebind to zero */ - if (ctx->Array.ArrayBufferObj == bufObj) { - _mesa_BindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); - } - if (ctx->Array.ElementArrayBufferObj == bufObj) { - _mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); - } - + ASSERT(bufObj->Name == ids[i]); + /* decrement refcount and delete if <= 0 */ bufObj->RefCount--; if (bufObj->RefCount <= 0) { + /* buffer should not be bound anymore! */ + ASSERT(ctx->Array.ArrayBufferObj != bufObj); + ASSERT(ctx->Array.ElementArrayBufferObj != bufObj); + ASSERT(ctx->Array.Vertex.BufferObj != bufObj); _mesa_remove_buffer_object(ctx, bufObj); ASSERT(ctx->Driver.DeleteBuffer); (*ctx->Driver.DeleteBuffer)(ctx, bufObj); diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index c0b7bcfabe..52f8c8cef9 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -25,6 +25,7 @@ #include "glheader.h" #include "imports.h" +#include "bufferobj.h" #include "context.h" #include "enable.h" #include "enums.h" @@ -59,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) { + _mesa_remove_buffer_object( ctx, array->BufferObj ); (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj ); } array->BufferObj = ctx->Array.ArrayBufferObj; |