Mesa (master): mesa/main: use p_atomic_inc_return instead of locking

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 16 11:08:52 UTC 2020


Module: Mesa
Branch: master
Commit: 3af0711c402033a8ad7649dc0509e4f7ddc1b640
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3af0711c402033a8ad7649dc0509e4f7ddc1b640

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Fri Jul 10 13:12:40 2020 +0200

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 at collabora.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5901>

---

 src/mesa/main/debug_output.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/debug_output.c b/src/mesa/main/debug_output.c
index 6d4c8e72ee3..6527aea5771 100644
--- a/src/mesa/main/debug_output.c
+++ b/src/mesa/main/debug_output.c
@@ -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);
    }
 }
 



More information about the mesa-commit mailing list