Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-12-28 13:29:34 +0300
committerJacques Lucke <mail@jlucke.com>2019-12-28 13:29:34 +0300
commit1eca32bb8422565e52ec6a676045dad47f92a24e (patch)
tree4f8567e26a0249a7a5c27320ee3d2cf916f323ac /source/blender/simulations/bparticles
parent4601ea8f82c673582e33302a1e823299cd91607f (diff)
improve usage of TBB
Diffstat (limited to 'source/blender/simulations/bparticles')
-rw-r--r--source/blender/simulations/bparticles/c_wrapper.cpp9
-rw-r--r--source/blender/simulations/bparticles/simulate.cpp38
2 files changed, 39 insertions, 8 deletions
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index f191e7f8a4e..c3eedf2cdae 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -17,7 +17,10 @@
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
-#include "tbb/tbb.h"
+#ifdef WITH_TBB
+# define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
+# include "tbb/tbb.h"
+#endif
#define WRAPPERS(T1, T2) \
inline T1 unwrap(T2 value) \
@@ -148,10 +151,14 @@ static Mesh *distribute_tetrahedons(ArrayRef<float3> centers,
&mesh->ldata, CD_MLOOPCOL, CD_DEFAULT, nullptr, mesh->totloop, "Color"),
mesh->totloop);
+#if WITH_TBB
tbb::parallel_for(
tbb::blocked_range<uint>(0, amount, 1000), [&](const tbb::blocked_range<uint> &range) {
distribute_tetrahedons_range(mesh, loop_colors, range, centers, scales, colors);
});
+#else
+ distribute_tetrahedons_range(mesh, loop_colors, IndexRange(amount), centers, scales, colors);
+#endif
return mesh;
}
diff --git a/source/blender/simulations/bparticles/simulate.cpp b/source/blender/simulations/bparticles/simulate.cpp
index 1452cb9b6d7..1f46c03a774 100644
--- a/source/blender/simulations/bparticles/simulate.cpp
+++ b/source/blender/simulations/bparticles/simulate.cpp
@@ -8,9 +8,10 @@
#include "simulate.hpp"
-// #ifdef WITH_TBB
-#include "tbb/tbb.h"
-// #endif
+#ifdef WITH_TBB
+# define TBB_SUPPRESS_DEPRECATED_MESSAGES 1
+# include "tbb/tbb.h"
+#endif
namespace BParticles {
@@ -350,7 +351,7 @@ BLI_NOINLINE static void simulate_blocks_for_time_span(
FloatInterval time_span,
SimulationState &simulation_state)
{
- tbb::parallel_for((uint)0, blocks.size(), [&](uint block_index) {
+ auto func = [&](uint block_index) {
AttributesBlock &block = *blocks[block_index];
StringRef particle_system_name = simulation_state.particles().particle_container_name(
@@ -368,7 +369,15 @@ BLI_NOINLINE static void simulate_blocks_for_time_span(
time_span.end());
delete_tagged_particles_and_reorder(block);
- });
+ };
+
+#ifdef WITH_TBB
+ tbb::parallel_for((uint)0, blocks.size(), func);
+#else
+ for (uint i : blocks.index_iterator()) {
+ func(i);
+ }
+#endif
}
BLI_NOINLINE static void simulate_blocks_from_birth_to_current_time(
@@ -378,7 +387,7 @@ BLI_NOINLINE static void simulate_blocks_from_birth_to_current_time(
float end_time,
SimulationState &simulation_state)
{
- tbb::parallel_for((uint)0, blocks.size(), [&](uint block_index) {
+ auto func = [&](uint block_index) {
AttributesBlock &block = *blocks[block_index];
StringRef particle_system_name = simulation_state.particles().particle_container_name(
@@ -395,7 +404,15 @@ BLI_NOINLINE static void simulate_blocks_from_birth_to_current_time(
simulation_state, particle_allocator, block.as_ref(), system_info, durations, end_time);
delete_tagged_particles_and_reorder(block);
- });
+ };
+
+#ifdef WITH_TBB
+ tbb::parallel_for((uint)0, blocks.size(), func);
+#else
+ for (uint i : blocks.index_iterator()) {
+ func(i);
+ }
+#endif
}
BLI_NOINLINE static Vector<AttributesBlock *> get_all_blocks_to_simulate(
@@ -462,6 +479,7 @@ void simulate_particles(SimulationState &simulation_state,
Vector<AttributesBlock *> newly_created_blocks;
{
ParticleAllocator particle_allocator(particles_state);
+#ifdef WITH_TBB
tbb::parallel_invoke(
[&]() {
simulate_all_existing_blocks(
@@ -471,6 +489,12 @@ void simulate_particles(SimulationState &simulation_state,
create_particles_from_emitters(
simulation_state, particle_allocator, emitters, simulation_time_span);
});
+#else
+ simulate_all_existing_blocks(
+ simulation_state, systems_to_simulate, particle_allocator, simulation_time_span);
+ create_particles_from_emitters(
+ simulation_state, particle_allocator, emitters, simulation_time_span);
+#endif
newly_created_blocks = particle_allocator.allocated_blocks();
}