diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-01-11 19:56:18 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-01-11 19:56:18 +0300 |
commit | 713852affbc2d48d52582e2c298c722539c09603 (patch) | |
tree | b141c4357df5b97c368e12d04780e45b241638da | |
parent | c253fe5e877c0b6fda0e165fddf0f01739129aea (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.
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 28 |
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); |