From 93c9be2b975a3267096d1da19873549057989f05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 22 Aug 2022 01:31:41 -0400 Subject: [PATCH] mesa: inline _mesa_reference_buffer_object The last parameter is always a constant expression, so this simplifies it. This is also required by later commits. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/bufferobj.c | 45 --------------------------------------------- src/mesa/main/bufferobj.h | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 64a4da3..610d390 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1053,51 +1053,6 @@ _mesa_delete_buffer_object(struct gl_context *ctx, } - -/** - * Set ptr to bufObj w/ reference counting. - * This is normally only called from the _mesa_reference_buffer_object() macro - * when there's a real pointer change. - */ -void -_mesa_reference_buffer_object_(struct gl_context *ctx, - struct gl_buffer_object **ptr, - struct gl_buffer_object *bufObj, - bool shared_binding) -{ - if (*ptr) { - /* Unreference the old buffer */ - struct gl_buffer_object *oldObj = *ptr; - - assert(oldObj->RefCount >= 1); - - /* Count references only if the context doesn't own the buffer or if - * ptr is a binding point shared by multiple contexts (such as a texture - * buffer object being a buffer bound within a texture object). - */ - if (shared_binding || ctx != oldObj->Ctx) { - if (p_atomic_dec_zero(&oldObj->RefCount)) { - _mesa_delete_buffer_object(ctx, oldObj); - } - } else { - /* Update the private ref count. */ - assert(oldObj->CtxRefCount >= 1); - oldObj->CtxRefCount--; - } - } - - if (bufObj) { - /* reference new buffer */ - if (shared_binding || ctx != bufObj->Ctx) - p_atomic_inc(&bufObj->RefCount); - else - bufObj->CtxRefCount++; - } - - *ptr = bufObj; -} - - /** * Get the value of MESA_NO_MINMAX_CACHE. */ diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index 032a4cd..19b5367 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -166,11 +166,48 @@ extern void _mesa_delete_buffer_object(struct gl_context *ctx, struct gl_buffer_object *bufObj); -extern void +/** + * Set ptr to bufObj w/ reference counting. + * This is normally only called from the _mesa_reference_buffer_object() macro + * when there's a real pointer change. + */ +static inline void _mesa_reference_buffer_object_(struct gl_context *ctx, struct gl_buffer_object **ptr, struct gl_buffer_object *bufObj, - bool shared_binding); + bool shared_binding) +{ + if (*ptr) { + /* Unreference the old buffer */ + struct gl_buffer_object *oldObj = *ptr; + + assert(oldObj->RefCount >= 1); + + /* Count references only if the context doesn't own the buffer or if + * ptr is a binding point shared by multiple contexts (such as a texture + * buffer object being a buffer bound within a texture object). + */ + if (shared_binding || ctx != oldObj->Ctx) { + if (p_atomic_dec_zero(&oldObj->RefCount)) { + _mesa_delete_buffer_object(ctx, oldObj); + } + } else { + /* Update the private ref count. */ + assert(oldObj->CtxRefCount >= 1); + oldObj->CtxRefCount--; + } + } + + if (bufObj) { + /* reference new buffer */ + if (shared_binding || ctx != bufObj->Ctx) + p_atomic_inc(&bufObj->RefCount); + else + bufObj->CtxRefCount++; + } + + *ptr = bufObj; +} /** * Assign a buffer into a pointer with reference counting. The destination -- 2.7.4