diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-11-23 23:19:54 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-11-23 23:19:54 +0300 |
commit | bc3f0cfd145d2b05d17cc4f04839d3263dbc90aa (patch) | |
tree | 307ee3d5749a09122ad91216dbd22a6ffc42a84d | |
parent | cf6e8edda5e51696a20c76b879d920655d65e81d (diff) |
BMesh: add limited support for parallelization over some basic iterators.
This merely uses new memloop/task looper over vertex/edge/face mempools.
Quite obviously, only BM_VERTS/EDGES/FACES_OF_MESH iterators are
supported.
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators_inline.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h index e68440021e6..32f0f4b67c4 100644 --- a/source/blender/bmesh/intern/bmesh_iterators_inline.h +++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h @@ -182,4 +182,40 @@ BLI_INLINE void *BM_iter_new(BMIter *iter, BMesh *bm, const char itype, void *da } } +/** + * \brief Parallel (threaded) iterator, only available for most basic itertypes (verts/edges/faces of mesh). + * + * Uses BLI_task_parallel_mempool to iterate over all items of underlying matching mempool. + * + * \note You have to include BLI_task.h before BMesh includes to be able to use this function! + */ + +#ifdef __BLI_TASK_H__ + +ATTR_NONNULL(1) +BLI_INLINE void BM_iter_parallel( + BMesh *bm, const char itype, TaskParallelMempoolFunc func, void *userdata, const bool use_threading) +{ + BLI_assert(bm != NULL); + + /* inlining optimizes out this switch when called with the defined type */ + switch ((BMIterType)itype) { + case BM_VERTS_OF_MESH: + BLI_task_parallel_mempool(bm->vpool, userdata, func, use_threading); + break; + case BM_EDGES_OF_MESH: + BLI_task_parallel_mempool(bm->epool, userdata, func, use_threading); + break; + case BM_FACES_OF_MESH: + BLI_task_parallel_mempool(bm->fpool, userdata, func, use_threading); + break; + default: + /* should never happen */ + BLI_assert(0); + break; + } +} + +#endif /* __BLI_TASK_H__ */ + #endif /* __BMESH_ITERATORS_INLINE_H__ */ |