Revert "glthread: mark internal bufferobjs for the ctx they belong to"

This reverts commit 45b6aa1eb7.

This is not thread safe and will lead to buffer leaks, eg:

[threadA] _mesa_reference_buffer_object_       ctx=0x60bc07fa33f0 buf=0x60bc09b90020 CtxRefCount-=993187
[threadB] _mesa_glthread_release_upload_buffer ctx=0x60bc07fa33f0 buf=0x60bc09b90020 ref=7768 CtxRefCount=993212 -> 954
[threadB] _mesa_glthread_upload                ctx=0x60bc07fa33f0 buf=0x60bc09eb7d00 CtxRefCount=1000000
[threadA] _mesa_reference_buffer_object_       ctx=0x60bc07fa33f0 buf=0x60bc09b90020 CtxRefCount-=993186
 ../src/mesa/main/bufferobj.h:201: _mesa_reference_buffer_object_: Assertion `oldObj->Ctx == ctx' failed.

The assert is one added by the previous commit.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14483
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
(cherry picked from commit 68ef044b3b)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39462>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-12-19 11:47:44 +01:00 committed by Dylan Baker
parent a058d3b074
commit 302ebe2082
2 changed files with 1 additions and 10 deletions

View file

@ -5734,7 +5734,7 @@
"description": "Revert \"glthread: mark internal bufferobjs for the ctx they belong to\"",
"nominated": true,
"nomination_type": 3,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "45b6aa1eb7ce0b3845567be7ee4349ab55f30043",
"notes": null

View file

@ -25,8 +25,6 @@
#include "dispatch.h"
#include "main/bufferobj.h"
#define PRIVATE_REFCOUNT 1000000
/**
* Create an upload buffer. This is called from the app thread, so everything
* has to be thread-safe in the driver.
@ -81,11 +79,6 @@ _mesa_glthread_release_upload_buffer(struct gl_context *ctx, bool async_release)
-glthread->upload_buffer_private_refcount);
glthread->upload_buffer_private_refcount = 0;
}
if (glthread->upload_buffer) {
glthread->upload_buffer->Ctx = NULL;
p_atomic_add(&glthread->upload_buffer->RefCount,
-(PRIVATE_REFCOUNT - glthread->upload_buffer->CtxRefCount));
}
if (async_release) {
/* Defer to avoid calling tc_resource_release from this thread. */
@ -163,8 +156,6 @@ _mesa_glthread_upload(struct gl_context *ctx, const void *data,
*/
glthread->upload_buffer->RefCount += default_size;
glthread->upload_buffer_private_refcount = default_size;
glthread->upload_buffer->Ctx = ctx;
glthread->upload_buffer->CtxRefCount = PRIVATE_REFCOUNT;
}
/* Upload data. */