[Bf-blender-cvs] [498ffef7b05] master: Subsurf: Use regular mutex instead of RW one
Sergey Sharybin
noreply at git.blender.org
Thu Jan 11 14:43:59 CET 2018
Commit: 498ffef7b054c08a1d05271aeb4fde5eeeebf450
Author: Sergey Sharybin
Date: Thu Jan 11 14:32:56 2018 +0100
Branches: master
https://developer.blender.org/rB498ffef7b054c08a1d05271aeb4fde5eeeebf450
Subsurf: Use regular mutex instead of RW one
Mutex is now local to particular CCGDM, and guarding edge hash which is only
used by a single function only. There is no need to acquire read lock after
edge hash was created.
===================================================================
M source/blender/blenkernel/BKE_subsurf.h
M source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h
index d7b9d20d7b0..96320415b16 100644
--- a/source/blender/blenkernel/BKE_subsurf.h
+++ b/source/blender/blenkernel/BKE_subsurf.h
@@ -144,7 +144,7 @@ typedef struct CCGDerivedMesh {
struct EdgeHash *ehash;
- ThreadRWMutex loops_cache_rwlock;
+ ThreadMutex loops_cache_lock;
ThreadRWMutex origindex_cache_rwlock;
} CCGDerivedMesh;
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index d2f325fb3c4..c6b701d2d28 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1488,7 +1488,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
/* DMFlagMat *faceFlags = ccgdm->faceFlags; */ /* UNUSED */
if (!ccgdm->ehash) {
- BLI_rw_mutex_lock(&ccgdm->loops_cache_rwlock, THREAD_LOCK_WRITE);
+ BLI_mutex_lock(&ccgdm->loops_cache_lock);
if (!ccgdm->ehash) {
MEdge *medge;
EdgeHash *ehash;
@@ -1502,10 +1502,9 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
atomic_cas_ptr((void**)&ccgdm->ehash, ccgdm->ehash, ehash);
}
- BLI_rw_mutex_unlock(&ccgdm->loops_cache_rwlock);
+ BLI_mutex_unlock(&ccgdm->loops_cache_lock);
}
- BLI_rw_mutex_lock(&ccgdm->loops_cache_rwlock, THREAD_LOCK_READ);
totface = ccgSubSurf_getNumFaces(ss);
ml = mloop;
for (index = 0; index < totface; index++) {
@@ -1548,7 +1547,6 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
}
}
}
- BLI_rw_mutex_unlock(&ccgdm->loops_cache_rwlock);
}
static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
@@ -4050,7 +4048,7 @@ static void ccgDM_release(DerivedMesh *dm)
MEM_freeN(ccgdm->faceMap);
}
- BLI_rw_mutex_end(&ccgdm->loops_cache_rwlock);
+ BLI_mutex_end(&ccgdm->loops_cache_lock);
BLI_rw_mutex_end(&ccgdm->origindex_cache_rwlock);
MEM_freeN(ccgdm);
@@ -5044,7 +5042,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
ccgdm->dm.numLoopData = ccgdm->dm.numPolyData * 4;
ccgdm->dm.numTessFaceData = 0;
- BLI_rw_mutex_init(&ccgdm->loops_cache_rwlock);
+ BLI_mutex_init(&ccgdm->loops_cache_lock);
BLI_rw_mutex_init(&ccgdm->origindex_cache_rwlock);
return ccgdm;
More information about the Bf-blender-cvs
mailing list