mesa: do not unbind general point when different indexed points are deleted

When a buffer is deleted, we have to remove it from all binding points.
We were re-using the code for BindBufferRange for this; however, this
caused the general binding point to be unbound (bound to NULL)
unconditionally, even if a different buffer is bound there. Fix this by
inlining the various bind calls into the delete buffers code.

cc: mesa-stable

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14755
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
(cherry picked from commit fa418f1e73)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39969>
This commit is contained in:
Eric R. Smith 2026-02-02 16:23:47 -04:00 committed by Dylan Baker
parent 8dde704494
commit 5e5448a023
2 changed files with 7 additions and 8 deletions

View file

@ -504,7 +504,7 @@
"description": "mesa: do not unbind general point when different indexed points are deleted",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -1823,16 +1823,15 @@ delete_buffers(struct gl_context *ctx, GLsizei n, const GLuint *ids)
}
for (j = 0; j < MAX_FEEDBACK_BUFFERS; j++) {
if (ctx->TransformFeedback.CurrentObject->Buffers[j] == bufObj) {
_mesa_bind_buffer_base_transform_feedback(ctx,
ctx->TransformFeedback.CurrentObject,
j, NULL, false);
_mesa_set_transform_feedback_binding(ctx, ctx->TransformFeedback.CurrentObject,
j, NULL, 0, 0);
}
}
/* unbind UBO binding points */
for (j = 0; j < ctx->Const.MaxUniformBufferBindings; j++) {
if (ctx->UniformBufferBindings[j].BufferObject == bufObj) {
bind_buffer_base_uniform_buffer(ctx, j, NULL);
bind_uniform_buffer(ctx, j, NULL, -1, -1, GL_TRUE);
}
}
@ -1843,7 +1842,7 @@ delete_buffers(struct gl_context *ctx, GLsizei n, const GLuint *ids)
/* unbind SSBO binding points */
for (j = 0; j < ctx->Const.MaxShaderStorageBufferBindings; j++) {
if (ctx->ShaderStorageBufferBindings[j].BufferObject == bufObj) {
bind_buffer_base_shader_storage_buffer(ctx, j, NULL);
bind_shader_storage_buffer(ctx, j, NULL, -1, -1, GL_TRUE);
}
}
@ -1851,10 +1850,10 @@ delete_buffers(struct gl_context *ctx, GLsizei n, const GLuint *ids)
bind_buffer_object(ctx, &ctx->ShaderStorageBuffer, 0, false);
}
/* unbind Atomci Buffer binding points */
/* unbind Atomic Buffer binding points */
for (j = 0; j < ctx->Const.MaxAtomicBufferBindings; j++) {
if (ctx->AtomicBufferBindings[j].BufferObject == bufObj) {
bind_buffer_base_atomic_buffer(ctx, j, NULL);
bind_atomic_buffer(ctx, j, NULL, -1, -1, GL_TRUE);
}
}