From 31d907fa0ad1afa8c8a1829e16d3af394ab9e301 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 16 Jan 2016 15:59:37 +0100 Subject: Cleanup: BLI_task - API changes. Based on usages so far: - Split callback worker func in two, 'basic' and 'extended' versions. The former goes back to the simplest verion, while the later keeps the 'userdata_chunk', and gets the thread_id too. - Add use_threading to simple BLI_task_parallel_range(), turns out we need this pretty much systematically, and allows to get rid of most usages of BLI_task_parallel_range_ex(). - Now BLI_task_parallel_range() expects 'basic' version of callback, while BLI_task_parallel_range_ex() expectes 'extended' version of the callback. All in all, this should make common usage of BLI_task_parallel_range simpler (less verbose), and add access to advanced callback to thread id, which is mandatory in some (future) cases. --- source/blender/blenlib/intern/BLI_kdopbvh.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/blenlib/intern/BLI_kdopbvh.c') diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index f1ed49f74e0..c4bf2ae6910 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -750,7 +750,7 @@ typedef struct BVHDivNodesData { int first_of_next_level; } BVHDivNodesData; -static void non_recursive_bvh_div_nodes_task_cb(void *userdata, void *UNUSED(userdata_chunk), int j) +static void non_recursive_bvh_div_nodes_task_cb(void *userdata, const int j) { BVHDivNodesData *data = userdata; @@ -873,9 +873,9 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, cb_data.i = i; cb_data.depth = depth; - BLI_task_parallel_range_ex( - i, end_j, &cb_data, NULL, 0, non_recursive_bvh_div_nodes_task_cb, - num_leafs > KDOPBVH_THREAD_LEAF_THRESHOLD, false); + BLI_task_parallel_range( + i, end_j, &cb_data, non_recursive_bvh_div_nodes_task_cb, + num_leafs > KDOPBVH_THREAD_LEAF_THRESHOLD); } } @@ -1195,7 +1195,7 @@ int BLI_bvhtree_overlap_thread_num(const BVHTree *tree) return (int)MIN2(tree->tree_type, tree->nodes[tree->totleaf]->totnode); } -static void bvhtree_overlap_task_cb(void *userdata, void *UNUSED(userdata_chunk), int j) +static void bvhtree_overlap_task_cb(void *userdata, const int j) { BVHOverlapData_Thread *data = &((BVHOverlapData_Thread *)userdata)[j]; BVHOverlapData_Shared *data_shared = data->shared; @@ -1260,9 +1260,9 @@ BVHTreeOverlap *BLI_bvhtree_overlap( data[j].thread = j; } - BLI_task_parallel_range_ex( - 0, thread_num, data, NULL, 0, bvhtree_overlap_task_cb, - tree1->totleaf > KDOPBVH_THREAD_LEAF_THRESHOLD, false); + BLI_task_parallel_range( + 0, thread_num, data, bvhtree_overlap_task_cb, + tree1->totleaf > KDOPBVH_THREAD_LEAF_THRESHOLD); for (j = 0; j < thread_num; j++) total += BLI_stack_count(data[j].overlap); -- cgit v1.2.3