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>2021-09-15 12:02:39 +0300
committerJacques Lucke <jacques@blender.org>2021-09-15 12:02:39 +0300
commite6ca0545904fe4236be9960fdb3c2760092582a5 (patch)
treebdc2217126eb5755662ef0ff188d08f7d6d51961 /source/blender/functions/intern/generic_virtual_array.cc
parentfb27a9bb983ce74b8d8f5f871cf0706dd1e25051 (diff)
Geometry Nodes: multi threaded field evaluation
This adds a new `ParallelMultiFunction` which wraps another multi-function and evaluates it with multiple threads. The speeds up field evaluation quite a bit (the effect is most noticeable when the number of evaluations and the field is large). There are still other single-threaded performance bottlenecks in field evaluation that will need to be solved separately. Most notably here is the process of copying the computed data into the position attribute in the Set Position node. Differential Revision: https://developer.blender.org/D12457
Diffstat (limited to 'source/blender/functions/intern/generic_virtual_array.cc')
-rw-r--r--source/blender/functions/intern/generic_virtual_array.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index bd033a429de..9a83d8cd497 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -387,4 +387,47 @@ void GVMutableArray_GSpan::disable_not_applied_warning()
show_not_saved_warning_ = false;
}
+/* --------------------------------------------------------------------
+ * GVArray_For_SlicedGVArray.
+ */
+
+void GVArray_For_SlicedGVArray::get_impl(const int64_t index, void *r_value) const
+{
+ varray_.get(index + offset_, r_value);
+}
+
+void GVArray_For_SlicedGVArray::get_to_uninitialized_impl(const int64_t index, void *r_value) const
+{
+ varray_.get_to_uninitialized(index + offset_, r_value);
+}
+
+/* --------------------------------------------------------------------
+ * GVArray_Slice.
+ */
+
+GVArray_Slice::GVArray_Slice(const GVArray &varray, const IndexRange slice)
+{
+ if (varray.is_span()) {
+ /* Create a new virtual for the sliced span. */
+ const GSpan span = varray.get_internal_span();
+ const GSpan sliced_span = span.slice(slice.start(), slice.size());
+ varray_span_.emplace(sliced_span);
+ varray_ = &*varray_span_;
+ }
+ else if (varray.is_single()) {
+ /* Can just use the existing virtual array, because it's the same value for the indices in the
+ * slice anyway. */
+ varray_ = &varray;
+ }
+ else {
+ /* Generic version when none of the above method works.
+ * We don't necessarily want to materialize the input varray because there might be
+ * large distances between the required indices. Then we would materialize many elements that
+ * are not accessed later on.
+ */
+ varray_any_.emplace(varray, slice);
+ varray_ = &*varray_any_;
+ }
+}
+
} // namespace blender::fn