diff options
-rw-r--r-- | src/mesa/main/bufferobj.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 18fa67d2d74..486aac31a8a 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1084,8 +1084,18 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx, _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller); return false; } - _mesa_HashInsertMaybeLocked(ctx->Shared->BufferObjects, buffer, - *buf_handle, buf != NULL, + _mesa_HashLockMaybeLocked(ctx->Shared->BufferObjects, + ctx->BufferObjectsLocked); + _mesa_HashInsertLocked(ctx->Shared->BufferObjects, buffer, + *buf_handle, buf != NULL); + /* If one context only creates buffers and another context only deletes + * buffers, buffers don't get released because it only produces zombie + * buffers. Only the context that has created the buffers can release + * them. Thus, when we create buffers, we prune the list of zombie + * buffers. + */ + unreference_zombie_buffers_for_ctx(ctx); + _mesa_HashUnlockMaybeLocked(ctx->Shared->BufferObjects, ctx->BufferObjectsLocked); } @@ -1763,6 +1773,13 @@ create_buffers(struct gl_context *ctx, GLsizei n, GLuint *buffers, bool dsa) */ _mesa_HashLockMaybeLocked(ctx->Shared->BufferObjects, ctx->BufferObjectsLocked); + /* If one context only creates buffers and another context only deletes + * buffers, buffers don't get released because it only produces zombie + * buffers. Only the context that has created the buffers can release + * them. Thus, when we create buffers, we prune the list of zombie + * buffers. + */ + unreference_zombie_buffers_for_ctx(ctx); _mesa_HashFindFreeKeys(ctx->Shared->BufferObjects, buffers, n); |