diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-03-22 03:13:28 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-03-22 03:30:19 +0300 |
commit | fab14f78542ca040cc1606dbd33a4db6aea5976a (patch) | |
tree | 080478f6ef6b80c43d8529049b19ea75d3f47733 /source/blender/blenlib | |
parent | 976c91cd770f4323d4a5007e5bf444b8c701278b (diff) |
Fix build when using WITH_TBB=OFF after recent changes
And wrap tbb::parallel_sort in blender namespace similar to other TBB
functionality.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_sort.hh | 32 | ||||
-rw-r--r-- | source/blender/blenlib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/mesh_intersect.cc | 11 |
3 files changed, 35 insertions, 9 deletions
diff --git a/source/blender/blenlib/BLI_sort.hh b/source/blender/blenlib/BLI_sort.hh new file mode 100644 index 00000000000..411e6a0c4df --- /dev/null +++ b/source/blender/blenlib/BLI_sort.hh @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +/** \file + * \ingroup bli + */ + +#ifdef WITH_TBB +# include <tbb/parallel_sort.h> +#else +# include <algorithm> +#endif + +namespace blender { + +#ifdef WITH_TBB +using tbb::parallel_sort; +#else +template<typename RandomAccessIterator> +void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end) +{ + std::sort<RandomAccessIterator>(begin, end); +} +template<typename RandomAccessIterator, typename Compare> +void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end, const Compare &comp) +{ + std::sort<RandomAccessIterator, Compare>(begin, end, comp); +} +#endif + +} // namespace blender diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 6c216f873de..af71c96fc10 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -285,6 +285,7 @@ set(SRC BLI_simd.h BLI_smallhash.h BLI_sort.h + BLI_sort.hh BLI_sort_utils.h BLI_span.hh BLI_stack.h diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index 8f2c86556aa..96ae0750899 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -26,6 +26,7 @@ # include "BLI_math_vector.h" # include "BLI_polyfill_2d.h" # include "BLI_set.hh" +# include "BLI_sort.hh" # include "BLI_span.hh" # include "BLI_task.h" # include "BLI_task.hh" @@ -37,10 +38,6 @@ # include "BLI_mesh_intersect.hh" -# ifdef WITH_TBB -# include <tbb/parallel_sort.h> -# endif - // # define PERFDEBUG namespace blender::meshintersect { @@ -672,11 +669,7 @@ void IMesh::populate_vert(int max_verts) * TODO: when all debugged, set fix_order = false. */ const bool fix_order = true; if (fix_order) { -# ifdef WITH_TBB - tbb::parallel_sort(vert_.begin(), vert_.end(), [](const Vert *a, const Vert *b) { -# else - std::sort(vert_.begin(), vert_.end(), [](const Vert *a, const Vert *b) { -# endif + blender::parallel_sort(vert_.begin(), vert_.end(), [](const Vert *a, const Vert *b) { if (a->orig != NO_INDEX && b->orig != NO_INDEX) { return a->orig < b->orig; } |