Update glDeletePrograms/Buffers() so that the ID is freed immediately, like
texture objects.
This commit is contained in:
@@ -533,9 +533,8 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer)
|
|||||||
assert(oldBufObj->RefCount >= 0);
|
assert(oldBufObj->RefCount >= 0);
|
||||||
if (oldBufObj->RefCount == 0) {
|
if (oldBufObj->RefCount == 0) {
|
||||||
assert(oldBufObj->Name != 0);
|
assert(oldBufObj->Name != 0);
|
||||||
_mesa_remove_buffer_object(ctx, oldBufObj);
|
|
||||||
ASSERT(ctx->Driver.DeleteBuffer);
|
ASSERT(ctx->Driver.DeleteBuffer);
|
||||||
(*ctx->Driver.DeleteBuffer)( ctx, oldBufObj );
|
ctx->Driver.DeleteBuffer( ctx, oldBufObj );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -635,20 +634,15 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
|
|||||||
_mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
|
_mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* decrement refcount and delete if <= 0 */
|
/* The ID is immediately freed for re-use */
|
||||||
if (!bufObj->DeletePending) {
|
_mesa_remove_buffer_object(ctx, bufObj);
|
||||||
bufObj->DeletePending = GL_TRUE;
|
bufObj->RefCount--;
|
||||||
bufObj->RefCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bufObj->RefCount <= 0) {
|
if (bufObj->RefCount <= 0) {
|
||||||
/* buffer should not be bound anymore! */
|
|
||||||
ASSERT(ctx->Array.ArrayBufferObj != bufObj);
|
ASSERT(ctx->Array.ArrayBufferObj != bufObj);
|
||||||
ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
|
ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
|
||||||
ASSERT(ctx->Array.Vertex.BufferObj != bufObj);
|
ASSERT(ctx->Array.Vertex.BufferObj != bufObj);
|
||||||
_mesa_remove_buffer_object(ctx, bufObj);
|
|
||||||
ASSERT(ctx->Driver.DeleteBuffer);
|
ASSERT(ctx->Driver.DeleteBuffer);
|
||||||
(*ctx->Driver.DeleteBuffer)(ctx, bufObj);
|
ctx->Driver.DeleteBuffer(ctx, bufObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -727,7 +721,7 @@ _mesa_IsBufferARB(GLuint id)
|
|||||||
bufObj = (struct gl_buffer_object *) _mesa_HashLookup(ctx->Shared->BufferObjects, id);
|
bufObj = (struct gl_buffer_object *) _mesa_HashLookup(ctx->Shared->BufferObjects, id);
|
||||||
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
|
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
|
||||||
|
|
||||||
return bufObj && !bufObj->DeletePending;
|
return bufObj ? GL_TRUE : GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1475,7 +1475,6 @@ struct gl_buffer_object
|
|||||||
GLuint Size; /**< Size of storage in bytes */
|
GLuint Size; /**< Size of storage in bytes */
|
||||||
GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
|
GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
|
||||||
GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
|
GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
|
||||||
GLboolean DeletePending; /**< Deleted by user but RefCount > 0? */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1706,7 +1705,6 @@ struct program
|
|||||||
{
|
{
|
||||||
GLuint Id;
|
GLuint Id;
|
||||||
GLubyte *String; /**< Null-terminated program text */
|
GLubyte *String; /**< Null-terminated program text */
|
||||||
GLboolean DeletePending; /**< User called glDeletePrograms? */
|
|
||||||
GLint RefCount;
|
GLint RefCount;
|
||||||
GLenum Target;
|
GLenum Target;
|
||||||
GLenum Format; /**< String encoding format */
|
GLenum Format; /**< String encoding format */
|
||||||
|
@@ -185,6 +185,7 @@ _mesa_DeleteFragmentShaderATI(GLuint id)
|
|||||||
_mesa_BindFragmentShaderATI(0);
|
_mesa_BindFragmentShaderATI(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if (!prog->DeletePending) {
|
if (!prog->DeletePending) {
|
||||||
prog->DeletePending = GL_TRUE;
|
prog->DeletePending = GL_TRUE;
|
||||||
prog->RefCount--;
|
prog->RefCount--;
|
||||||
@@ -193,6 +194,14 @@ _mesa_DeleteFragmentShaderATI(GLuint id)
|
|||||||
_mesa_HashRemove(ctx->Shared->Programs, id);
|
_mesa_HashRemove(ctx->Shared->Programs, id);
|
||||||
ctx->Driver.DeleteProgram(ctx, prog);
|
ctx->Driver.DeleteProgram(ctx, prog);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* The ID is immediately available for re-use now */
|
||||||
|
_mesa_HashRemove(ctx->Shared->Programs, id);
|
||||||
|
prog->RefCount--;
|
||||||
|
if (prog->RefCount <= 0) {
|
||||||
|
ctx->Driver.DeleteProgram(ctx, prog);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -940,9 +940,8 @@ _mesa_BindProgram(GLenum target, GLuint id)
|
|||||||
curProg->Base.RefCount--;
|
curProg->Base.RefCount--;
|
||||||
/* and delete if refcount goes below one */
|
/* and delete if refcount goes below one */
|
||||||
if (curProg->Base.RefCount <= 0) {
|
if (curProg->Base.RefCount <= 0) {
|
||||||
ASSERT(curProg->Base.DeletePending);
|
/* the program ID was already removed from the hash table */
|
||||||
ctx->Driver.DeleteProgram(ctx, &(curProg->Base));
|
ctx->Driver.DeleteProgram(ctx, &(curProg->Base));
|
||||||
_mesa_HashRemove(ctx->Shared->Programs, id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -961,9 +960,8 @@ _mesa_BindProgram(GLenum target, GLuint id)
|
|||||||
curProg->Base.RefCount--;
|
curProg->Base.RefCount--;
|
||||||
/* and delete if refcount goes below one */
|
/* and delete if refcount goes below one */
|
||||||
if (curProg->Base.RefCount <= 0) {
|
if (curProg->Base.RefCount <= 0) {
|
||||||
ASSERT(curProg->Base.DeletePending);
|
/* the program ID was already removed from the hash table */
|
||||||
ctx->Driver.DeleteProgram(ctx, &(curProg->Base));
|
ctx->Driver.DeleteProgram(ctx, &(curProg->Base));
|
||||||
_mesa_HashRemove(ctx->Shared->Programs, id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1068,13 +1066,10 @@ _mesa_DeletePrograms(GLsizei n, const GLuint *ids)
|
|||||||
_mesa_problem(ctx, "bad target in glDeleteProgramsNV");
|
_mesa_problem(ctx, "bad target in glDeleteProgramsNV");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Decrement reference count if not already marked for delete */
|
/* The ID is immediately available for re-use now */
|
||||||
if (!prog->DeletePending) {
|
_mesa_HashRemove(ctx->Shared->Programs, ids[i]);
|
||||||
prog->DeletePending = GL_TRUE;
|
prog->RefCount--;
|
||||||
prog->RefCount--;
|
|
||||||
}
|
|
||||||
if (prog->RefCount <= 0) {
|
if (prog->RefCount <= 0) {
|
||||||
_mesa_HashRemove(ctx->Shared->Programs, ids[i]);
|
|
||||||
ctx->Driver.DeleteProgram(ctx, prog);
|
ctx->Driver.DeleteProgram(ctx, prog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user