diff options
author | Jacques Lucke <jacques@blender.org> | 2021-05-10 11:28:24 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-05-10 11:28:24 +0300 |
commit | 0061150e4c90de474a38bd2eeeea7fe0d12de353 (patch) | |
tree | 64c8daef509e1b7801f110eaab8f61e0d4ec1887 /source/blender | |
parent | f2370bb22d7fd9b03a46c2df1f0eb9c2cd6676b2 (diff) |
Functions: support materialize virtual array to initialized span
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/functions/FN_generic_virtual_array.hh | 9 | ||||
-rw-r--r-- | source/blender/functions/intern/generic_virtual_array.cc | 18 |
2 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh index 2e91479dd30..aca752583c4 100644 --- a/source/blender/functions/FN_generic_virtual_array.hh +++ b/source/blender/functions/FN_generic_virtual_array.hh @@ -135,6 +135,9 @@ class GVArray { this->get_internal_single(r_value); } + void materialize(void *dst) const; + void materialize(const IndexMask mask, void *dst) const; + void materialize_to_uninitialized(void *dst) const; void materialize_to_uninitialized(const IndexMask mask, void *dst) const; @@ -162,6 +165,7 @@ class GVArray { virtual bool is_single_impl() const; virtual void get_internal_single_impl(void *UNUSED(r_value)) const; + virtual void materialize_impl(const IndexMask mask, void *dst) const; virtual void materialize_to_uninitialized_impl(const IndexMask mask, void *dst) const; virtual const void *try_get_internal_varray_impl() const; @@ -370,6 +374,11 @@ template<typename T> class GVArray_For_VArray : public GVArray { *(T *)r_value = varray_->get_internal_single(); } + void materialize_impl(const IndexMask mask, void *dst) const override + { + varray_->materialize(mask, MutableSpan((T *)dst, mask.min_array_size())); + } + void materialize_to_uninitialized_impl(const IndexMask mask, void *dst) const override { varray_->materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size())); diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc index ca2bd0f806f..a835e7a54a9 100644 --- a/source/blender/functions/intern/generic_virtual_array.cc +++ b/source/blender/functions/intern/generic_virtual_array.cc @@ -53,6 +53,24 @@ class GVArray_For_ShallowCopy : public GVArray { * GVArray. */ +void GVArray::materialize(void *dst) const +{ + this->materialize(IndexMask(size_), dst); +} + +void GVArray::materialize(const IndexMask mask, void *dst) const +{ + this->materialize_impl(mask, dst); +} + +void GVArray::materialize_impl(const IndexMask mask, void *dst) const +{ + for (const int64_t i : mask) { + void *elem_dst = POINTER_OFFSET(dst, type_->size() * i); + this->get(i, elem_dst); + } +} + void GVArray::materialize_to_uninitialized(void *dst) const { this->materialize_to_uninitialized(IndexMask(size_), dst); |