Merge branch 'fix_glthread_bufleak' into 'main'

mesa, glthread: fix upload_buffer leak, ac: fix dev_filename printing

Closes #14483

See merge request mesa/mesa!39036
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-12-20 01:45:07 +00:00
commit 64ff74e4f5
3 changed files with 8 additions and 13 deletions

View file

@ -1679,8 +1679,9 @@ void ac_print_gpu_info(FILE *f, const struct radeon_info *info, int fd)
char proc_fd[32]; char proc_fd[32];
char dev_filename[32]; char dev_filename[32];
snprintf(proc_fd, sizeof(proc_fd), "/proc/self/fd/%u", fd); snprintf(proc_fd, sizeof(proc_fd), "/proc/self/fd/%u", fd);
if (readlink(proc_fd, dev_filename, sizeof(dev_filename)) != -1) int n = readlink(proc_fd, dev_filename, sizeof(dev_filename));
fprintf(f, " dev_filename = %s\n", dev_filename); if (n != -1)
fprintf(f, " dev_filename = %.*s\n", n, dev_filename);
fprintf(f, " num_se = %i\n", info->num_se); fprintf(f, " num_se = %i\n", info->num_se);
fprintf(f, " num_rb = %i\n", info->num_rb); fprintf(f, " num_rb = %i\n", info->num_rb);

View file

@ -161,15 +161,18 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
/* Update the private ref count. */ /* Update the private ref count. */
assert(oldObj->CtxRefCount >= 1); assert(oldObj->CtxRefCount >= 1);
oldObj->CtxRefCount--; oldObj->CtxRefCount--;
assert(oldObj->Ctx == ctx);
} }
} }
if (bufObj) { if (bufObj) {
/* reference new buffer */ /* reference new buffer */
if (shared_binding || ctx != bufObj->Ctx) if (shared_binding || ctx != bufObj->Ctx) {
p_atomic_inc(&bufObj->RefCount); p_atomic_inc(&bufObj->RefCount);
else } else {
bufObj->CtxRefCount++; bufObj->CtxRefCount++;
assert(bufObj->Ctx == ctx);
}
} }
*ptr = bufObj; *ptr = bufObj;

View file

@ -25,8 +25,6 @@
#include "dispatch.h" #include "dispatch.h"
#include "main/bufferobj.h" #include "main/bufferobj.h"
#define PRIVATE_REFCOUNT 1000000
/** /**
* Create an upload buffer. This is called from the app thread, so everything * Create an upload buffer. This is called from the app thread, so everything
* has to be thread-safe in the driver. * 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);
glthread->upload_buffer_private_refcount = 0; 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) { if (async_release) {
/* Defer to avoid calling tc_resource_release from this thread. */ /* 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->RefCount += default_size;
glthread->upload_buffer_private_refcount = default_size; glthread->upload_buffer_private_refcount = default_size;
glthread->upload_buffer->Ctx = ctx;
glthread->upload_buffer->CtxRefCount = PRIVATE_REFCOUNT;
} }
/* Upload data. */ /* Upload data. */