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 <jacques@blender.org>2022-04-07 10:48:07 +0300
committerJacques Lucke <jacques@blender.org>2022-04-07 10:48:07 +0300
commit2aff04917f9e0420174e01dff0936d5237a7bbbd (patch)
treee345363cb6e21ad68400dba64650a3ca64b29347
parentfd5e5dac8946b1359904737f799523682b4ada1e (diff)
Functions: parallelize materializing arrays after field evaluation
This improves performance e.g. when creating an integer attribute based on an index field. For 4 million vertices, I measured a speedup from 3.5 ms to 1.2 ms.
-rw-r--r--source/blender/functions/intern/field.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc
index 986d6ddc19e..944674c23a9 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -468,16 +468,21 @@ Vector<GVArray> evaluate_fields(ResourceScope &scope,
/* Still have to copy over the data in the destination provided by the caller. */
if (dst_varray.is_span()) {
/* Materialize into a span. */
- computed_varray.materialize_to_uninitialized(mask, dst_varray.get_internal_span().data());
+ threading::parallel_for(mask.index_range(), 2048, [&](const IndexRange range) {
+ computed_varray.materialize_to_uninitialized(mask.slice(range),
+ dst_varray.get_internal_span().data());
+ });
}
else {
/* Slower materialize into a different structure. */
const CPPType &type = computed_varray.type();
- BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
- for (const int i : mask) {
- computed_varray.get_to_uninitialized(i, buffer);
- dst_varray.set_by_relocate(i, buffer);
- }
+ threading::parallel_for(mask.index_range(), 2048, [&](const IndexRange range) {
+ BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
+ for (const int i : mask.slice(range)) {
+ computed_varray.get_to_uninitialized(i, buffer);
+ dst_varray.set_by_relocate(i, buffer);
+ }
+ });
}
r_varrays[out_index] = dst_varray;
}