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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-01-11 19:56:18 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-01-11 19:56:18 +0300
commit713852affbc2d48d52582e2c298c722539c09603 (patch)
treeb141c4357df5b97c368e12d04780e45b241638da /source/blender/blenkernel/intern/multires.c
parentc253fe5e877c0b6fda0e165fddf0f01739129aea (diff)
Preparation step for nuking OMP from multires code.
Remove the critical OMP sections used to protect mem allocation. First one can be done in a separate loop before main, parallelized one. Second one only affect 'private' data, so we only need to ensure guardedalloc thread safety is enabled. This is committed as separated step to ease troubleshooting in case bisecting becomes necesary.
Diffstat (limited to 'source/blender/blenkernel/intern/multires.c')
-rw-r--r--source/blender/blenkernel/intern/multires.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 9679b585e6f..4eb550a9f4c 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -44,6 +44,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_task.h"
#include "BKE_pbvh.h"
#include "BKE_ccg.h"
@@ -1052,6 +1053,16 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
k = 0; /*current loop/mdisp index within the mloop array*/
+ /* when adding new faces in edit mode, need to allocate disps */
+ for (i = 0; i < totloop; ++i) {
+ if (mdisps[i].disps == NULL) {
+ multires_reallocate_mdisps(totloop, mdisps, totlvl);
+ break;
+ }
+ }
+
+ BLI_begin_threaded_malloc();
+
#pragma omp parallel for private(i) if (totloop * gridSize * gridSize >= CCG_OMP_LIMIT)
for (i = 0; i < totpoly; ++i) {
@@ -1065,24 +1076,15 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
CCGElem *subgrid = subGridData[gIndex];
float (*dispgrid)[3] = NULL;
- /* when adding new faces in edit mode, need to allocate disps */
- if (!mdisp->disps)
-#pragma omp critical
- {
- multires_reallocate_mdisps(totloop, mdisps, totlvl);
- }
-
dispgrid = mdisp->disps;
/* if needed, reallocate multires paint mask */
if (gpm && gpm->level < key.level) {
gpm->level = key.level;
-#pragma omp critical
- {
- if (gpm->data)
- MEM_freeN(gpm->data);
- gpm->data = MEM_callocN(sizeof(float) * key.grid_area, "gpm.data");
+ if (gpm->data) {
+ MEM_freeN(gpm->data);
}
+ gpm->data = MEM_callocN(sizeof(float) * key.grid_area, "gpm.data");
}
for (y = 0; y < gridSize; y++) {
@@ -1142,6 +1144,8 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm
}
}
+ BLI_end_threaded_malloc();
+
if (op == APPLY_DISPLACEMENTS) {
ccgSubSurf_stitchFaces(ccgdm->ss, 0, NULL, 0);
ccgSubSurf_updateNormals(ccgdm->ss, NULL, 0);