[Bf-blender-cvs] [55fb2abc814] master: Curves: Bring back parallel copying of curve and point attributes
Hans Goudey
noreply at git.blender.org
Wed Jul 27 18:53:28 CEST 2022
Commit: 55fb2abc814c57074cae5d7328bdcdc623fcd974
Author: Hans Goudey
Date: Wed Jul 27 11:51:45 2022 -0500
Branches: master
https://developer.blender.org/rB55fb2abc814c57074cae5d7328bdcdc623fcd974
Curves: Bring back parallel copying of curve and point attributes
This was removed in cacdea7f4a5b49d to fix a bug, but copying point
and curve attributes should be fine as long as the attribute arrays are
retrieved before-hand.
Differential Revision: https://developer.blender.org/D15541
===================================================================
M source/blender/blenkernel/intern/curves_geometry.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index 6486be4afe0..7fb4e37f956 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -1163,6 +1163,10 @@ static CurvesGeometry copy_with_removed_points(const CurvesGeometry &curves,
}
CurvesGeometry new_curves{new_point_count, new_curve_count};
+ Vector<bke::AttributeTransferData> point_attributes = bke::retrieve_attributes_for_transfer(
+ curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_POINT);
+ Vector<bke::AttributeTransferData> curve_attributes = bke::retrieve_attributes_for_transfer(
+ curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_CURVE);
threading::parallel_invoke(
256 < new_point_count * new_curve_count,
@@ -1170,8 +1174,7 @@ static CurvesGeometry copy_with_removed_points(const CurvesGeometry &curves,
[&]() { new_curves.offsets_for_write().copy_from(new_curve_offsets); },
[&]() {
/* Copy over point attributes. */
- for (auto &attribute : bke::retrieve_attributes_for_transfer(
- curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_POINT)) {
+ for (bke::AttributeTransferData &attribute : point_attributes) {
threading::parallel_for(copy_point_ranges.index_range(), 128, [&](IndexRange range) {
for (const int range_i : range) {
const IndexRange src_range = copy_point_ranges[range_i];
@@ -1182,24 +1185,29 @@ static CurvesGeometry copy_with_removed_points(const CurvesGeometry &curves,
{copy_point_range_dst_offsets[range_i], src_range.size()});
}
});
- attribute.dst.finish();
}
-
+ },
+ [&]() {
/* Copy over curve attributes.
* In some cases points are just dissolved, so the the number of
* curves will be the same. That could be optimized in the future. */
- for (auto &attribute : bke::retrieve_attributes_for_transfer(
- curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_CURVE)) {
+ for (bke::AttributeTransferData &attribute : curve_attributes) {
if (new_curves.curves_num() == curves.curves_num()) {
attribute.dst.span.copy_from(attribute.src);
}
else {
copy_with_map(attribute.src, new_curve_orig_indices, attribute.dst.span);
}
- attribute.dst.finish();
}
});
+ for (bke::AttributeTransferData &attribute : point_attributes) {
+ attribute.dst.finish();
+ }
+ for (bke::AttributeTransferData &attribute : curve_attributes) {
+ attribute.dst.finish();
+ }
+
return new_curves;
}
@@ -1236,6 +1244,10 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
}
CurvesGeometry new_curves{new_tot_points, new_tot_curves};
+ Vector<bke::AttributeTransferData> point_attributes = bke::retrieve_attributes_for_transfer(
+ curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_POINT);
+ Vector<bke::AttributeTransferData> curve_attributes = bke::retrieve_attributes_for_transfer(
+ curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_CURVE);
threading::parallel_invoke(
256 < new_tot_points * new_tot_curves,
@@ -1267,8 +1279,7 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
},
[&]() {
/* Copy over point attributes. */
- for (auto &attribute : bke::retrieve_attributes_for_transfer(
- curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_POINT)) {
+ for (bke::AttributeTransferData &attribute : point_attributes) {
threading::parallel_for(old_curve_ranges.index_range(), 128, [&](IndexRange range) {
for (const int range_i : range) {
copy_between_buffers(attribute.src.type(),
@@ -1278,11 +1289,11 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
new_point_ranges[range_i]);
}
});
- attribute.dst.finish();
}
+ },
+ [&]() {
/* Copy over curve attributes. */
- for (auto &attribute : bke::retrieve_attributes_for_transfer(
- curves.attributes(), new_curves.attributes_for_write(), ATTR_DOMAIN_MASK_CURVE)) {
+ for (bke::AttributeTransferData &attribute : curve_attributes) {
threading::parallel_for(old_curve_ranges.index_range(), 128, [&](IndexRange range) {
for (const int range_i : range) {
copy_between_buffers(attribute.src.type(),
@@ -1292,10 +1303,16 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
new_curve_ranges[range_i]);
}
});
- attribute.dst.finish();
}
});
+ for (bke::AttributeTransferData &attribute : point_attributes) {
+ attribute.dst.finish();
+ }
+ for (bke::AttributeTransferData &attribute : curve_attributes) {
+ attribute.dst.finish();
+ }
+
return new_curves;
}
More information about the Bf-blender-cvs
mailing list