Module: Mesa
Branch: main
Commit: 7ba2784b0a4bbed36a75488d4b73a314aafaedf1
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ba2784b0a4bbed36a75488d4b73a314aafaedf1

Author: Rob Clark <[email protected]>
Date:   Thu Aug 18 10:59:50 2022 -0700

egl: Make RefCount atomic

Once we relax the locking, we will be doing _eglPutFoo() outside of the
big display lock.

Signed-off-by: Rob Clark <[email protected]>
Acked-by: Eric Engestrom <[email protected]>
Reviewed-by: Adam Jackson <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18050>

---

 src/egl/main/egldisplay.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index db90b2b2dc7..ddbcbf0061d 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -442,8 +442,7 @@ void
 _eglGetResource(_EGLResource *res)
 {
    assert(res && res->RefCount > 0);
-   /* hopefully a resource is always manipulated with its display locked */
-   res->RefCount++;
+   p_atomic_inc(&res->RefCount);
 }
 
 
@@ -454,8 +453,7 @@ EGLBoolean
 _eglPutResource(_EGLResource *res)
 {
    assert(res && res->RefCount > 0);
-   res->RefCount--;
-   return (!res->RefCount);
+   return p_atomic_dec_zero(&res->RefCount);
 }
 
 

Reply via email to