Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-12-22 14:45:06 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-12-22 14:50:57 +0300
commitdf0ecd73af9218608b5436761d6a298cb4985709 (patch)
tree187c52f03ac7aac11eeb1293753d145ad293723c /source/blender/blenkernel/intern/subsurf_ccg.c
parent50f1c9a8afeffc81580bc12a19d8ffd01c3a9e6f (diff)
Subsurf: Avoid global lock for loops and orig index layers
This is a bit annoying to have per-DM locking, but it's way better (as in, up to 4 times better) for playback speed when having lots of subsurf objects,
Diffstat (limited to 'source/blender/blenkernel/intern/subsurf_ccg.c')
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index f8025f8df84..1386c23e234 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -90,9 +90,6 @@
/* assumes MLoop's are layed out 4 for each poly, in order */
#define USE_LOOP_LAYOUT_FAST
-static ThreadRWMutex loops_cache_rwlock = BLI_RWLOCK_INITIALIZER;
-static ThreadRWMutex origindex_cache_rwlock = BLI_RWLOCK_INITIALIZER;
-
static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss,
int drawInteriorEdges,
int useSubsurfUv,
@@ -1492,7 +1489,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
/* DMFlagMat *faceFlags = ccgdm->faceFlags; */ /* UNUSED */
if (!ccgdm->ehash) {
- BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE);
+ BLI_rw_mutex_lock(&ccgdm->loops_cache_rwlock, THREAD_LOCK_WRITE);
if (!ccgdm->ehash) {
MEdge *medge;
@@ -1503,10 +1500,10 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
BLI_edgehash_insert(ccgdm->ehash, medge[i].v1, medge[i].v2, SET_INT_IN_POINTER(i));
}
}
- BLI_rw_mutex_unlock(&loops_cache_rwlock);
+ BLI_rw_mutex_unlock(&ccgdm->loops_cache_rwlock);
}
- BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_READ);
+ BLI_rw_mutex_lock(&ccgdm->loops_cache_rwlock, THREAD_LOCK_READ);
totface = ccgSubSurf_getNumFaces(ss);
mv = mloop;
for (index = 0; index < totface; index++) {
@@ -1549,7 +1546,7 @@ static void ccgDM_copyFinalLoopArray(DerivedMesh *dm, MLoop *mloop)
}
}
}
- BLI_rw_mutex_unlock(&loops_cache_rwlock);
+ BLI_rw_mutex_unlock(&ccgdm->loops_cache_rwlock);
}
static void ccgDM_copyFinalPolyArray(DerivedMesh *dm, MPoly *mpoly)
@@ -4050,6 +4047,10 @@ static void ccgDM_release(DerivedMesh *dm)
MEM_freeN(ccgdm->edgeMap);
MEM_freeN(ccgdm->faceMap);
}
+
+ BLI_rw_mutex_end(&ccgdm->loops_cache_rwlock);
+ BLI_rw_mutex_end(&ccgdm->origindex_cache_rwlock);
+
MEM_freeN(ccgdm);
}
}
@@ -4064,14 +4065,14 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
int a, index, totnone, totorig;
/* Avoid re-creation if the layer exists already */
- BLI_rw_mutex_lock(&origindex_cache_rwlock, THREAD_LOCK_READ);
+ BLI_rw_mutex_lock(&ccgdm->origindex_cache_rwlock, THREAD_LOCK_READ);
origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
- BLI_rw_mutex_unlock(&origindex_cache_rwlock);
+ BLI_rw_mutex_unlock(&ccgdm->origindex_cache_rwlock);
if (origindex) {
return origindex;
}
- BLI_rw_mutex_lock(&origindex_cache_rwlock, THREAD_LOCK_WRITE);
+ BLI_rw_mutex_lock(&ccgdm->origindex_cache_rwlock, THREAD_LOCK_WRITE);
DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL);
origindex = DM_get_vert_data_layer(dm, CD_ORIGINDEX);
@@ -4086,7 +4087,7 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
CCGVert *v = ccgdm->vertMap[index].vert;
origindex[a] = ccgDM_getVertMapIndex(ccgdm->ss, v);
}
- BLI_rw_mutex_unlock(&origindex_cache_rwlock);
+ BLI_rw_mutex_unlock(&ccgdm->origindex_cache_rwlock);
return origindex;
}
@@ -5041,6 +5042,9 @@ 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_rw_mutex_init(&ccgdm->origindex_cache_rwlock);
+
return ccgdm;
}