diff --git a/source/blender/blenlib/BLI_cpp_type.hh b/source/blender/blenlib/BLI_cpp_type.hh index 4429c60ec1c..085a6505c0e 100644 --- a/source/blender/blenlib/BLI_cpp_type.hh +++ b/source/blender/blenlib/BLI_cpp_type.hh @@ -73,7 +73,7 @@ */ #include "BLI_hash.hh" -#include "BLI_index_mask.hh" +#include "BLI_index_mask_fwd.hh" #include "BLI_map.hh" #include "BLI_parameter_pack_utils.hh" #include "BLI_string_ref.hh" @@ -155,36 +155,47 @@ class CPPType : NonCopyable, NonMovable { uintptr_t alignment_mask_ = 0; void (*default_construct_)(void *ptr) = nullptr; + void (*default_construct_n_)(void *ptr, int64_t n) = nullptr; void (*default_construct_indices_)(void *ptr, const IndexMask &mask) = nullptr; void (*value_initialize_)(void *ptr) = nullptr; + void (*value_initialize_n_)(void *ptr, int64_t n) = nullptr; void (*value_initialize_indices_)(void *ptr, const IndexMask &mask) = nullptr; void (*destruct_)(void *ptr) = nullptr; + void (*destruct_n_)(void *ptr, int64_t n) = nullptr; void (*destruct_indices_)(void *ptr, const IndexMask &mask) = nullptr; void (*copy_assign_)(const void *src, void *dst) = nullptr; + void (*copy_assign_n_)(const void *src, void *dst, int64_t n) = nullptr; void (*copy_assign_indices_)(const void *src, void *dst, const IndexMask &mask) = nullptr; void (*copy_assign_compressed_)(const void *src, void *dst, const IndexMask &mask) = nullptr; void (*copy_construct_)(const void *src, void *dst) = nullptr; + void (*copy_construct_n_)(const void *src, void *dst, int64_t n) = nullptr; void (*copy_construct_indices_)(const void *src, void *dst, const IndexMask &mask) = nullptr; void (*copy_construct_compressed_)(const void *src, void *dst, const IndexMask &mask) = nullptr; void (*move_assign_)(void *src, void *dst) = nullptr; + void (*move_assign_n_)(void *src, void *dst, int64_t n) = nullptr; void (*move_assign_indices_)(void *src, void *dst, const IndexMask &mask) = nullptr; void (*move_construct_)(void *src, void *dst) = nullptr; + void (*move_construct_n_)(void *src, void *dst, int64_t n) = nullptr; void (*move_construct_indices_)(void *src, void *dst, const IndexMask &mask) = nullptr; void (*relocate_assign_)(void *src, void *dst) = nullptr; + void (*relocate_assign_n_)(void *src, void *dst, int64_t n) = nullptr; void (*relocate_assign_indices_)(void *src, void *dst, const IndexMask &mask) = nullptr; void (*relocate_construct_)(void *src, void *dst) = nullptr; + void (*relocate_construct_n_)(void *src, void *dst, int64_t n) = nullptr; void (*relocate_construct_indices_)(void *src, void *dst, const IndexMask &mask) = nullptr; + void (*fill_assign_n_)(const void *value, void *dst, int64_t n) = nullptr; void (*fill_assign_indices_)(const void *value, void *dst, const IndexMask &mask) = nullptr; + void (*fill_construct_n_)(const void *value, void *dst, int64_t n) = nullptr; void (*fill_construct_indices_)(const void *value, void *dst, const IndexMask &mask) = nullptr; void (*print_)(const void *value, std::stringstream &ss) = nullptr; @@ -494,7 +505,7 @@ inline void CPPType::default_construct(void *ptr) const inline void CPPType::default_construct_n(void *ptr, int64_t n) const { - this->default_construct_indices(ptr, IndexMask(n)); + default_construct_n_(ptr, n); } inline void CPPType::default_construct_indices(void *ptr, const IndexMask &mask) const @@ -509,7 +520,7 @@ inline void CPPType::value_initialize(void *ptr) const inline void CPPType::value_initialize_n(void *ptr, int64_t n) const { - this->value_initialize_indices(ptr, IndexMask(n)); + value_initialize_n_(ptr, n); } inline void CPPType::value_initialize_indices(void *ptr, const IndexMask &mask) const @@ -524,7 +535,7 @@ inline void CPPType::destruct(void *ptr) const inline void CPPType::destruct_n(void *ptr, int64_t n) const { - this->destruct_indices(ptr, IndexMask(n)); + destruct_n_(ptr, n); } inline void CPPType::destruct_indices(void *ptr, const IndexMask &mask) const @@ -539,7 +550,7 @@ inline void CPPType::copy_assign(const void *src, void *dst) const inline void CPPType::copy_assign_n(const void *src, void *dst, int64_t n) const { - this->copy_assign_indices(src, dst, IndexMask(n)); + copy_assign_n_(src, dst, n); } inline void CPPType::copy_assign_indices(const void *src, void *dst, const IndexMask &mask) const @@ -561,7 +572,7 @@ inline void CPPType::copy_construct(const void *src, void *dst) const inline void CPPType::copy_construct_n(const void *src, void *dst, int64_t n) const { - this->copy_construct_indices(src, dst, IndexMask(n)); + copy_construct_n_(src, dst, n); } inline void CPPType::copy_construct_indices(const void *src, @@ -585,7 +596,7 @@ inline void CPPType::move_assign(void *src, void *dst) const inline void CPPType::move_assign_n(void *src, void *dst, int64_t n) const { - this->move_assign_indices(src, dst, IndexMask(n)); + move_assign_n_(src, dst, n); } inline void CPPType::move_assign_indices(void *src, void *dst, const IndexMask &mask) const @@ -600,7 +611,7 @@ inline void CPPType::move_construct(void *src, void *dst) const inline void CPPType::move_construct_n(void *src, void *dst, int64_t n) const { - this->move_construct_indices(src, dst, IndexMask(n)); + move_construct_n_(src, dst, n); } inline void CPPType::move_construct_indices(void *src, void *dst, const IndexMask &mask) const @@ -615,7 +626,7 @@ inline void CPPType::relocate_assign(void *src, void *dst) const inline void CPPType::relocate_assign_n(void *src, void *dst, int64_t n) const { - this->relocate_assign_indices(src, dst, IndexMask(n)); + relocate_assign_n_(src, dst, n); } inline void CPPType::relocate_assign_indices(void *src, void *dst, const IndexMask &mask) const @@ -630,7 +641,7 @@ inline void CPPType::relocate_construct(void *src, void *dst) const inline void CPPType::relocate_construct_n(void *src, void *dst, int64_t n) const { - this->relocate_construct_indices(src, dst, IndexMask(n)); + relocate_construct_n_(src, dst, n); } inline void CPPType::relocate_construct_indices(void *src, void *dst, const IndexMask &mask) const @@ -640,7 +651,7 @@ inline void CPPType::relocate_construct_indices(void *src, void *dst, const Inde inline void CPPType::fill_assign_n(const void *value, void *dst, int64_t n) const { - this->fill_assign_indices(value, dst, IndexMask(n)); + fill_assign_n_(value, dst, n); } inline void CPPType::fill_assign_indices(const void *value, void *dst, const IndexMask &mask) const @@ -650,7 +661,7 @@ inline void CPPType::fill_assign_indices(const void *value, void *dst, const Ind inline void CPPType::fill_construct_n(const void *value, void *dst, int64_t n) const { - this->fill_construct_indices(value, dst, IndexMask(n)); + fill_construct_n_(value, dst, n); } inline void CPPType::fill_construct_indices(const void *value, diff --git a/source/blender/blenlib/BLI_cpp_type_make.hh b/source/blender/blenlib/BLI_cpp_type_make.hh index e7ef72ca990..7e8a5b9b24e 100644 --- a/source/blender/blenlib/BLI_cpp_type_make.hh +++ b/source/blender/blenlib/BLI_cpp_type_make.hh @@ -8,10 +8,12 @@ * \ingroup bli */ -#include "BLI_cpp_type.hh" -#include "BLI_utildefines.h" #include +#include "BLI_cpp_type.hh" +#include "BLI_index_mask.hh" +#include "BLI_utildefines.h" + namespace blender::cpp_type_util { template inline bool pointer_has_valid_alignment(const void *ptr) @@ -37,18 +39,25 @@ template void default_construct_indices_cb(void *ptr, const IndexMas } mask.foreach_index_optimized([&](int64_t i) { new (static_cast(ptr) + i) T; }); } +template void default_construct_n_cb(void *ptr, const int64_t n) +{ + default_construct_indices_cb(ptr, IndexMask(n)); +} template void value_initialize_cb(void *ptr) { BLI_assert(pointer_can_point_to_instance(ptr)); new (ptr) T(); } - template void value_initialize_indices_cb(void *ptr, const IndexMask &mask) { BLI_assert(mask.size() == 0 || pointer_can_point_to_instance(ptr)); mask.foreach_index_optimized([&](int64_t i) { new (static_cast(ptr) + i) T(); }); } +template void value_initialize_n_cb(void *ptr, const int64_t n) +{ + value_initialize_indices_cb(ptr, IndexMask(n)); +} template void destruct_cb(void *ptr) { @@ -64,6 +73,10 @@ template void destruct_indices_cb(void *ptr, const IndexMask &mask) T *ptr_ = static_cast(ptr); mask.foreach_index_optimized([&](int64_t i) { ptr_[i].~T(); }); } +template void destruct_n_cb(void *ptr, const int64_t n) +{ + destruct_indices_cb(ptr, IndexMask(n)); +} template void copy_assign_cb(const void *src, void *dst) { @@ -81,6 +94,10 @@ template void copy_assign_indices_cb(const void *src, void *dst, con mask.foreach_index_optimized([&](int64_t i) { dst_[i] = src_[i]; }); } +template void copy_assign_n_cb(const void *src, void *dst, const int64_t n) +{ + copy_assign_indices_cb(src, dst, IndexMask(n)); +} template void copy_assign_compressed_cb(const void *src, void *dst, const IndexMask &mask) { @@ -112,6 +129,10 @@ void copy_construct_indices_cb(const void *src, void *dst, const IndexMask &mask mask.foreach_index_optimized([&](int64_t i) { new (dst_ + i) T(src_[i]); }); } +template void copy_construct_n_cb(const void *src, void *dst, const int64_t n) +{ + copy_construct_indices_cb(src, dst, IndexMask(n)); +} template void copy_construct_compressed_cb(const void *src, void *dst, const IndexMask &mask) { @@ -141,6 +162,10 @@ template void move_assign_indices_cb(void *src, void *dst, const Ind mask.foreach_index_optimized([&](int64_t i) { dst_[i] = std::move(src_[i]); }); } +template void move_assign_n_cb(void *src, void *dst, const int64_t n) +{ + move_assign_indices_cb(src, dst, IndexMask(n)); +} template void move_construct_cb(void *src, void *dst) { @@ -160,6 +185,10 @@ template void move_construct_indices_cb(void *src, void *dst, const mask.foreach_index_optimized([&](int64_t i) { new (dst_ + i) T(std::move(src_[i])); }); } +template void move_construct_n_cb(void *src, void *dst, const int64_t n) +{ + move_construct_indices_cb(src, dst, IndexMask(n)); +} template void relocate_assign_cb(void *src, void *dst) { @@ -185,6 +214,10 @@ template void relocate_assign_indices_cb(void *src, void *dst, const src_[i].~T(); }); } +template void relocate_assign_n_cb(void *src, void *dst, const int64_t n) +{ + relocate_assign_indices_cb(src, dst, IndexMask(n)); +} template void relocate_construct_cb(void *src, void *dst) { @@ -211,6 +244,10 @@ void relocate_construct_indices_cb(void *src, void *dst, const IndexMask &mask) src_[i].~T(); }); } +template void relocate_construct_n_cb(void *src, void *dst, const int64_t n) +{ + relocate_construct_indices_cb(src, dst, IndexMask(n)); +} template void fill_assign_indices_cb(const void *value, void *dst, const IndexMask &mask) @@ -222,6 +259,10 @@ void fill_assign_indices_cb(const void *value, void *dst, const IndexMask &mask) mask.foreach_index_optimized([&](int64_t i) { dst_[i] = value_; }); } +template void fill_assign_n_cb(const void *value, void *dst, const int64_t n) +{ + fill_assign_indices_cb(value, dst, IndexMask(n)); +} template void fill_construct_cb(const void *value, void *dst, int64_t n) { @@ -240,6 +281,10 @@ void fill_construct_indices_cb(const void *value, void *dst, const IndexMask &ma mask.foreach_index_optimized([&](int64_t i) { new (dst_ + i) T(value_); }); } +template void fill_construct_n_cb(const void *value, void *dst, const int64_t n) +{ + fill_construct_indices_cb(value, dst, IndexMask(n)); +} template void print_cb(const void *value, std::stringstream &ss) { @@ -281,8 +326,10 @@ CPPType::CPPType(TypeTag /*type*/, this->is_trivially_destructible = std::is_trivially_destructible_v; if constexpr (std::is_default_constructible_v) { default_construct_ = default_construct_cb; + default_construct_n_ = default_construct_n_cb; default_construct_indices_ = default_construct_indices_cb; value_initialize_ = value_initialize_cb; + value_initialize_n_ = value_initialize_n_cb; value_initialize_indices_ = value_initialize_indices_cb; if constexpr (bool(Flags & CPPTypeFlags::IdentityDefaultValue)) { static const T default_value = T::identity(); @@ -295,21 +342,25 @@ CPPType::CPPType(TypeTag /*type*/, } if constexpr (std::is_destructible_v) { destruct_ = destruct_cb; + destruct_n_ = destruct_n_cb; destruct_indices_ = destruct_indices_cb; } if constexpr (std::is_copy_assignable_v) { copy_assign_ = copy_assign_cb; + copy_assign_n_ = copy_assign_n_cb; copy_assign_indices_ = copy_assign_indices_cb; copy_assign_compressed_ = copy_assign_compressed_cb; } if constexpr (std::is_copy_constructible_v) { if constexpr (std::is_trivially_copy_constructible_v) { copy_construct_ = copy_assign_; + copy_construct_n_ = copy_assign_n_; copy_construct_indices_ = copy_assign_indices_; copy_construct_compressed_ = copy_assign_compressed_; } else { copy_construct_ = copy_construct_cb; + copy_construct_n_ = copy_construct_n_cb; copy_construct_indices_ = copy_construct_indices_cb; copy_construct_compressed_ = copy_construct_compressed_cb; } @@ -319,51 +370,62 @@ CPPType::CPPType(TypeTag /*type*/, /* This casts away the const from the src pointer. This is fine for trivial types as moving * them does not change the original value. */ move_assign_ = reinterpret_cast(copy_assign_); + move_assign_n_ = reinterpret_cast(copy_assign_n_); move_assign_indices_ = reinterpret_cast( copy_assign_indices_); } else { move_assign_ = move_assign_cb; + move_assign_n_ = move_assign_n_cb; move_assign_indices_ = move_assign_indices_cb; } } if constexpr (std::is_move_constructible_v) { if constexpr (std::is_trivially_move_constructible_v) { move_construct_ = move_assign_; + move_construct_n_ = move_assign_n_; move_construct_indices_ = move_assign_indices_; } else { move_construct_ = move_construct_cb; + move_construct_n_ = move_construct_n_cb; move_construct_indices_ = move_construct_indices_cb; } } if constexpr (std::is_destructible_v) { if constexpr (std::is_trivially_move_assignable_v && std::is_trivially_destructible_v) { relocate_assign_ = move_assign_; + relocate_assign_n_ = move_assign_n_; relocate_assign_indices_ = move_assign_indices_; relocate_construct_ = move_assign_; + relocate_construct_n_ = move_assign_n_; relocate_construct_indices_ = move_assign_indices_; } else { if constexpr (std::is_move_assignable_v) { relocate_assign_ = relocate_assign_cb; + relocate_assign_n_ = relocate_assign_n_cb; relocate_assign_indices_ = relocate_assign_indices_cb; } if constexpr (std::is_move_constructible_v) { relocate_construct_ = relocate_construct_cb; + relocate_construct_n_ = relocate_construct_n_cb; relocate_construct_indices_ = relocate_construct_indices_cb; } } } if constexpr (std::is_copy_assignable_v) { + fill_assign_n_ = fill_assign_n_cb; fill_assign_indices_ = fill_assign_indices_cb; } if constexpr (std::is_copy_constructible_v) { if constexpr (std::is_trivially_constructible_v) { + fill_construct_n_ = fill_assign_n_; fill_construct_indices_ = fill_assign_indices_; } else { + fill_construct_n_ = fill_construct_n_cb; fill_construct_indices_ = fill_construct_indices_cb; } } diff --git a/source/blender/nodes/NOD_geometry_nodes_execute.hh b/source/blender/nodes/NOD_geometry_nodes_execute.hh index db13099ce0f..c9431319598 100644 --- a/source/blender/nodes/NOD_geometry_nodes_execute.hh +++ b/source/blender/nodes/NOD_geometry_nodes_execute.hh @@ -7,6 +7,7 @@ #include "BLI_compute_context.hh" #include "BLI_generic_pointer.hh" #include "BLI_resource_scope.hh" +#include "BLI_vector_set.hh" #include "DNA_node_types.h"