mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
mesa/main: use p_atomic_inc_return instead of locking
There's no good reason for using a mutex here, as we have a simpler primitive; atomic integers. So let's use that instead, to simplify things a bit. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5901>
This commit is contained in:
parent
a0f8439691
commit
3af0711c40
1 changed files with 2 additions and 6 deletions
|
|
@ -37,8 +37,7 @@
|
|||
#include "util/u_memory.h"
|
||||
|
||||
|
||||
static simple_mtx_t DynamicIDMutex = _SIMPLE_MTX_INITIALIZER_NP;
|
||||
static GLuint NextDynamicID = 1;
|
||||
static GLuint PrevDynamicID = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -194,10 +193,7 @@ void
|
|||
_mesa_debug_get_id(GLuint *id)
|
||||
{
|
||||
if (!(*id)) {
|
||||
simple_mtx_lock(&DynamicIDMutex);
|
||||
if (!(*id))
|
||||
*id = NextDynamicID++;
|
||||
simple_mtx_unlock(&DynamicIDMutex);
|
||||
*id = p_atomic_inc_return(&PrevDynamicID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue