diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-07 11:02:34 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-07 11:02:34 +0300 |
commit | 384a02a214cad88f3180deee36b22529c213ddaf (patch) | |
tree | bf81dfad32c961f6be6ba8b529144bfb180fba69 /source/blender/blenlib/BLI_generic_virtual_array.hh | |
parent | 2aff04917f9e0420174e01dff0936d5237a7bbbd (diff) |
BLI: add missing materialize methods for virtual arrays
This does two things:
* Introduce new `materialize_compressed` methods. Those are used
when the dst array should not have any gaps.
* Add materialize methods in various classes where they were missing
(and therefore caused overhead, because slower fallbacks had to be used).
Diffstat (limited to 'source/blender/blenlib/BLI_generic_virtual_array.hh')
-rw-r--r-- | source/blender/blenlib/BLI_generic_virtual_array.hh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_generic_virtual_array.hh b/source/blender/blenlib/BLI_generic_virtual_array.hh index f4c9e745cf9..4aed1caf796 100644 --- a/source/blender/blenlib/BLI_generic_virtual_array.hh +++ b/source/blender/blenlib/BLI_generic_virtual_array.hh @@ -51,6 +51,9 @@ class GVArrayImpl { virtual void materialize(const IndexMask mask, void *dst) const; virtual void materialize_to_uninitialized(const IndexMask mask, void *dst) const; + virtual void materialize_compressed(IndexMask mask, void *dst) const; + virtual void materialize_compressed_to_uninitialized(IndexMask mask, void *dst) const; + virtual bool try_assign_VArray(void *varray) const; virtual bool may_have_ownership() const; }; @@ -133,6 +136,9 @@ class GVArrayCommon { void materialize_to_uninitialized(void *dst) const; void materialize_to_uninitialized(const IndexMask mask, void *dst) const; + void materialize_compressed(IndexMask mask, void *dst) const; + void materialize_compressed_to_uninitialized(IndexMask mask, void *dst) const; + /** * Returns true when the virtual array is stored as a span internally. */ @@ -336,6 +342,16 @@ template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl { varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size())); } + void materialize_compressed(const IndexMask mask, void *dst) const override + { + varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size())); + } + + void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override + { + varray_.materialize_compressed_to_uninitialized(mask, MutableSpan((T *)dst, mask.size())); + } + bool try_assign_VArray(void *varray) const override { *(VArray<T> *)varray = varray_; @@ -400,6 +416,27 @@ template<typename T> class VArrayImpl_For_GVArray : public VArrayImpl<T> { { return varray_.may_have_ownership(); } + + void materialize(IndexMask mask, MutableSpan<T> r_span) const override + { + varray_.materialize(mask, r_span.data()); + } + + void materialize_to_uninitialized(IndexMask mask, MutableSpan<T> r_span) const override + { + varray_.materialize_to_uninitialized(mask, r_span.data()); + } + + void materialize_compressed(IndexMask mask, MutableSpan<T> r_span) const override + { + varray_.materialize_compressed(mask, r_span.data()); + } + + void materialize_compressed_to_uninitialized(IndexMask mask, + MutableSpan<T> r_span) const override + { + varray_.materialize_compressed_to_uninitialized(mask, r_span.data()); + } }; /* Used to convert any typed virtual mutable array into a generic one. */ @@ -479,6 +516,16 @@ template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutab varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size())); } + void materialize_compressed(const IndexMask mask, void *dst) const override + { + varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size())); + } + + void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override + { + varray_.materialize_compressed_to_uninitialized(mask, MutableSpan((T *)dst, mask.size())); + } + bool try_assign_VArray(void *varray) const override { *(VArray<T> *)varray = varray_; @@ -561,6 +608,27 @@ template<typename T> class VMutableArrayImpl_For_GVMutableArray : public VMutabl { return varray_.may_have_ownership(); } + + void materialize(IndexMask mask, MutableSpan<T> r_span) const override + { + varray_.materialize(mask, r_span.data()); + } + + void materialize_to_uninitialized(IndexMask mask, MutableSpan<T> r_span) const override + { + varray_.materialize_to_uninitialized(mask, r_span.data()); + } + + void materialize_compressed(IndexMask mask, MutableSpan<T> r_span) const override + { + varray_.materialize_compressed(mask, r_span.data()); + } + + void materialize_compressed_to_uninitialized(IndexMask mask, + MutableSpan<T> r_span) const override + { + varray_.materialize_compressed_to_uninitialized(mask, r_span.data()); + } }; /** \} */ @@ -590,6 +658,13 @@ class GVArrayImpl_For_GSpan : public GVMutableArrayImpl { bool is_span() const override; GSpan get_internal_span() const override; + + virtual void materialize(const IndexMask mask, void *dst) const override; + virtual void materialize_to_uninitialized(const IndexMask mask, void *dst) const override; + + virtual void materialize_compressed(const IndexMask mask, void *dst) const override; + virtual void materialize_compressed_to_uninitialized(const IndexMask mask, + void *dst) const override; }; /** \} */ |