mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
mesa: unreference zombie buffers when creating buffers to lower memory usage
This fixes an issue where one context only creates buffers while another context only destroys buffers. Only the creating context can release its buffers and the destroying context only turns them into zombie buffers. This fix makes the creating context release its zombie buffers. It's not a plot from an apocalyptic movie. Fixes:e014e3b6be"mesa: don't count buffer references for the context that created them" Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4840 Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11514> (cherry picked from commitec7e262349)
This commit is contained in:
parent
31aa33c182
commit
7a2e0b2a87
2 changed files with 20 additions and 3 deletions
|
|
@ -1408,7 +1408,7 @@
|
|||
"description": "mesa: unreference zombie buffers when creating buffers to lower memory usage",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "e014e3b6be638f4192d6eddd3d1033fd571f3a76"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue