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 <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18828>
This commit is contained in:
Marek Olšák
2022-08-22 01:31:41 -04:00
committed by Marge Bot
parent 1885608184
commit 93c9be2b97
2 changed files with 39 additions and 47 deletions
-45
View File
@@ -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.
*/
+39 -2
View File
@@ -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