[Bf-blender-cvs] [ab36a7de75e] temp-varray-get-set-multiple: progress
Jacques Lucke
noreply at git.blender.org
Sun Sep 26 15:09:34 CEST 2021
Commit: ab36a7de75e5bb93e8fb4abfadc7667c01227a5e
Author: Jacques Lucke
Date: Sat Sep 25 15:59:20 2021 +0200
Branches: temp-varray-get-set-multiple
https://developer.blender.org/rBab36a7de75e5bb93e8fb4abfadc7667c01227a5e
progress
===================================================================
M source/blender/blenkernel/intern/attribute_access.cc
M source/blender/blenkernel/intern/geometry_component_curve.cc
M source/blender/blenlib/BLI_virtual_array.hh
M source/blender/functions/FN_generic_virtual_array.hh
M source/blender/functions/intern/field.cc
M source/blender/functions/intern/generic_virtual_array.cc
M source/blender/functions/intern/multi_function_builder.cc
M source/blender/functions/intern/multi_function_procedure_executor.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index c2837b522c4..0153ffc8bc9 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -300,7 +300,7 @@ static bool add_custom_data_layer_from_attribute_init(CustomData &custom_data,
return false;
}
const GVArray *varray = static_cast<const AttributeInitVArray &>(initializer).varray;
- varray->materialize_to_uninitialized(IndexRange(varray->size()), data);
+ varray->get_multiple_to_uninitialized(data);
return true;
}
case AttributeInit::Type::MoveArray: {
@@ -495,7 +495,7 @@ static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attr
return false;
}
const GVArray *varray = static_cast<const AttributeInitVArray &>(initializer).varray;
- varray->materialize_to_uninitialized(IndexRange(varray->size()), data);
+ varray->get_multiple_to_uninitialized(data);
return true;
}
case AttributeInit::Type::MoveArray: {
@@ -1300,7 +1300,7 @@ static OutputAttribute create_output_attribute(GeometryComponent &component,
/* Fill the temporary array with values from the existing attribute. */
GVArrayPtr old_varray = component.attribute_get_for_read(
attribute_id, domain, data_type, default_value);
- old_varray->materialize_to_uninitialized(IndexRange(domain_size), data);
+ old_varray->get_multiple_to_uninitialized(data);
}
GVMutableArrayPtr varray = std::make_unique<GVMutableAttribute_For_OutputAttribute>(
GMutableSpan{*cpp_type, data, domain_size}, component, attribute_id);
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc
index 3b671e672ef..0cd9448626b 100644
--- a/source/blender/blenkernel/intern/geometry_component_curve.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curve.cc
@@ -293,28 +293,6 @@ template<typename T> class VArray_For_SplineToPoint final : public VArray<T> {
const PointIndices indices = lookup_point_indices(offsets_, index);
return original_data_[indices.spline_index];
}
-
- void materialize_to_uninitialized_impl(const IndexMask mask, MutableSpan<T> r_span) const final
- {
- T *dst = r_span.data();
- const int total_size = offsets_.last();
- if (mask.is_range() && mask.as_range() == IndexRange(total_size)) {
- for (const int spline_index : original_data_.index_range()) {
- const int offset = offsets_[spline_index];
- const int next_offset = offsets_[spline_index + 1];
- uninitialized_fill_n(dst + offset, next_offset - offset, original_data_[spline_index]);
- }
- }
- else {
- int spline_index = 0;
- for (const int dst_index : mask) {
- while (offsets_[spline_index] < dst_index) {
- spline_index++;
- }
- new (dst + dst_index) T(original_data_[spline_index]);
- }
- }
- }
};
static GVArrayPtr adapt_curve_domain_spline_to_point(const CurveEval &curve, GVArrayPtr varray)
@@ -541,34 +519,6 @@ static void point_attribute_materialize(Span<Span<T>> data,
}
}
-template<typename T>
-static void point_attribute_materialize_to_uninitialized(Span<Span<T>> data,
- Span<int> offsets,
- const IndexMask mask,
- MutableSpan<T> r_span)
-{
- T *dst = r_span.data();
- const int total_size = offsets.last();
- if (mask.is_range() && mask.as_range() == IndexRange(total_size)) {
- for (const int spline_index : data.index_range()) {
- const int offset = offsets[spline_index];
- const int next_offset = offsets[spline_index + 1];
- uninitialized_copy_n(data[spline_index].data(), next_offset - offset, dst + offset);
- }
- }
- else {
- int spline_index = 0;
- for (const int dst_index : mask) {
- while (offsets[spline_index] < dst_index) {
- spline_index++;
- }
-
- const int index_in_spline = dst_index - offsets[spline_index];
- new (dst + dst_index) T(data[spline_index][index_in_spline]);
- }
- }
-}
-
/**
* Virtual array for any control point data accessed with spans and an offset array.
*/
@@ -588,11 +538,6 @@ template<typename T> class VArray_For_SplinePoints : public VArray<T> {
const PointIndices indices = lookup_point_indices(offsets_, index);
return data_[indices.spline_index][indices.point_index];
}
-
- void materialize_to_uninitialized_impl(const IndexMask mask, MutableSpan<T> r_span) const final
- {
- point_attribute_materialize_to_uninitialized(data_.as_span(), offsets_, mask, r_span);
- }
};
/**
@@ -620,12 +565,6 @@ template<typename T> class VMutableArray_For_SplinePoints final : public VMutabl
const PointIndices indices = lookup_point_indices(offsets_, index);
data_[indices.spline_index][indices.point_index] = value;
}
-
- void materialize_to_uninitialized_impl(const IndexMask mask, MutableSpan<T> r_span) const final
- {
- point_attribute_materialize_to_uninitialized(
- {(Span<T> *)data_.data(), data_.size()}, offsets_, mask, r_span);
- }
};
template<typename T> GVArrayPtr point_data_gvarray(Array<Span<T>> spans, Array<int> offsets)
@@ -691,13 +630,6 @@ class VMutableArray_For_SplinePosition final : public VMutableArray<float3> {
}
return spans;
}
-
- void materialize_to_uninitialized_impl(const IndexMask mask,
- MutableSpan<float3> r_span) const final
- {
- Array<Span<float3>> spans = this->get_position_spans();
- point_attribute_materialize_to_uninitialized(spans.as_span(), offsets_, mask, r_span);
- }
};
/**
diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index f08a21e18e0..c991df3a519 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -107,15 +107,14 @@ template<typename T> class VArray {
void get_multiple_to_uninitialized(T *dst) const
{
- this->get_multiple_to_uninitialized(dst);
+ this->get_multiple_to_uninitialized(dst, IndexMask(size_));
}
void get_multiple_to_uninitialized(T *dst, IndexMask mask) const
{
BLI_assert(mask.min_array_size() <= size_);
- BLI_assert(mask.min_array_size() <= dst.size());
if constexpr (std::is_trivial_v<T>) {
- this->get_multiple(dst, mask);
+ this->get_multiple(MutableSpan(dst, mask.min_array_size()), mask);
}
else {
this->get_multiple_to_uninitialized_impl(dst, mask);
@@ -184,17 +183,6 @@ template<typename T> class VArray {
return this->get(index);
}
- void materialize_to_uninitialized(MutableSpan<T> r_span) const
- {
- this->materialize_to_uninitialized(IndexMask(size_), r_span);
- }
-
- void materialize_to_uninitialized(IndexMask mask, MutableSpan<T> r_span) const
- {
- BLI_assert(mask.min_array_size() <= size_);
- this->materialize_to_uninitialized_impl(mask, r_span);
- }
-
protected:
virtual T get_impl(const int64_t index) const = 0;
@@ -237,22 +225,6 @@ template<typename T> class VArray {
BLI_assert_unreachable();
return T();
}
-
- virtual void materialize_to_uninitialized_impl(IndexMask mask, MutableSpan<T> r_span) const
- {
- T *dst = r_span.data();
- if (this->is_span()) {
- const T *src = this->get_internal_span().data();
- mask.foreach_index([&](const int64_t i) { new (dst + i) T(src[i]); });
- }
- else if (this->is_single()) {
- const T single = this->get_internal_single();
- mask.foreach_index([&](const int64_t i) { new (dst + i) T(single); });
- }
- else {
- mask.foreach_index([&](const int64_t i) { new (dst + i) T(this->get(i)); });
- }
- }
};
/* Similar to VArray, but the elements are mutable. */
@@ -482,7 +454,7 @@ template<typename T> class VArray_Span final : public Span<T> {
else {
owned_data_.~Array();
new (&owned_data_) Array<T>(varray_.size(), NoInitialization{});
- varray_.materialize_to_uninitialized(owned_data_);
+ varray_.get_multiple_to_uninitialized(owned_data_.data());
this->data_ = owned_data_.data();
}
}
@@ -516,7 +488,7 @@ template<typename T> class VMutableArray_Span final : public MutableSpan<T> {
if (copy_values_to_span) {
owned_data_.~Array();
new (&owned_data_) Array<T>(varray_.size(), NoInitialization{});
- varray_.materialize_to_uninitialized(owned_data_);
+ varray_.get_multiple_to_uninitialized(owned_data_.data());
}
else {
owned_data_.reinitialize(varray_.size());
@@ -569,12 +541,6 @@ template<typename T, typename GetFunc> class VArray_For_Func final : public VArr
{
return get_func_(index);
}
-
- void materialize_to_uninitialized_impl(IndexMask mask, MutableSpan<T> r_span) const override
- {
- T *dst = r_span.data();
- mask.foreach_index([&](const int64_t i) { new (dst + i) T(get_func_(i)); });
- }
};
template<typename StructT, typename ElemT, ElemT (*GetFunc)(const StructT &)>
@@ -592,12 +558,6 @@ class VArray_For_DerivedSpan : public VArray<ElemT> {
{
return GetFunc(data_[index]);
}
-
- void materialize_to_uninitialized_impl(IndexMask mask, MutableSpan<ElemT> r_span) const override
- {
- ElemT *dst = r_span.data();
- mask.foreach_index([&](const int64_t i) { new (dst + i) ElemT(GetFunc(data_[i])); });
- }
};
template<typename StructT,
@@ -624,12 +584,6 @@ class VMutableArray_For_DerivedSpan : public VMutableArray<ElemT> {
{
SetFunc(data_[index], std::move(value));
}
-
- void materialize_to_uninitialized_impl(IndexMask mask, MutableSpan<ElemT> r_span) const override
- {
- ElemT *dst = r_span.data();
- mask.foreach_index([&](const int64_t i) { new (dst + i) ElemT(GetFunc(data_[i])); });
- }
};
/**
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 69192f13
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list