summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-03-04 14:46:00 +0000
committerBrian Paul <[email protected]>2004-03-04 14:46:00 +0000
commit94ec525ba5bc763210b1fb0198beeee2fe601b99 (patch)
tree4d89995eac45446e2e5a1ce9493c696950f0b2f7
parent3f94cef027041f57029de4cc165e0bad1e6634fa (diff)
yet another take on VBO deleting and reference counting
-rw-r--r--src/mesa/main/bufferobj.c54
-rw-r--r--src/mesa/main/mtypes.h1
2 files changed, 54 insertions, 1 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0e417a26154..882f24526c7 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -452,8 +452,60 @@ _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 == ids[i]);
+
+ if (ctx->Array.Vertex.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
+ }
+ if (ctx->Array.Normal.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
+ }
+ if (ctx->Array.Color.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
+ }
+ if (ctx->Array.SecondaryColor.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
+ }
+ if (ctx->Array.FogCoord.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
+ }
+ if (ctx->Array.Index.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
+ }
+ if (ctx->Array.EdgeFlag.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
+ }
+ 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;
+ }
+ }
+ 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;
+ }
+ }
+
+ 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 );
+ }
+
/* decrement refcount and delete if <= 0 */
+ bufObj->DeletePending = GL_TRUE;
bufObj->RefCount--;
if (bufObj->RefCount <= 0) {
/* buffer should not be bound anymore! */
@@ -541,7 +593,7 @@ _mesa_IsBufferARB(GLuint id)
bufObj = (struct gl_buffer_object *) _mesa_HashLookup(ctx->Shared->BufferObjects, id);
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
- return (bufObj != NULL);
+ return bufObj && !bufObj->DeletePending;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index e090a3d6834..3ef508b3f83 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1329,6 +1329,7 @@ struct gl_buffer_object {
GLvoid *Pointer; /**< Only valid while buffer is mapped */
GLuint Size; /**< Size of data array in bytes */
GLubyte *Data; /**< The storage */
+ GLboolean DeletePending; /**< Deleted by user? */
};