diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-09 15:49:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-09 17:55:04 +0300 |
commit | 14f3b2cdad2d7b00ce3ea27bf8eb0087ac2a6cbd (patch) | |
tree | 889d20ad5cf627057bb619e18ec47d39cabafc99 /source/blender/blenkernel/intern | |
parent | f546b0800b9121b24b1292f1ec602ed9964d1848 (diff) |
BLI_task: add TLS support to BLI_task_parallel_mempool
Support thread local storage for BLI_task_parallel_mempool,
as well as support for the reduce and free callbacks.
mempool_iter_threadsafe_* functions have been moved into a private
header thats only shared between task_iterator.c and BLI_mempool.c
so the TLS can be made part of the iterator array without having to
rely on passing in struct offsets.
Add test task.MempoolIterTLS that ensures reduce and free
are working as expected.
Reviewed By: mont29
Ref D11548
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/armature_deform.c | 16 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice_deform.c | 16 |
2 files changed, 24 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c index 8711a001e32..bca5503c8d2 100644 --- a/source/blender/blenkernel/intern/armature_deform.c +++ b/source/blender/blenkernel/intern/armature_deform.c @@ -444,7 +444,9 @@ static void armature_vert_task(void *__restrict userdata, armature_vert_task_with_dvert(data, i, dvert); } -static void armature_vert_task_editmesh(void *__restrict userdata, MempoolIterData *iter) +static void armature_vert_task_editmesh(void *__restrict userdata, + MempoolIterData *iter, + const TaskParallelTLS *__restrict UNUSED(tls)) { const ArmatureUserdata *data = userdata; BMVert *v = (BMVert *)iter; @@ -452,7 +454,9 @@ static void armature_vert_task_editmesh(void *__restrict userdata, MempoolIterDa armature_vert_task_with_dvert(data, BM_elem_index_get(v), dvert); } -static void armature_vert_task_editmesh_no_dvert(void *__restrict userdata, MempoolIterData *iter) +static void armature_vert_task_editmesh_no_dvert(void *__restrict userdata, + MempoolIterData *iter, + const TaskParallelTLS *__restrict UNUSED(tls)) { const ArmatureUserdata *data = userdata; BMVert *v = (BMVert *)iter; @@ -593,12 +597,16 @@ static void armature_deform_coords_impl(const Object *ob_arm, * have already been properly set. */ BM_mesh_elem_index_ensure(em_target->bm, BM_VERT); + TaskParallelSettings settings; + BLI_parallel_mempool_settings_defaults(&settings); + if (use_dverts) { - BLI_task_parallel_mempool(em_target->bm->vpool, &data, armature_vert_task_editmesh, true); + BLI_task_parallel_mempool( + em_target->bm->vpool, &data, armature_vert_task_editmesh, &settings); } else { BLI_task_parallel_mempool( - em_target->bm->vpool, &data, armature_vert_task_editmesh_no_dvert, true); + em_target->bm->vpool, &data, armature_vert_task_editmesh_no_dvert, &settings); } } else { diff --git a/source/blender/blenkernel/intern/lattice_deform.c b/source/blender/blenkernel/intern/lattice_deform.c index 4a926ee3d96..a8126cb5538 100644 --- a/source/blender/blenkernel/intern/lattice_deform.c +++ b/source/blender/blenkernel/intern/lattice_deform.c @@ -320,7 +320,9 @@ static void lattice_deform_vert_task(void *__restrict userdata, lattice_deform_vert_with_dvert(data, index, data->dvert ? &data->dvert[index] : NULL); } -static void lattice_vert_task_editmesh(void *__restrict userdata, MempoolIterData *iter) +static void lattice_vert_task_editmesh(void *__restrict userdata, + MempoolIterData *iter, + const TaskParallelTLS *__restrict UNUSED(tls)) { const LatticeDeformUserdata *data = userdata; BMVert *v = (BMVert *)iter; @@ -328,7 +330,9 @@ static void lattice_vert_task_editmesh(void *__restrict userdata, MempoolIterDat lattice_deform_vert_with_dvert(data, BM_elem_index_get(v), dvert); } -static void lattice_vert_task_editmesh_no_dvert(void *__restrict userdata, MempoolIterData *iter) +static void lattice_vert_task_editmesh_no_dvert(void *__restrict userdata, + MempoolIterData *iter, + const TaskParallelTLS *__restrict UNUSED(tls)) { const LatticeDeformUserdata *data = userdata; BMVert *v = (BMVert *)iter; @@ -397,12 +401,16 @@ static void lattice_deform_coords_impl(const Object *ob_lattice, * have already been properly set. */ BM_mesh_elem_index_ensure(em_target->bm, BM_VERT); + TaskParallelSettings settings; + BLI_parallel_mempool_settings_defaults(&settings); + if (cd_dvert_offset != -1) { - BLI_task_parallel_mempool(em_target->bm->vpool, &data, lattice_vert_task_editmesh, true); + BLI_task_parallel_mempool( + em_target->bm->vpool, &data, lattice_vert_task_editmesh, &settings); } else { BLI_task_parallel_mempool( - em_target->bm->vpool, &data, lattice_vert_task_editmesh_no_dvert, true); + em_target->bm->vpool, &data, lattice_vert_task_editmesh_no_dvert, &settings); } } else { |