[Bf-blender-cvs] [d1eec74c562] geometry-nodes: Geometry Nodes: use attribute span api in attribute math node
Jacques Lucke
noreply at git.blender.org
Thu Nov 26 18:22:50 CET 2020
Commit: d1eec74c5627d45547d2c31727a028d0be626c4a
Author: Jacques Lucke
Date: Thu Nov 26 18:12:19 2020 +0100
Branches: geometry-nodes
https://developer.blender.org/rBd1eec74c5627d45547d2c31727a028d0be626c4a
Geometry Nodes: use attribute span api in attribute math node
For a simple add operation, this results in a 3-4x speedup.
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
index d8c2b75a0a9..d8a7e5df43c 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
@@ -73,16 +73,22 @@ static void do_math_operation(const FloatReadAttribute &input_a,
{
const int size = input_a.size();
+ Span<float> span_a = input_a.get_span();
+ Span<float> span_b = input_b.get_span();
+ MutableSpan<float> span_result = result.get_span();
+
bool success = try_dispatch_float_math_fl_fl_to_fl(
operation, [&](auto math_function, const FloatMathOperationInfo &UNUSED(info)) {
for (const int i : IndexRange(size)) {
- const float in1 = input_a[i];
- const float in2 = input_b[i];
+ const float in1 = span_a[i];
+ const float in2 = span_b[i];
const float out = math_function(in1, in2);
- result.set(i, out);
+ span_result[i] = out;
}
});
+ result.apply_span();
+
/* The operation is not supported by this node currently. */
BLI_assert(success);
UNUSED_VARS_NDEBUG(success);
More information about the Bf-blender-cvs
mailing list