diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 64a4da36be2..610d3903b6d 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 032a4cd376c..19b5367536c 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