2#include "gaia/config/config.h"
8#include "gaia/core/span.h"
9#include "gaia/core/utility.h"
10#include "gaia/mem/mem_alloc.h"
11#include "gaia/mem/mem_sani.h"
12#include "gaia/meta/reflection.h"
17 enum class DataLayout : uint8_t {
26#define GAIA_LAYOUT(layout_name) static constexpr auto gaia_Data_Layout = ::gaia::mem::DataLayout::layout_name
32 constexpr uint32_t get_alignment() {
33 if constexpr (std::is_empty_v<T>)
38 return (uint32_t)core::get_min(
sizeof(uintptr_t),
alignof(T));
48 constexpr size_t get_aligned_byte_offset(uintptr_t address,
size_t alig,
size_t itemSize,
size_t cnt) {
49 const auto padding = mem::padding(address, alig);
50 address += padding + itemSize * cnt;
60 template <
typename T,
size_t Alignment>
61 constexpr size_t get_aligned_byte_offset(uintptr_t address,
size_t cnt) {
62 const auto padding = mem::padding<Alignment>(address);
63 address += padding +
sizeof(T) * cnt;
72 template <DataLayout TDataLayout,
typename TItem>
76 template <
typename TItem>
79 constexpr static DataLayout Layout = DataLayout::AoS;
81 constexpr static size_t PackSize = 1;
83 constexpr static size_t Alignment = detail::get_alignment<TItem>();
87 template <
typename TItem>
90 constexpr static DataLayout Layout = DataLayout::SoA;
92 constexpr static size_t PackSize = 4;
94 constexpr static size_t Alignment = PackSize * 4;
98 template <
typename TItem>
101 constexpr static DataLayout Layout = DataLayout::SoA8;
103 constexpr static size_t PackSize = 8;
105 constexpr static size_t Alignment = PackSize * 4;
109 template <
typename TItem>
112 constexpr static DataLayout Layout = DataLayout::SoA16;
114 constexpr static size_t PackSize = 16;
116 constexpr static size_t Alignment = PackSize * 4;
122 template <DataLayout TDataLayout,
typename TItem>
128 template <DataLayout TDataLayout,
typename TItem>
133 template <DataLayout TDataLayout,
typename TItem>
140 template <DataLayout TDataLayout,
typename TItem,
size_t Ids>
146 template <DataLayout TDataLayout,
typename TItem,
size_t Ids>
161 template <
typename ValueType>
175 GAIA_NODISCARD
static constexpr uint32_t
get_min_byte_size(uintptr_t addr,
size_t cnt)
noexcept {
176 const auto offset = detail::get_aligned_byte_offset<ValueType, Alignment>(addr, cnt);
177 return (uint32_t)(offset - addr);
184 template <
typename Allocator>
185 GAIA_NODISCARD
static uint8_t*
alloc(
size_t cnt)
noexcept {
187 auto* pData = (ValueType*)mem::AllocHelper::alloc<uint8_t, Allocator>(bytes);
188 core::call_ctor_raw_n(pData, cnt);
189 return (uint8_t*)pData;
197 template <
typename Allocator>
198 static void free(
void* pData,
size_t cap,
size_t cnt)
noexcept {
199 if (pData ==
nullptr)
201 core::call_dtor_n((ValueType*)pData, cnt);
202 GAIA_MEM_SANI_DEL_BLOCK(
sizeof(ValueType), pData, cap, cnt);
203 return mem::AllocHelper::free<Allocator>(pData);
210 template <
typename Allocator>
211 static void free(
void* pData,
size_t cnt)
noexcept {
212 if (pData ==
nullptr)
214 core::call_dtor_n((ValueType*)pData, cnt);
215 return mem::AllocHelper::free<Allocator>(pData);
222 GAIA_NODISCARD
constexpr static ValueType
get_value(std::span<const ValueType> s,
size_t idx)
noexcept {
230 GAIA_NODISCARD
constexpr static const ValueType&
get(std::span<const ValueType> s,
size_t idx)
noexcept {
238 GAIA_NODISCARD
constexpr static ValueType&
set(std::span<ValueType> s,
size_t idx)
noexcept {
243 template <
typename ValueType>
248 template <
typename ValueType>
265 template <
typename C>
267 static_assert(!std::is_same_v<C, data_view_policy_aos_get>);
273 GAIA_NODISCARD
const ValueType&
operator[](
size_t idx)
const noexcept {
274 GAIA_ASSERT(idx <
m_data.size());
275 return ((
const ValueType*)
m_data.data())[idx];
280 GAIA_NODISCARD
decltype(
auto)
data() const noexcept {
281 return (
const uint8_t*)
m_data.data();
286 GAIA_NODISCARD
auto size() const noexcept {
291 template <
typename ValueType>
296 template <
typename ValueType>
313 template <
typename C>
315 static_assert(!std::is_same_v<C, data_view_policy_aos_set>);
322 GAIA_ASSERT(idx <
m_data.size());
323 return ((ValueType*)
m_data.data())[idx];
329 GAIA_NODISCARD
const ValueType&
operator[](
size_t idx)
const noexcept {
330 GAIA_ASSERT(idx <
m_data.size());
331 return ((
const ValueType*)
m_data.data())[idx];
336 GAIA_NODISCARD
auto data() const noexcept {
342 GAIA_NODISCARD
auto size() const noexcept {
347 template <
typename ValueType>
361 GAIA_NODISCARD
static const uint8_t*
362 get(
const void* pData, uint32_t alignment, std::span<const uint8_t> fieldSizes, uint32_t fieldIdx, uint32_t row,
363 uint32_t capacity)
noexcept {
364 GAIA_ASSERT(pData !=
nullptr);
365 GAIA_ASSERT(alignment != 0 && fieldIdx < fieldSizes.size() && row < capacity);
367 auto address = (uintptr_t)pData;
369 address = detail::get_aligned_byte_offset(address, alignment, fieldSizes[i], capacity);
371 address += mem::padding(address, alignment);
372 return (
const uint8_t*)address + ((uintptr_t)fieldSizes[fieldIdx] * row);
383 GAIA_NODISCARD
static uint8_t*
384 set(
void* pData, uint32_t alignment, std::span<const uint8_t> fieldSizes, uint32_t fieldIdx, uint32_t row,
385 uint32_t capacity)
noexcept {
386 return const_cast<uint8_t*
>(
get(pData, alignment, fieldSizes, fieldIdx, row, capacity));
401 template <DataLayout TDataLayout,
typename ValueType>
403 static_assert(std::is_copy_assignable_v<ValueType>);
406 using TTuple =
decltype(meta::struct_to_tuple(std::declval<ValueType>()));
415 constexpr static size_t TTupleItems = std::tuple_size<TTuple>::value;
416 static_assert(
Alignment > 0U,
"SoA data can't be zero-aligned");
420 template <
size_t Item>
421 using value_type =
typename std::tuple_element<Item, TTuple>::type;
424 template <
size_t Item>
431 GAIA_NODISCARD
constexpr static uint32_t
get_min_byte_size(uintptr_t addr,
size_t cnt)
noexcept {
432 const auto offset = get_aligned_byte_offset<TTupleItems>(addr, cnt);
433 return (uint32_t)(offset - addr);
440 template <
typename Allocator>
441 GAIA_NODISCARD
static uint8_t*
alloc(
size_t cnt)
noexcept {
443 return mem::AllocHelper::alloc_alig<uint8_t, Allocator>(
Alignment, bytes);
451 template <
typename Allocator>
452 static void free(
void* pData,
size_t cap,
size_t cnt)
noexcept {
453 if (pData ==
nullptr)
457 return mem::AllocHelper::free_alig<Allocator>(pData);
465 meta::each_member(ValueType{}, [&](
auto&&... item) {
466 auto address = mem::align<Alignment>((uintptr_t)pData);
469 GAIA_MEM_SANI_ADD_BLOCK(
sizeof(item), (
void*)address, cap, count),
471 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
481 meta::each_member(ValueType{}, [&](
auto&&... item) {
482 auto address = mem::align<Alignment>((uintptr_t)pData);
485 GAIA_MEM_SANI_DEL_BLOCK(
sizeof(item), (
void*)address, cap, count),
487 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
498 meta::each_member(ValueType{}, [&](
auto&&... item) {
499 auto address = mem::align<Alignment>((uintptr_t)pData);
502 GAIA_MEM_SANI_PUSH_N(
sizeof(item), (
void*)address, cap, count, n),
504 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
514 static void mem_pop_block(
void* pData,
size_t cap,
size_t count,
size_t n) {
515 meta::each_member(ValueType{}, [&](
auto&&... item) {
516 auto address = mem::align<Alignment>((uintptr_t)pData);
519 GAIA_MEM_SANI_POP_N(
sizeof(item), (
void*)address, cap, count, n),
521 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
530 GAIA_NODISCARD
constexpr static ValueType
get(std::span<const uint8_t> s,
size_t idx)
noexcept {
531 return get_inter(meta::struct_to_tuple(ValueType{}), s, idx, std::make_index_sequence<TTupleItems>());
539 template <
size_t Item>
540 GAIA_NODISCARD
constexpr static auto get(std::span<const uint8_t> s,
size_t idx = 0) noexcept {
541 const auto offset = get_aligned_byte_offset<Item>((uintptr_t)s.data(), s.size());
542 const auto& ref = get_ref<const value_type<Item>>(
reinterpret_cast<const uint8_t*
>(offset), idx);
543 return std::span{&ref, s.size() - idx};
548 std::span<uint8_t> m_data;
555 constexpr accessor(std::span<uint8_t> data,
size_t idx): m_data(data), m_idx(idx) {}
559 constexpr void operator=(
const ValueType& val)
noexcept {
560 set_inter(meta::struct_to_tuple(val), m_data, m_idx, std::make_index_sequence<TTupleItems>());
566 set_inter(meta::struct_to_tuple(GAIA_MOV(val)), m_data, m_idx, std::make_index_sequence<TTupleItems>());
571 GAIA_NODISCARD
constexpr operator ValueType() const noexcept {
573 meta::struct_to_tuple(ValueType{}), {(
const uint8_t*)m_data.data(), m_data.size()}, m_idx,
574 std::make_index_sequence<TTupleItems>());
582 GAIA_NODISCARD
constexpr static auto set(std::span<uint8_t> s,
size_t idx)
noexcept {
591 template <
size_t Item>
592 GAIA_NODISCARD
constexpr static auto set(std::span<uint8_t> s,
size_t idx = 0) noexcept {
593 const auto offset = get_aligned_byte_offset<Item>((uintptr_t)s.data(), s.size());
594 auto& ref = get_ref<value_type<Item>>((
const uint8_t*)offset, idx);
595 return std::span{&ref, s.size() - idx};
599 template <
size_t... Ids>
600 GAIA_NODISCARD
constexpr static size_t
601 get_aligned_byte_offset_seq(uintptr_t address,
size_t cnt, std::index_sequence<Ids...> ) {
602 ((address = detail::get_aligned_byte_offset(address,
Alignment,
sizeof(value_type<Ids>), cnt)), ...);
603 address += mem::padding(address,
Alignment);
607 template <u
int32_t N>
608 GAIA_NODISCARD
constexpr static size_t get_aligned_byte_offset(uintptr_t address,
size_t cnt) {
609 return get_aligned_byte_offset_seq(address, cnt, std::make_index_sequence<N>());
612 template <
typename TMemberType>
613 GAIA_NODISCARD
constexpr static TMemberType& get_ref(
const uint8_t* data,
size_t idx)
noexcept {
616 auto* pCastData = (TMemberType*)data;
617 return pCastData[idx];
620 template <
typename Tup,
size_t... Ids>
621 GAIA_NODISCARD
constexpr static ValueType
622 get_inter(Tup&& t, std::span<const uint8_t> s,
size_t idx, std::index_sequence<Ids...> )
noexcept {
623 auto address = mem::align<Alignment>((uintptr_t)s.data());
626 std::get<Ids>(t) = get_ref<value_type<Ids>>((
const uint8_t*)address, idx),
628 address = mem::align<Alignment>(address + (
sizeof(value_type<Ids>) * s.size()))),
630 return meta::tuple_to_struct<ValueType, TTuple>(GAIA_FWD(t));
633 template <
typename Tup,
size_t... Ids>
634 constexpr static void
635 set_inter(Tup&& t, std::span<uint8_t> s,
size_t idx, std::index_sequence<Ids...> )
noexcept {
636 auto address = mem::align<Alignment>((uintptr_t)s.data());
639 get_ref<value_type<Ids>>((uint8_t*)address, idx) = std::get<Ids>(t),
641 address = mem::align<Alignment>(address + (
sizeof(value_type<Ids>) * s.size()))),
646 template <
typename ValueType>
649 template <
typename ValueType>
652 template <
typename ValueType>
659 template <DataLayout TDataLayout,
typename ValueType>
661 static_assert(std::is_copy_assignable_v<ValueType>);
668 template <
size_t Item>
686 template <
typename C>
688 static_assert(!std::is_same_v<C, data_view_policy_soa_get>);
694 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_t idx)
const noexcept {
701 template <
size_t Item>
702 GAIA_NODISCARD
constexpr auto get() const noexcept {
703 auto s = view_policy::template get<Item>(
m_data);
704 return std::span(s.data(), s.size());
709 GAIA_NODISCARD
decltype(
auto)
data() const noexcept {
710 return (
const uint8_t*)
m_data.data();
715 GAIA_NODISCARD
auto size() const noexcept {
720 template <
typename ValueType>
723 template <
typename ValueType>
726 template <
typename ValueType>
733 template <DataLayout TDataLayout,
typename ValueType>
735 static_assert(std::is_copy_assignable_v<ValueType>);
742 template <
size_t Item>
762 template <
typename C>
764 static_assert(!std::is_same_v<C, data_view_policy_soa_set>);
776 constexpr void operator=(
const ValueType& val)
noexcept {
789 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_t idx)
const noexcept {
795 GAIA_NODISCARD
constexpr auto operator[](
size_t idx)
noexcept {
802 template <
size_t Item>
803 GAIA_NODISCARD
constexpr auto get() const noexcept {
804 auto s = view_policy::template get<Item>(
m_data);
805 return std::span(s.data(), s.size());
811 template <
size_t Item>
812 GAIA_NODISCARD
constexpr auto set() noexcept {
813 auto s = view_policy::template set<Item>(
m_data);
814 return std::span(s.data(), s.size());
819 GAIA_NODISCARD
auto data() const noexcept {
825 GAIA_NODISCARD
auto size() const noexcept {
830 template <
typename ValueType>
833 template <
typename ValueType>
836 template <
typename ValueType>
846 template <
typename,
typename =
void>
847 struct auto_view_policy_inter {
848 static constexpr DataLayout data_layout_type = DataLayout::AoS;
850 template <
typename T>
851 struct auto_view_policy_inter<T, std::void_t<decltype(T::gaia_Data_Layout)>> {
852 static constexpr DataLayout data_layout_type = T::gaia_Data_Layout;
855 template <
typename,
typename =
void>
856 struct is_soa_layout: std::false_type {};
857 template <
typename T>
858 struct is_soa_layout<T, std::void_t<decltype(T::gaia_Data_Layout)>>:
859 std::bool_constant<!std::is_empty_v<T> && (T::gaia_Data_Layout != DataLayout::AoS)> {};
865 template <
typename T>
866 using auto_view_policy = data_view_policy<detail::auto_view_policy_inter<T>::data_layout_type, T>;
869 template <
typename T>
870 using auto_view_policy_get = data_view_policy_get<detail::auto_view_policy_inter<T>::data_layout_type, T>;
873 template <
typename T>
874 using auto_view_policy_set = data_view_policy_set<detail::auto_view_policy_inter<T>::data_layout_type, T>;
878 template <
typename T>
879 inline constexpr bool is_soa_layout_v = detail::is_soa_layout<T>::value;
Proxy used to read or assign one complete SoA value.
Definition data_layout_policy.h:547
constexpr void operator=(const ValueType &val) noexcept
Assigns a copied value to the selected SoA fields.
Definition data_layout_policy.h:559
constexpr accessor(std::span< uint8_t > data, size_t idx)
Creates a value proxy.
Definition data_layout_policy.h:555
constexpr void operator=(ValueType &&val) noexcept
Assigns a moved value to the selected SoA fields.
Definition data_layout_policy.h:565
Compile-time properties of a data layout.
Definition data_layout_policy.h:73
Read-only byte view over AoS values.
Definition data_layout_policy.h:249
std::span< const uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:254
data_view_policy_aos_get(std::span< uint8_t > data)
Creates a read-only view over mutable bytes.
Definition data_layout_policy.h:258
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:286
GAIA_NODISCARD const ValueType & operator[](size_t idx) const noexcept
Returns a value by index.
Definition data_layout_policy.h:273
data_view_policy_aos_get(const C &c)
Creates a read-only view over a contiguous container.
Definition data_layout_policy.h:266
data_view_policy_aos_get(std::span< const uint8_t > data)
Creates a read-only view over bytes.
Definition data_layout_policy.h:261
GAIA_NODISCARD decltype(auto) data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:280
Mutable byte view over AoS values.
Definition data_layout_policy.h:297
data_view_policy_aos_set(std::span< const uint8_t > data)
Creates a mutable view from a byte span.
Definition data_layout_policy.h:309
GAIA_NODISCARD ValueType & operator[](size_t idx) noexcept
Returns a mutable value by index.
Definition data_layout_policy.h:321
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:342
std::span< uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:302
data_view_policy_aos_set(const C &c)
Creates a mutable view over a contiguous container.
Definition data_layout_policy.h:314
GAIA_NODISCARD const ValueType & operator[](size_t idx) const noexcept
Returns a read-only value by index.
Definition data_layout_policy.h:329
GAIA_NODISCARD auto data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:336
data_view_policy_aos_set(std::span< uint8_t > data)
Creates a mutable view over bytes.
Definition data_layout_policy.h:306
View policy for accessing and storing data in the AoS way. Good for random access and when accessing ...
Definition data_layout_policy.h:162
static constexpr size_t Alignment
Required byte alignment.
Definition data_layout_policy.h:169
static GAIA_NODISCARD constexpr uint32_t get_min_byte_size(uintptr_t addr, size_t cnt) noexcept
Calculates the bytes required for a value range.
Definition data_layout_policy.h:175
static GAIA_NODISCARD uint8_t * alloc(size_t cnt) noexcept
Allocates and default-constructs an AoS value range.
Definition data_layout_policy.h:185
static void free(void *pData, size_t cnt) noexcept
Destroys and releases an AoS value range.
Definition data_layout_policy.h:211
GAIA_NODISCARD static constexpr ValueType get_value(std::span< const ValueType > s, size_t idx) noexcept
Copies a value from an AoS span.
Definition data_layout_policy.h:222
std::add_pointer_t< ValueType > TargetCastType
Pointer type used to address stored values.
Definition data_layout_policy.h:164
GAIA_NODISCARD static constexpr ValueType & set(std::span< ValueType > s, size_t idx) noexcept
Returns a mutable value reference from an AoS span.
Definition data_layout_policy.h:238
static void free(void *pData, size_t cap, size_t cnt) noexcept
Destroys and releases an instrumented AoS value range.
Definition data_layout_policy.h:198
static constexpr DataLayout Layout
Physical layout.
Definition data_layout_policy.h:167
GAIA_NODISCARD static constexpr const ValueType & get(std::span< const ValueType > s, size_t idx) noexcept
Returns a read-only value reference from an AoS span.
Definition data_layout_policy.h:230
Indexed read-only view metadata.
Definition data_layout_policy.h:141
Read-only view for a selected layout and item type.
Definition data_layout_policy.h:129
Indexed mutable view metadata.
Definition data_layout_policy.h:147
Mutable view for a selected layout and item type.
Definition data_layout_policy.h:134
Type-erased policy for addressing one field value in SoA storage. The field arrays use the same align...
Definition data_layout_policy.h:352
static GAIA_NODISCARD const uint8_t * get(const void *pData, uint32_t alignment, std::span< const uint8_t > fieldSizes, uint32_t fieldIdx, uint32_t row, uint32_t capacity) noexcept
Returns one read-only field value from type-erased SoA storage.
Definition data_layout_policy.h:362
static GAIA_NODISCARD uint8_t * set(void *pData, uint32_t alignment, std::span< const uint8_t > fieldSizes, uint32_t fieldIdx, uint32_t row, uint32_t capacity) noexcept
Returns one mutable field value from type-erased SoA storage.
Definition data_layout_policy.h:384
Metadata for a selected field.
Definition data_layout_policy.h:669
typename view_policy::template const_value_type< Item > const_value_type
Const-qualified field type.
Definition data_layout_policy.h:671
Read-only byte view over SoA values.
Definition data_layout_policy.h:660
data_view_policy_soa_get(std::span< const uint8_t > data)
Creates a read-only view over bytes.
Definition data_layout_policy.h:682
data_view_policy_soa_get(std::span< uint8_t > data)
Creates a read-only view over mutable bytes.
Definition data_layout_policy.h:679
std::span< const uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:675
GAIA_NODISCARD decltype(auto) data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:709
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:715
data_view_policy_soa_get(const C &c)
Creates a read-only view over a contiguous container.
Definition data_layout_policy.h:687
GAIA_NODISCARD constexpr auto get() const noexcept
Returns a read-only span over one field.
Definition data_layout_policy.h:702
Proxy used to assign one complete value.
Definition data_layout_policy.h:768
constexpr void operator=(ValueType &&val) noexcept
Assigns a moved value.
Definition data_layout_policy.h:781
constexpr void operator=(const ValueType &val) noexcept
Assigns a copied value.
Definition data_layout_policy.h:776
size_t m_idx
Value index.
Definition data_layout_policy.h:772
std::span< uint8_t > m_data
Backing byte span.
Definition data_layout_policy.h:770
Metadata for a selected field.
Definition data_layout_policy.h:743
typename view_policy::template const_value_type< Item > const_value_type
Const-qualified field type.
Definition data_layout_policy.h:747
typename view_policy::template value_type< Item > value_type
Mutable field type.
Definition data_layout_policy.h:745
Mutable byte view over SoA values.
Definition data_layout_policy.h:734
GAIA_NODISCARD constexpr auto set() noexcept
Returns a mutable span over one field.
Definition data_layout_policy.h:812
data_view_policy_soa_set(std::span< uint8_t > data)
Creates a mutable view over bytes.
Definition data_layout_policy.h:755
data_view_policy_soa_set(const C &c)
Creates a mutable view over a contiguous container.
Definition data_layout_policy.h:763
std::span< uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:751
GAIA_NODISCARD constexpr auto operator[](size_t idx) noexcept
Returns a mutable proxy by index.
Definition data_layout_policy.h:795
data_view_policy_soa_set(std::span< const uint8_t > data)
Creates a mutable view from a byte span.
Definition data_layout_policy.h:758
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:825
GAIA_NODISCARD constexpr auto get() const noexcept
Returns a read-only span over one field.
Definition data_layout_policy.h:803
GAIA_NODISCARD auto data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:819
View policy for accessing and storing data in the SoA way. Good for SIMD processing.
Definition data_layout_policy.h:402
GAIA_NODISCARD static constexpr ValueType get(std::span< const uint8_t > s, size_t idx) noexcept
Reconstructs a value from its SoA fields.
Definition data_layout_policy.h:530
static void mem_pop_block(void *pData, size_t cap, size_t count, size_t n)
Poisons removed SoA values for the memory sanitizer.
Definition data_layout_policy.h:514
static void mem_add_block(void *pData, size_t cap, size_t count)
Registers a newly allocated SoA range with the memory sanitizer.
Definition data_layout_policy.h:464
uint8_t * TargetCastType
Pointer type used to address SoA storage.
Definition data_layout_policy.h:408
static constexpr DataLayout Layout
Physical layout.
Definition data_layout_policy.h:411
static constexpr size_t Alignment
Required byte alignment.
Definition data_layout_policy.h:413
typename std::add_const< value_type< Item > >::type const_value_type
Const-qualified type of a reflected field.
Definition data_layout_policy.h:425
static GAIA_NODISCARD uint8_t * alloc(size_t cnt) noexcept
Allocates an SoA value range.
Definition data_layout_policy.h:441
decltype(meta::struct_to_tuple(std::declval< ValueType >())) TTuple
Tuple representation of the reflected value fields.
Definition data_layout_policy.h:406
GAIA_NODISCARD static constexpr uint32_t get_min_byte_size(uintptr_t addr, size_t cnt) noexcept
Calculates the bytes required for an SoA value range.
Definition data_layout_policy.h:431
static void mem_del_block(void *pData, size_t cap, size_t count)
Unregisters an SoA range from the memory sanitizer.
Definition data_layout_policy.h:480
GAIA_NODISCARD static constexpr auto set(std::span< uint8_t > s, size_t idx) noexcept
Returns a mutable proxy for one complete value.
Definition data_layout_policy.h:582
static void mem_push_block(void *pData, size_t cap, size_t count, size_t n)
Makes newly appended SoA values addressable by the memory sanitizer.
Definition data_layout_policy.h:497
static void free(void *pData, size_t cap, size_t cnt) noexcept
Releases an instrumented SoA value range.
Definition data_layout_policy.h:452
GAIA_NODISCARD static constexpr auto set(std::span< uint8_t > s, size_t idx=0) noexcept
Returns a mutable span over one SoA field.
Definition data_layout_policy.h:592
static constexpr size_t TTupleItems
Number of reflected fields.
Definition data_layout_policy.h:415
GAIA_NODISCARD static constexpr auto get(std::span< const uint8_t > s, size_t idx=0) noexcept
Returns a read-only span over one SoA field.
Definition data_layout_policy.h:540
typename std::tuple_element< Item, TTuple >::type value_type
Type of a reflected field.
Definition data_layout_policy.h:421
Storage policy for a selected layout and item type.
Definition data_layout_policy.h:123