Blender  V3.3
BLI_generic_virtual_array.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
12 #include "BLI_generic_array.hh"
13 #include "BLI_generic_span.hh"
14 #include "BLI_timeit.hh"
15 #include "BLI_virtual_array.hh"
16 
17 namespace blender {
18 
19 /* -------------------------------------------------------------------- */
23 class GVArray;
24 class GVArrayImpl;
25 class GVMutableArray;
26 class GVMutableArrayImpl;
27 
28 /* A generically typed version of #VArrayImpl. */
29 class GVArrayImpl {
30  protected:
31  const CPPType *type_;
33 
34  public:
36  virtual ~GVArrayImpl() = default;
37 
38  const CPPType &type() const;
39 
40  int64_t size() const;
41 
42  virtual void get(int64_t index, void *r_value) const;
43  virtual void get_to_uninitialized(int64_t index, void *r_value) const = 0;
44 
45  virtual CommonVArrayInfo common_info() const;
46 
47  virtual void materialize(const IndexMask mask, void *dst) const;
48  virtual void materialize_to_uninitialized(const IndexMask mask, void *dst) const;
49 
50  virtual void materialize_compressed(IndexMask mask, void *dst) const;
51  virtual void materialize_compressed_to_uninitialized(IndexMask mask, void *dst) const;
52 
53  virtual bool try_assign_VArray(void *varray) const;
54 };
55 
56 /* A generic version of #VMutableArrayImpl. */
58  public:
60  {
61  }
62 
63  virtual void set_by_copy(int64_t index, const void *value);
64  virtual void set_by_relocate(int64_t index, void *value);
65  virtual void set_by_move(int64_t index, void *value) = 0;
66 
67  virtual void set_all(const void *src);
68 
69  virtual bool try_assign_VMutableArray(void *varray) const;
70 };
71 
74 /* -------------------------------------------------------------------- */
78 namespace detail {
80  const GVArrayImpl *(*get_varray)(const void *buffer) =
81  [](const void *UNUSED(buffer)) -> const GVArrayImpl * { return nullptr; };
82 
83  template<typename StorageT> static constexpr GVArrayAnyExtraInfo get();
84 };
85 } // namespace detail
86 
87 class GVMutableArray;
88 
94  protected:
100 
101  const GVArrayImpl *impl_ = nullptr;
103 
104  protected:
105  GVArrayCommon() = default;
106  GVArrayCommon(const GVArrayCommon &other);
107  GVArrayCommon(GVArrayCommon &&other) noexcept;
109  GVArrayCommon(std::shared_ptr<const GVArrayImpl> impl);
111 
112  template<typename ImplT, typename... Args> void emplace(Args &&...args);
113 
114  void copy_from(const GVArrayCommon &other);
115  void move_from(GVArrayCommon &&other) noexcept;
116 
117  const GVArrayImpl *impl_from_storage() const;
118 
119  public:
120  const CPPType &type() const;
121  operator bool() const;
122 
123  int64_t size() const;
124  bool is_empty() const;
125  IndexRange index_range() const;
126 
127  template<typename T> bool try_assign_VArray(VArray<T> &varray) const;
128  bool may_have_ownership() const;
129 
130  void materialize(void *dst) const;
131  void materialize(const IndexMask mask, void *dst) const;
132 
133  void materialize_to_uninitialized(void *dst) const;
134  void materialize_to_uninitialized(const IndexMask mask, void *dst) const;
135 
136  void materialize_compressed(IndexMask mask, void *dst) const;
138 
140 
144  bool is_span() const;
149  GSpan get_internal_span() const;
150 
154  bool is_single() const;
160  void get_internal_single(void *r_value) const;
164  void get_internal_single_to_uninitialized(void *r_value) const;
165 
166  void get(int64_t index, void *r_value) const;
171  template<typename T> T get(int64_t index) const;
172  void get_to_uninitialized(int64_t index, void *r_value) const;
173 };
174 
176 class GVArray : public GVArrayCommon {
177  private:
178  friend GVMutableArray;
179 
180  public:
181  GVArray() = default;
182 
183  GVArray(const GVArray &other);
184  GVArray(GVArray &&other) noexcept;
185  GVArray(const GVArrayImpl *impl);
186  GVArray(std::shared_ptr<const GVArrayImpl> impl);
187 
188  GVArray(varray_tag::span /* tag */, GSpan span);
189  GVArray(varray_tag::single_ref /* tag */, const CPPType &type, int64_t size, const void *value);
190  GVArray(varray_tag::single /* tag */, const CPPType &type, int64_t size, const void *value);
191 
192  template<typename T> GVArray(const VArray<T> &varray);
193  template<typename T> VArray<T> typed() const;
194 
195  template<typename ImplT, typename... Args> static GVArray For(Args &&...args);
196 
197  static GVArray ForSingle(const CPPType &type, int64_t size, const void *value);
198  static GVArray ForSingleRef(const CPPType &type, int64_t size, const void *value);
200  static GVArray ForSpan(GSpan span);
202  static GVArray ForEmpty(const CPPType &type);
203 
204  GVArray slice(IndexRange slice) const;
205 
206  GVArray &operator=(const GVArray &other);
207  GVArray &operator=(GVArray &&other) noexcept;
208 
210  {
211  return impl_;
212  }
213 };
214 
217  public:
218  GVMutableArray() = default;
220  GVMutableArray(GVMutableArray &&other) noexcept;
222  GVMutableArray(std::shared_ptr<GVMutableArrayImpl> impl);
223 
224  template<typename T> GVMutableArray(const VMutableArray<T> &varray);
225  template<typename T> VMutableArray<T> typed() const;
226 
227  template<typename ImplT, typename... Args> static GVMutableArray For(Args &&...args);
228 
229  static GVMutableArray ForSpan(GMutableSpan span);
230 
231  operator GVArray() const &;
232  operator GVArray() &&noexcept;
233 
234  GVMutableArray &operator=(const GVMutableArray &other);
235  GVMutableArray &operator=(GVMutableArray &&other) noexcept;
236 
238 
239  template<typename T> bool try_assign_VMutableArray(VMutableArray<T> &varray) const;
240 
241  void set_by_copy(int64_t index, const void *value);
242  void set_by_move(int64_t index, void *value);
243  void set_by_relocate(int64_t index, void *value);
244 
245  void fill(const void *value);
249  void set_all(const void *src);
250 
252 
253  private:
254  GVMutableArrayImpl *get_impl() const;
255 };
256 
259 /* -------------------------------------------------------------------- */
263 /* A generic version of VArraySpan. */
264 class GVArraySpan : public GSpan {
265  private:
266  GVArray varray_;
267  void *owned_data_ = nullptr;
268 
269  public:
271  GVArraySpan(GVArray varray);
272  GVArraySpan(GVArraySpan &&other);
273  ~GVArraySpan();
275 };
276 
277 /* A generic version of MutableVArraySpan. */
279  private:
280  GVMutableArray varray_;
281  void *owned_data_ = nullptr;
282  bool save_has_been_called_ = false;
283  bool show_not_saved_warning_ = true;
284 
285  public:
287  GMutableVArraySpan(GVMutableArray varray, bool copy_values_to_span = true);
291 
292  const GVMutableArray &varray() const;
293 
294  void save();
295  void disable_not_applied_warning();
296 };
297 
300 /* -------------------------------------------------------------------- */
304 /* Used to convert a typed virtual array into a generic one. */
305 template<typename T> class GVArrayImpl_For_VArray : public GVArrayImpl {
306  protected:
308 
309  public:
311  : GVArrayImpl(CPPType::get<T>(), varray.size()), varray_(std::move(varray))
312  {
313  }
314 
315  protected:
316  void get(const int64_t index, void *r_value) const override
317  {
318  *(T *)r_value = varray_[index];
319  }
320 
321  void get_to_uninitialized(const int64_t index, void *r_value) const override
322  {
323  new (r_value) T(varray_[index]);
324  }
325 
326  void materialize(const IndexMask mask, void *dst) const override
327  {
328  varray_.materialize(mask, MutableSpan((T *)dst, mask.min_array_size()));
329  }
330 
331  void materialize_to_uninitialized(const IndexMask mask, void *dst) const override
332  {
333  varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size()));
334  }
335 
336  void materialize_compressed(const IndexMask mask, void *dst) const override
337  {
338  varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size()));
339  }
340 
341  void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override
342  {
344  }
345 
346  bool try_assign_VArray(void *varray) const override
347  {
348  *(VArray<T> *)varray = varray_;
349  return true;
350  }
351 
352  CommonVArrayInfo common_info() const override
353  {
354  return varray_.common_info();
355  }
356 };
357 
358 /* Used to convert any generic virtual array into a typed one. */
359 template<typename T> class VArrayImpl_For_GVArray : public VArrayImpl<T> {
360  protected:
362 
363  public:
364  VArrayImpl_For_GVArray(GVArray varray) : VArrayImpl<T>(varray.size()), varray_(std::move(varray))
365  {
366  BLI_assert(varray_);
367  BLI_assert(varray_.type().template is<T>());
368  }
369 
370  protected:
371  T get(const int64_t index) const override
372  {
373  T value;
374  varray_.get(index, &value);
375  return value;
376  }
377 
378  CommonVArrayInfo common_info() const override
379  {
380  return varray_.common_info();
381  }
382 
383  bool try_assign_GVArray(GVArray &varray) const override
384  {
385  varray = varray_;
386  return true;
387  }
388 
389  void materialize(IndexMask mask, MutableSpan<T> r_span) const override
390  {
391  varray_.materialize(mask, r_span.data());
392  }
393 
395  {
396  varray_.materialize_to_uninitialized(mask, r_span.data());
397  }
398 
400  {
401  varray_.materialize_compressed(mask, r_span.data());
402  }
403 
405  MutableSpan<T> r_span) const override
406  {
408  }
409 };
410 
411 /* Used to convert any typed virtual mutable array into a generic one. */
412 template<typename T> class GVMutableArrayImpl_For_VMutableArray : public GVMutableArrayImpl {
413  protected:
415 
416  public:
418  : GVMutableArrayImpl(CPPType::get<T>(), varray.size()), varray_(std::move(varray))
419  {
420  }
421 
422  protected:
423  void get(const int64_t index, void *r_value) const override
424  {
425  *(T *)r_value = varray_[index];
426  }
427 
428  void get_to_uninitialized(const int64_t index, void *r_value) const override
429  {
430  new (r_value) T(varray_[index]);
431  }
432 
433  CommonVArrayInfo common_info() const override
434  {
435  return varray_.common_info();
436  }
437 
438  void set_by_copy(const int64_t index, const void *value) override
439  {
440  const T &value_ = *(const T *)value;
441  varray_.set(index, value_);
442  }
443 
444  void set_by_relocate(const int64_t index, void *value) override
445  {
446  T &value_ = *(T *)value;
447  varray_.set(index, std::move(value_));
448  value_.~T();
449  }
450 
451  void set_by_move(const int64_t index, void *value) override
452  {
453  T &value_ = *(T *)value;
454  varray_.set(index, std::move(value_));
455  }
456 
457  void set_all(const void *src) override
458  {
459  varray_.set_all(Span((T *)src, size_));
460  }
461 
462  void materialize(const IndexMask mask, void *dst) const override
463  {
464  varray_.materialize(mask, MutableSpan((T *)dst, mask.min_array_size()));
465  }
466 
467  void materialize_to_uninitialized(const IndexMask mask, void *dst) const override
468  {
469  varray_.materialize_to_uninitialized(mask, MutableSpan((T *)dst, mask.min_array_size()));
470  }
471 
472  void materialize_compressed(const IndexMask mask, void *dst) const override
473  {
474  varray_.materialize_compressed(mask, MutableSpan((T *)dst, mask.size()));
475  }
476 
477  void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override
478  {
480  }
481 
482  bool try_assign_VArray(void *varray) const override
483  {
484  *(VArray<T> *)varray = varray_;
485  return true;
486  }
487 
488  bool try_assign_VMutableArray(void *varray) const override
489  {
490  *(VMutableArray<T> *)varray = varray_;
491  return true;
492  }
493 };
494 
495 /* Used to convert an generic mutable virtual array into a typed one. */
496 template<typename T> class VMutableArrayImpl_For_GVMutableArray : public VMutableArrayImpl<T> {
497  protected:
499 
500  public:
502  : VMutableArrayImpl<T>(varray.size()), varray_(varray)
503  {
504  BLI_assert(varray_);
505  BLI_assert(varray_.type().template is<T>());
506  }
507 
508  private:
509  T get(const int64_t index) const override
510  {
511  T value;
512  varray_.get(index, &value);
513  return value;
514  }
515 
516  void set(const int64_t index, T value) override
517  {
518  varray_.set_by_relocate(index, &value);
519  }
520 
521  CommonVArrayInfo common_info() const override
522  {
523  return varray_.common_info();
524  }
525 
526  bool try_assign_GVArray(GVArray &varray) const override
527  {
528  varray = varray_;
529  return true;
530  }
531 
532  bool try_assign_GVMutableArray(GVMutableArray &varray) const override
533  {
534  varray = varray_;
535  return true;
536  }
537 
538  void materialize(IndexMask mask, MutableSpan<T> r_span) const override
539  {
540  varray_.materialize(mask, r_span.data());
541  }
542 
543  void materialize_to_uninitialized(IndexMask mask, MutableSpan<T> r_span) const override
544  {
545  varray_.materialize_to_uninitialized(mask, r_span.data());
546  }
547 
548  void materialize_compressed(IndexMask mask, MutableSpan<T> r_span) const override
549  {
550  varray_.materialize_compressed(mask, r_span.data());
551  }
552 
554  MutableSpan<T> r_span) const override
555  {
556  varray_.materialize_compressed_to_uninitialized(mask, r_span.data());
557  }
558 };
559 
562 /* -------------------------------------------------------------------- */
567  protected:
568  void *data_ = nullptr;
570 
571  public:
573  : GVMutableArrayImpl(span.type(), span.size()),
574  data_(span.data()),
575  element_size_(span.type().size())
576  {
577  }
578 
579  protected:
581  : GVMutableArrayImpl(type, size), element_size_(type.size())
582  {
583  }
584 
585  public:
586  void get(int64_t index, void *r_value) const override;
587  void get_to_uninitialized(int64_t index, void *r_value) const override;
588 
589  void set_by_copy(int64_t index, const void *value) override;
590  void set_by_move(int64_t index, void *value) override;
591  void set_by_relocate(int64_t index, void *value) override;
592 
593  CommonVArrayInfo common_info() const override;
594 
595  virtual void materialize(const IndexMask mask, void *dst) const override;
596  virtual void materialize_to_uninitialized(const IndexMask mask, void *dst) const override;
597 
598  virtual void materialize_compressed(const IndexMask mask, void *dst) const override;
600  void *dst) const override;
601 };
602 
604  public:
606 
607  private:
608  CommonVArrayInfo common_info() const override;
609 };
610 
611 template<> inline constexpr bool is_trivial_extended_v<GVArrayImpl_For_GSpan_final> = true;
612 
615 /* -------------------------------------------------------------------- */
620  protected:
621  const void *value_ = nullptr;
622 
623  public:
624  GVArrayImpl_For_SingleValueRef(const CPPType &type, const int64_t size, const void *value)
625  : GVArrayImpl(type, size), value_(value)
626  {
627  }
628 
629  protected:
631  {
632  }
633 
634  void get(const int64_t index, void *r_value) const override;
635  void get_to_uninitialized(const int64_t index, void *r_value) const override;
636  CommonVArrayInfo common_info() const override;
637  void materialize(const IndexMask mask, void *dst) const override;
638  void materialize_to_uninitialized(const IndexMask mask, void *dst) const override;
639  void materialize_compressed(const IndexMask mask, void *dst) const override;
640  void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override;
641 };
642 
644  public:
646 
647  private:
648  CommonVArrayInfo common_info() const override;
649 };
650 
651 template<>
653 
656 /* -------------------------------------------------------------------- */
661  : type_(&type), size_(size)
662 {
663  BLI_assert(size_ >= 0);
664 }
665 
666 inline const CPPType &GVArrayImpl::type() const
667 {
668  return *type_;
669 }
670 
672 {
673  return size_;
674 }
675 
678 /* -------------------------------------------------------------------- */
682 inline void GVMutableArray::set_by_copy(const int64_t index, const void *value)
683 {
684  BLI_assert(index >= 0);
685  BLI_assert(index < this->size());
686  this->get_impl()->set_by_copy(index, value);
687 }
688 
689 inline void GVMutableArray::set_by_move(const int64_t index, void *value)
690 {
691  BLI_assert(index >= 0);
692  BLI_assert(index < this->size());
693  this->get_impl()->set_by_move(index, value);
694 }
695 
696 inline void GVMutableArray::set_by_relocate(const int64_t index, void *value)
697 {
698  BLI_assert(index >= 0);
699  BLI_assert(index < this->size());
700  this->get_impl()->set_by_relocate(index, value);
701 }
702 
703 template<typename T>
705 {
706  BLI_assert(impl_->type().is<T>());
707  return this->get_impl()->try_assign_VMutableArray(&varray);
708 }
709 
710 inline GVMutableArrayImpl *GVMutableArray::get_impl() const
711 {
712  return (GVMutableArrayImpl *)impl_;
713 }
714 
717 /* -------------------------------------------------------------------- */
721 template<typename ImplT, typename... Args> inline void GVArrayCommon::emplace(Args &&...args)
722 {
723  static_assert(std::is_base_of_v<GVArrayImpl, ImplT>);
724  if constexpr (std::is_copy_constructible_v<ImplT> && Storage::template is_inline_v<ImplT>) {
725  impl_ = &storage_.template emplace<ImplT>(std::forward<Args>(args)...);
726  }
727  else {
728  std::shared_ptr<const GVArrayImpl> ptr = std::make_shared<ImplT>(std::forward<Args>(args)...);
729  impl_ = &*ptr;
730  storage_ = std::move(ptr);
731  }
732 }
733 
734 /* Copies the value at the given index into the provided storage. The `r_value` pointer is
735  * expected to point to initialized memory. */
736 inline void GVArrayCommon::get(const int64_t index, void *r_value) const
737 {
738  BLI_assert(index >= 0);
739  BLI_assert(index < this->size());
740  impl_->get(index, r_value);
741 }
742 
743 template<typename T> inline T GVArrayCommon::get(const int64_t index) const
744 {
745  BLI_assert(index >= 0);
746  BLI_assert(index < this->size());
747  BLI_assert(this->type().is<T>());
748  T value{};
749  impl_->get(index, &value);
750  return value;
751 }
752 
753 /* Same as `get`, but `r_value` is expected to point to uninitialized memory. */
754 inline void GVArrayCommon::get_to_uninitialized(const int64_t index, void *r_value) const
755 {
756  BLI_assert(index >= 0);
757  BLI_assert(index < this->size());
758  impl_->get_to_uninitialized(index, r_value);
759 }
760 
761 template<typename T> inline bool GVArrayCommon::try_assign_VArray(VArray<T> &varray) const
762 {
763  BLI_assert(impl_->type().is<T>());
764  return impl_->try_assign_VArray(&varray);
765 }
766 
767 inline const CPPType &GVArrayCommon::type() const
768 {
769  return impl_->type();
770 }
771 
772 inline GVArrayCommon::operator bool() const
773 {
774  return impl_ != nullptr;
775 }
776 
778 {
779  return impl_->common_info();
780 }
781 
783 {
784  if (impl_ == nullptr) {
785  return 0;
786  }
787  return impl_->size();
788 }
789 
790 inline bool GVArrayCommon::is_empty() const
791 {
792  return this->size() == 0;
793 }
794 
797 /* -------------------------------------------------------------------- */
801 inline GVArray::GVArray(varray_tag::span /* tag */, const GSpan span)
802 {
803  /* Use const-cast because the underlying virtual array implementation is shared between const
804  * and non const data. */
805  GMutableSpan mutable_span{span.type(), const_cast<void *>(span.data()), span.size()};
806  this->emplace<GVArrayImpl_For_GSpan_final>(mutable_span);
807 }
808 
810  const CPPType &type,
811  const int64_t size,
812  const void *value)
813 {
814  this->emplace<GVArrayImpl_For_SingleValueRef_final>(type, size, value);
815 }
816 
817 namespace detail {
818 template<typename StorageT> constexpr GVArrayAnyExtraInfo GVArrayAnyExtraInfo::get()
819 {
820  static_assert(std::is_base_of_v<GVArrayImpl, StorageT> ||
821  is_same_any_v<StorageT, const GVArrayImpl *, std::shared_ptr<const GVArrayImpl>>);
822 
823  if constexpr (std::is_base_of_v<GVArrayImpl, StorageT>) {
824  return {[](const void *buffer) {
825  return static_cast<const GVArrayImpl *>((const StorageT *)buffer);
826  }};
827  }
828  else if constexpr (std::is_same_v<StorageT, const GVArrayImpl *>) {
829  return {[](const void *buffer) { return *(const StorageT *)buffer; }};
830  }
831  else if constexpr (std::is_same_v<StorageT, std::shared_ptr<const GVArrayImpl>>) {
832  return {[](const void *buffer) { return ((const StorageT *)buffer)->get(); }};
833  }
834  else {
836  return {};
837  }
838 }
839 } // namespace detail
840 
841 template<typename ImplT, typename... Args> inline GVArray GVArray::For(Args &&...args)
842 {
843  static_assert(std::is_base_of_v<GVArrayImpl, ImplT>);
844  GVArray varray;
845  varray.template emplace<ImplT>(std::forward<Args>(args)...);
846  return varray;
847 }
848 
849 template<typename T> inline GVArray::GVArray(const VArray<T> &varray)
850 {
851  if (!varray) {
852  return;
853  }
854  const CommonVArrayInfo info = varray.common_info();
855  if (info.type == CommonVArrayInfo::Type::Single) {
856  *this = GVArray::ForSingle(CPPType::get<T>(), varray.size(), info.data);
857  return;
858  }
859  /* Need to check for ownership, because otherwise the referenced data can be destructed when
860  * #this is destructed. */
862  *this = GVArray::ForSpan(GSpan(CPPType::get<T>(), info.data, varray.size()));
863  return;
864  }
865  if (varray.try_assign_GVArray(*this)) {
866  return;
867  }
868  *this = GVArray::For<GVArrayImpl_For_VArray<T>>(varray);
869 }
870 
871 template<typename T> inline VArray<T> GVArray::typed() const
872 {
873  if (!*this) {
874  return {};
875  }
876  BLI_assert(impl_->type().is<T>());
877  const CommonVArrayInfo info = this->common_info();
878  if (info.type == CommonVArrayInfo::Type::Single) {
879  return VArray<T>::ForSingle(*static_cast<const T *>(info.data), this->size());
880  }
881  /* Need to check for ownership, because otherwise the referenced data can be destructed when
882  * #this is destructed. */
884  return VArray<T>::ForSpan(Span<T>(static_cast<const T *>(info.data), this->size()));
885  }
886  VArray<T> varray;
887  if (this->try_assign_VArray(varray)) {
888  return varray;
889  }
890  return VArray<T>::template For<VArrayImpl_For_GVArray<T>>(*this);
891 }
892 
895 /* -------------------------------------------------------------------- */
899 template<typename ImplT, typename... Args>
900 inline GVMutableArray GVMutableArray::For(Args &&...args)
901 {
902  static_assert(std::is_base_of_v<GVMutableArrayImpl, ImplT>);
903  GVMutableArray varray;
904  varray.emplace<ImplT>(std::forward<Args>(args)...);
905  return varray;
906 }
907 
908 template<typename T> inline GVMutableArray::GVMutableArray(const VMutableArray<T> &varray)
909 {
910  if (!varray) {
911  return;
912  }
913  const CommonVArrayInfo info = varray.common_info();
915  *this = GVMutableArray::ForSpan(
916  GMutableSpan(CPPType::get<T>(), const_cast<void *>(info.data), varray.size()));
917  return;
918  }
919  if (varray.try_assign_GVMutableArray(*this)) {
920  return;
921  }
922  *this = GVMutableArray::For<GVMutableArrayImpl_For_VMutableArray<T>>(varray);
923 }
924 
925 template<typename T> inline VMutableArray<T> GVMutableArray::typed() const
926 {
927  if (!*this) {
928  return {};
929  }
930  BLI_assert(this->type().is<T>());
931  const CommonVArrayInfo info = this->common_info();
934  MutableSpan<T>(const_cast<T *>(static_cast<const T *>(info.data)), this->size()));
935  }
936  VMutableArray<T> varray;
937  if (this->try_assign_VMutableArray(varray)) {
938  return varray;
939  }
940  return VMutableArray<T>::template For<VMutableArrayImpl_For_GVMutableArray<T>>(*this);
941 }
942 
945 } // namespace blender
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define final(a, b, c)
Definition: BLI_hash.h:21
#define UNUSED(x)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
bool is() const
const void * data() const
const CPPType & type() const
int64_t size() const
CommonVArrayInfo common_info() const
bool may_have_ownership() const
const GVArrayImpl * impl_from_storage() const
bool try_assign_VArray(VArray< T > &varray) const
void copy_from(const GVArrayCommon &other)
const CPPType & type() const
void move_from(GVArrayCommon &&other) noexcept
void get_to_uninitialized(int64_t index, void *r_value) const
void materialize(void *dst) const
void get_internal_single_to_uninitialized(void *r_value) const
void materialize_to_uninitialized(void *dst) const
void get(int64_t index, void *r_value) const
IndexRange index_range() const
void materialize_compressed_to_uninitialized(IndexMask mask, void *dst) const
void materialize_compressed(IndexMask mask, void *dst) const
void get_internal_single(void *r_value) const
GVArrayImpl_For_GSpan(const CPPType &type, int64_t size)
GVArrayImpl_For_GSpan(const GMutableSpan span)
GVArrayImpl_For_SingleValueRef(const CPPType &type, const int64_t size, const void *value)
GVArrayImpl_For_SingleValueRef(const CPPType &type, const int64_t size)
bool try_assign_VArray(void *varray) const override
void materialize_compressed(const IndexMask mask, void *dst) const override
void materialize_to_uninitialized(const IndexMask mask, void *dst) const override
void get(const int64_t index, void *r_value) const override
void get_to_uninitialized(const int64_t index, void *r_value) const override
CommonVArrayInfo common_info() const override
void materialize(const IndexMask mask, void *dst) const override
void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override
virtual void materialize_compressed_to_uninitialized(IndexMask mask, void *dst) const
virtual void get_to_uninitialized(int64_t index, void *r_value) const =0
virtual void materialize_compressed(IndexMask mask, void *dst) const
virtual void materialize(const IndexMask mask, void *dst) const
virtual void materialize_to_uninitialized(const IndexMask mask, void *dst) const
virtual void get(int64_t index, void *r_value) const
virtual bool try_assign_VArray(void *varray) const
GVArrayImpl(const CPPType &type, int64_t size)
virtual CommonVArrayInfo common_info() const
const CPPType & type() const
virtual ~GVArrayImpl()=default
GVArray slice(IndexRange slice) const
static GVArray ForEmpty(const CPPType &type)
static GVArray ForGArray(GArray<> array)
GVArray()=default
static GVArray ForSingleDefault(const CPPType &type, int64_t size)
const GVArrayImpl * get_implementation() const
GVArray & operator=(const GVArray &other)
static GVArray For(Args &&...args)
GVArray(const GVArray &other)
GVArray(GVArray &&other) noexcept
static GVArray ForSingleRef(const CPPType &type, int64_t size, const void *value)
static GVArray ForSpan(GSpan span)
static GVArray ForSingle(const CPPType &type, int64_t size, const void *value)
VArray< T > typed() const
void materialize_to_uninitialized(const IndexMask mask, void *dst) const override
void set_by_copy(const int64_t index, const void *value) override
bool try_assign_VMutableArray(void *varray) const override
void materialize_compressed(const IndexMask mask, void *dst) const override
void materialize_compressed_to_uninitialized(const IndexMask mask, void *dst) const override
void get(const int64_t index, void *r_value) const override
void get_to_uninitialized(const int64_t index, void *r_value) const override
void set_by_relocate(const int64_t index, void *value) override
void set_by_move(const int64_t index, void *value) override
void materialize(const IndexMask mask, void *dst) const override
virtual bool try_assign_VMutableArray(void *varray) const
virtual void set_all(const void *src)
virtual void set_by_copy(int64_t index, const void *value)
GVMutableArrayImpl(const CPPType &type, int64_t size)
virtual void set_by_relocate(int64_t index, void *value)
virtual void set_by_move(int64_t index, void *value)=0
GVMutableArray(GVMutableArray &&other) noexcept
void set_by_move(int64_t index, void *value)
void set_all(const void *src)
void set_by_copy(int64_t index, const void *value)
GVMutableArray(const GVMutableArray &other)
GVMutableArrayImpl * get_implementation() const
GMutableSpan get_internal_span() const
bool try_assign_VMutableArray(VMutableArray< T > &varray) const
GVMutableArray & operator=(const GVMutableArray &other)
void fill(const void *value)
VMutableArray< T > typed() const
static GVMutableArray ForSpan(GMutableSpan span)
static GVMutableArray For(Args &&...args)
void set_by_relocate(int64_t index, void *value)
constexpr T * data() const
Definition: BLI_span.hh:548
void materialize(MutableSpan< T > r_span) const
void materialize_compressed(IndexMask mask, MutableSpan< T > r_span) const
void materialize_compressed_to_uninitialized(IndexMask mask, MutableSpan< T > r_span) const
bool try_assign_GVArray(GVArray &varray) const
void materialize_to_uninitialized(MutableSpan< T > r_span) const
CommonVArrayInfo common_info() const
void materialize(IndexMask mask, MutableSpan< T > r_span) const override
void materialize_to_uninitialized(IndexMask mask, MutableSpan< T > r_span) const override
void materialize_compressed_to_uninitialized(IndexMask mask, MutableSpan< T > r_span) const override
bool try_assign_GVArray(GVArray &varray) const override
CommonVArrayInfo common_info() const override
void materialize_compressed(IndexMask mask, MutableSpan< T > r_span) const override
T get(const int64_t index) const override
static VArray ForSingle(T value, const int64_t size)
static VArray ForSpan(Span< T > values)
void set(const int64_t index, T value)
static VMutableArray ForSpan(MutableSpan< T > values)
bool try_assign_GVMutableArray(GVMutableArray &varray) const
void set_all(Span< T > src)
SyclQueue void void * src
T * data_
Definition: eval_output.h:163
ccl_global float * buffer
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
#define T
constexpr bool is_same_any_v
constexpr bool is_trivial_extended_v< GVArrayImpl_For_GSpan_final >
constexpr bool is_trivial_extended_v< GVArrayImpl_For_SingleValueRef_final >
static IOCIOImpl * impl
Definition: ocio_capi.cc:8
__int64 int64_t
Definition: stdint.h:89
static constexpr GVArrayAnyExtraInfo get()
PointerRNA * ptr
Definition: wm_files.c:3480