glthread: mark internal bufferobjs for the ctx they belong to

this avoids unlimited unnecessary atomics

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36889>
This commit is contained in:
Mike Blumenkrantz
2025-08-20 11:45:06 -04:00
committed by Marge Bot
parent cbe42a4c43
commit 45b6aa1eb7
+9
View File
@@ -25,6 +25,8 @@
#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.
@@ -72,6 +74,11 @@ _mesa_glthread_release_upload_buffer(struct gl_context *ctx)
-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));
}
_mesa_reference_buffer_object(ctx, &glthread->upload_buffer, NULL);
}
@@ -142,6 +149,8 @@ _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. */