[Bf-blender-cvs] [a1f44e43a25] blender-v2.92-release: Fix T84745: more build errors with TBB 2021

Brecht Van Lommel noreply at git.blender.org
Fri Jan 22 19:24:25 CET 2021


Commit: a1f44e43a253eabee74f40315b62cc0c0ff4cb9c
Author: Brecht Van Lommel
Date:   Fri Jan 22 18:14:04 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rBa1f44e43a253eabee74f40315b62cc0c0ff4cb9c

Fix T84745: more build errors with TBB 2021

* tbb::blocked_range moved to a different namespace and since the fix is
  non-trivial, remove some unused code that used this.
* Task group priorities are no longer supported. It's unclear if they are
  useful at all right now and even set correctly, for now all tasks are equal
  priority with TBB 2021.

===================================================================

M	intern/cycles/util/util_tbb.h
M	source/blender/blenlib/BLI_index_range.hh
M	source/blender/blenlib/intern/task_pool.cc

===================================================================

diff --git a/intern/cycles/util/util_tbb.h b/intern/cycles/util/util_tbb.h
index 206ba106ca6..168bd5db961 100644
--- a/intern/cycles/util/util_tbb.h
+++ b/intern/cycles/util/util_tbb.h
@@ -36,7 +36,14 @@ using tbb::parallel_for;
 
 static inline void parallel_for_cancel()
 {
+#if TBB_INTERFACE_VERSION_MAJOR >= 12
+  tbb::task_group_context *ctx = tbb::task::current_context();
+  if (ctx) {
+    ctx->cancel_group_execution();
+  }
+#else
   tbb::task::self().cancel_group_execution();
+#endif
 }
 
 CCL_NAMESPACE_END
diff --git a/source/blender/blenlib/BLI_index_range.hh b/source/blender/blenlib/BLI_index_range.hh
index 4121542c887..61a8088edea 100644
--- a/source/blender/blenlib/BLI_index_range.hh
+++ b/source/blender/blenlib/BLI_index_range.hh
@@ -58,11 +58,6 @@
 
 #include "BLI_utildefines.h"
 
-/* Forward declare tbb::blocked_range for conversion operations. */
-namespace tbb {
-template<typename Value> class blocked_range;
-}
-
 namespace blender {
 
 template<typename T> class Span;
@@ -86,12 +81,6 @@ class IndexRange {
     BLI_assert(size >= 0);
   }
 
-  template<typename T>
-  constexpr IndexRange(const tbb::blocked_range<T> &range)
-      : start_(range.begin()), size_(range.size())
-  {
-  }
-
   class Iterator {
    private:
     int64_t current_;
diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc
index 4b545c5647e..10f15f8749c 100644
--- a/source/blender/blenlib/intern/task_pool.cc
+++ b/source/blender/blenlib/intern/task_pool.cc
@@ -131,6 +131,12 @@ class TBBTaskGroup : public tbb::task_group {
  public:
   TBBTaskGroup(TaskPriority priority)
   {
+#  if TBB_INTERFACE_VERSION_MAJOR >= 12
+    /* TODO: support priorities in TBB 2021, where they are only available as
+     * part of task arenas, no longer for task groups. Or remove support for
+     * task priorities if they are no longer useful. */
+    UNUSED_VARS(priority);
+#  else
     switch (priority) {
       case TASK_PRIORITY_LOW:
         my_context.set_priority(tbb::priority_low);
@@ -139,6 +145,7 @@ class TBBTaskGroup : public tbb::task_group {
         my_context.set_priority(tbb::priority_normal);
         break;
     }
+#  endif
   }
 
   ~TBBTaskGroup()



More information about the Bf-blender-cvs mailing list