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>)
37 return (uint32_t)
alignof(T);
46 constexpr size_t get_aligned_byte_offset(uintptr_t address,
size_t alig,
size_t itemSize,
size_t cnt) {
47 const auto padding = mem::padding(address, alig);
48 address += padding + itemSize * cnt;
58 template <
typename T,
size_t Alignment>
59 constexpr size_t get_aligned_byte_offset(uintptr_t address,
size_t cnt) {
60 const auto padding = mem::padding<Alignment>(address);
61 address += padding +
sizeof(T) * cnt;
70 template <DataLayout TDataLayout,
typename TItem>
74 template <
typename TItem>
77 constexpr static DataLayout Layout = DataLayout::AoS;
79 constexpr static size_t PackSize = 1;
81 constexpr static size_t Alignment = detail::get_alignment<TItem>();
85 template <
typename TItem>
88 constexpr static DataLayout Layout = DataLayout::SoA;
90 constexpr static size_t PackSize = 4;
92 constexpr static size_t Alignment = PackSize * 4;
96 template <
typename TItem>
99 constexpr static DataLayout Layout = DataLayout::SoA8;
101 constexpr static size_t PackSize = 8;
103 constexpr static size_t Alignment = PackSize * 4;
107 template <
typename TItem>
110 constexpr static DataLayout Layout = DataLayout::SoA16;
112 constexpr static size_t PackSize = 16;
114 constexpr static size_t Alignment = PackSize * 4;
120 template <DataLayout TDataLayout,
typename TItem>
126 template <DataLayout TDataLayout,
typename TItem>
131 template <DataLayout TDataLayout,
typename TItem>
138 template <DataLayout TDataLayout,
typename TItem,
size_t Ids>
144 template <DataLayout TDataLayout,
typename TItem,
size_t Ids>
159 template <
typename ValueType>
173 GAIA_NODISCARD
static constexpr uint32_t
get_min_byte_size(uintptr_t addr,
size_t cnt)
noexcept {
174 const auto offset = detail::get_aligned_byte_offset<ValueType, Alignment>(addr, cnt);
175 return (uint32_t)(offset - addr);
182 template <
typename Allocator>
183 GAIA_NODISCARD
static uint8_t*
alloc(
size_t cnt)
noexcept {
185 return mem::AllocHelper::alloc<uint8_t, Allocator>(bytes);
193 template <
typename Allocator>
194 static void free(
void* pData,
size_t cap,
size_t cnt)
noexcept {
195 if (pData ==
nullptr)
197 core::call_dtor_n((ValueType*)pData, cnt);
198 GAIA_MEM_SANI_DEL_BLOCK(
sizeof(ValueType), pData, cap, cnt);
199 return mem::AllocHelper::free<Allocator>(pData);
206 template <
typename Allocator>
207 static void free(
void* pData,
size_t cnt)
noexcept {
208 if (pData ==
nullptr)
210 core::call_dtor_n((ValueType*)pData, cnt);
211 return mem::AllocHelper::free<Allocator>(pData);
218 GAIA_NODISCARD
constexpr static ValueType
get_value(std::span<const ValueType> s,
size_t idx)
noexcept {
226 GAIA_NODISCARD
constexpr static const ValueType&
get(std::span<const ValueType> s,
size_t idx)
noexcept {
234 GAIA_NODISCARD
constexpr static ValueType&
set(std::span<ValueType> s,
size_t idx)
noexcept {
239 template <
typename ValueType>
244 template <
typename ValueType>
261 template <
typename C>
263 static_assert(!std::is_same_v<C, data_view_policy_aos_get>);
269 GAIA_NODISCARD
const ValueType&
operator[](
size_t idx)
const noexcept {
270 GAIA_ASSERT(idx <
m_data.size());
271 return ((
const ValueType*)(
const void*)
m_data.data())[idx];
276 GAIA_NODISCARD
decltype(
auto)
data() const noexcept {
277 return (
const uint8_t*)
m_data.data();
282 GAIA_NODISCARD
auto size() const noexcept {
287 template <
typename ValueType>
292 template <
typename ValueType>
309 template <
typename C>
311 static_assert(!std::is_same_v<C, data_view_policy_aos_set>);
318 GAIA_ASSERT(idx <
m_data.size());
319 return ((ValueType*)(
void*)
m_data.data())[idx];
325 GAIA_NODISCARD
const ValueType&
operator[](
size_t idx)
const noexcept {
326 GAIA_ASSERT(idx <
m_data.size());
327 return ((
const ValueType*)(
const void*)
m_data.data())[idx];
332 GAIA_NODISCARD
auto data() const noexcept {
338 GAIA_NODISCARD
auto size() const noexcept {
343 template <
typename ValueType>
357 GAIA_NODISCARD
static const uint8_t*
358 get(
const void* pData, uint32_t alignment, std::span<const uint8_t> fieldSizes, uint32_t fieldIdx, uint32_t row,
359 uint32_t capacity)
noexcept {
360 GAIA_ASSERT(pData !=
nullptr);
361 GAIA_ASSERT(alignment != 0 && fieldIdx < fieldSizes.size() && row < capacity);
363 auto address = (uintptr_t)pData;
365 address = detail::get_aligned_byte_offset(address, alignment, fieldSizes[i], capacity);
367 address += mem::padding(address, alignment);
368 return (
const uint8_t*)address + ((uintptr_t)fieldSizes[fieldIdx] * row);
379 GAIA_NODISCARD
static uint8_t*
380 set(
void* pData, uint32_t alignment, std::span<const uint8_t> fieldSizes, uint32_t fieldIdx, uint32_t row,
381 uint32_t capacity)
noexcept {
382 return const_cast<uint8_t*
>(
get(pData, alignment, fieldSizes, fieldIdx, row, capacity));
397 template <DataLayout TDataLayout,
typename ValueType>
399 static_assert(std::is_copy_assignable_v<ValueType>);
402 using TTuple =
decltype(meta::struct_to_tuple(std::declval<ValueType>()));
411 constexpr static size_t TTupleItems = std::tuple_size<TTuple>::value;
412 static_assert(
Alignment > 0U,
"SoA data can't be zero-aligned");
416 template <
size_t Item>
417 using value_type =
typename std::tuple_element<Item, TTuple>::type;
420 template <
size_t Item>
427 GAIA_NODISCARD
constexpr static uint32_t
get_min_byte_size(uintptr_t addr,
size_t cnt)
noexcept {
428 const auto offset = get_aligned_byte_offset<TTupleItems>(addr, cnt);
429 return (uint32_t)(offset - addr);
436 template <
typename Allocator>
437 GAIA_NODISCARD
static uint8_t*
alloc(
size_t cnt)
noexcept {
439 return mem::AllocHelper::alloc_alig<uint8_t, Allocator>(
Alignment, bytes);
447 template <
typename Allocator>
448 static void free(
void* pData,
size_t cap,
size_t cnt)
noexcept {
449 if (pData ==
nullptr)
453 return mem::AllocHelper::free_alig<Allocator>(pData);
461 meta::each_member(ValueType{}, [&](
auto&&... item) {
462 auto address = mem::align<Alignment>((uintptr_t)pData);
465 GAIA_MEM_SANI_ADD_BLOCK(
sizeof(item), (
void*)address, cap, count),
467 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
477 meta::each_member(ValueType{}, [&](
auto&&... item) {
478 auto address = mem::align<Alignment>((uintptr_t)pData);
481 GAIA_MEM_SANI_DEL_BLOCK(
sizeof(item), (
void*)address, cap, count),
483 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
494 meta::each_member(ValueType{}, [&](
auto&&... item) {
495 auto address = mem::align<Alignment>((uintptr_t)pData);
498 GAIA_MEM_SANI_PUSH_N(
sizeof(item), (
void*)address, cap, count, n),
500 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
510 static void mem_pop_block(
void* pData,
size_t cap,
size_t count,
size_t n) {
511 meta::each_member(ValueType{}, [&](
auto&&... item) {
512 auto address = mem::align<Alignment>((uintptr_t)pData);
515 GAIA_MEM_SANI_POP_N(
sizeof(item), (
void*)address, cap, count, n),
517 address = mem::align<Alignment>(address + (
sizeof(item) * cap))),
526 GAIA_NODISCARD
constexpr static ValueType
get(std::span<const uint8_t> s,
size_t idx)
noexcept {
527 return get_inter(meta::struct_to_tuple(ValueType{}), s, idx, std::make_index_sequence<TTupleItems>());
535 template <
size_t Item>
536 GAIA_NODISCARD
constexpr static auto get(std::span<const uint8_t> s,
size_t idx = 0) noexcept {
537 const auto offset = get_aligned_byte_offset<Item>((uintptr_t)s.data(), s.size());
538 const auto& ref = get_ref<const value_type<Item>>(
reinterpret_cast<const uint8_t*
>(offset), idx);
539 return std::span{&ref, s.size() - idx};
544 std::span<uint8_t> m_data;
551 constexpr accessor(std::span<uint8_t> data,
size_t idx): m_data(data), m_idx(idx) {}
555 constexpr void operator=(
const ValueType& val)
noexcept {
556 set_inter(meta::struct_to_tuple(val), m_data, m_idx, std::make_index_sequence<TTupleItems>());
562 set_inter(meta::struct_to_tuple(GAIA_MOV(val)), m_data, m_idx, std::make_index_sequence<TTupleItems>());
567 GAIA_NODISCARD
constexpr operator ValueType() const noexcept {
569 meta::struct_to_tuple(ValueType{}), {(
const uint8_t*)m_data.data(), m_data.size()}, m_idx,
570 std::make_index_sequence<TTupleItems>());
578 GAIA_NODISCARD
constexpr static auto set(std::span<uint8_t> s,
size_t idx)
noexcept {
587 template <
size_t Item>
588 GAIA_NODISCARD
constexpr static auto set(std::span<uint8_t> s,
size_t idx = 0) noexcept {
589 const auto offset = get_aligned_byte_offset<Item>((uintptr_t)s.data(), s.size());
590 auto& ref = get_ref<value_type<Item>>((
const uint8_t*)offset, idx);
591 return std::span{&ref, s.size() - idx};
595 template <
size_t... Ids>
596 GAIA_NODISCARD
constexpr static size_t get_aligned_byte_offset_seq(
597 uintptr_t address, [[maybe_unused]]
size_t cnt, std::index_sequence<Ids...> ) {
598 ((address = detail::get_aligned_byte_offset(address,
Alignment,
sizeof(value_type<Ids>), cnt)), ...);
599 address += mem::padding(address,
Alignment);
603 template <u
int32_t N>
604 GAIA_NODISCARD
constexpr static size_t get_aligned_byte_offset(uintptr_t address,
size_t cnt) {
605 return get_aligned_byte_offset_seq(address, cnt, std::make_index_sequence<N>());
608 template <
typename TMemberType>
609 GAIA_NODISCARD
constexpr static TMemberType& get_ref(
const uint8_t* data,
size_t idx)
noexcept {
612 auto* pCastData = (TMemberType*)(
void*)data;
613 return pCastData[idx];
616 template <
typename Tup,
size_t... Ids>
617 GAIA_NODISCARD
constexpr static ValueType
618 get_inter(Tup&& t, std::span<const uint8_t> s,
size_t idx, std::index_sequence<Ids...> )
noexcept {
619 auto address = mem::align<Alignment>((uintptr_t)s.data());
622 std::get<Ids>(t) = get_ref<value_type<Ids>>((
const uint8_t*)address, idx),
624 address = mem::align<Alignment>(address + (
sizeof(value_type<Ids>) * s.size()))),
626 return meta::tuple_to_struct<ValueType, TTuple>(GAIA_FWD(t));
629 template <
typename Tup,
size_t... Ids>
630 constexpr static void
631 set_inter(Tup&& t, std::span<uint8_t> s,
size_t idx, std::index_sequence<Ids...> )
noexcept {
632 auto address = mem::align<Alignment>((uintptr_t)s.data());
635 get_ref<value_type<Ids>>((uint8_t*)address, idx) = std::get<Ids>(t),
637 address = mem::align<Alignment>(address + (
sizeof(value_type<Ids>) * s.size()))),
642 template <
typename ValueType>
645 template <
typename ValueType>
648 template <
typename ValueType>
655 template <DataLayout TDataLayout,
typename ValueType>
657 static_assert(std::is_copy_assignable_v<ValueType>);
664 template <
size_t Item>
682 template <
typename C>
684 static_assert(!std::is_same_v<C, data_view_policy_soa_get>);
690 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_t idx)
const noexcept {
697 template <
size_t Item>
698 GAIA_NODISCARD
constexpr auto get() const noexcept {
699 auto s = view_policy::template get<Item>(
m_data);
700 return std::span(s.data(), s.size());
705 GAIA_NODISCARD
decltype(
auto)
data() const noexcept {
706 return (
const uint8_t*)
m_data.data();
711 GAIA_NODISCARD
auto size() const noexcept {
716 template <
typename ValueType>
719 template <
typename ValueType>
722 template <
typename ValueType>
729 template <DataLayout TDataLayout,
typename ValueType>
731 static_assert(std::is_copy_assignable_v<ValueType>);
738 template <
size_t Item>
758 template <
typename C>
760 static_assert(!std::is_same_v<C, data_view_policy_soa_set>);
772 constexpr void operator=(
const ValueType& val)
noexcept {
785 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_t idx)
const noexcept {
791 GAIA_NODISCARD
constexpr auto operator[](
size_t idx)
noexcept {
798 template <
size_t Item>
799 GAIA_NODISCARD
constexpr auto get() const noexcept {
800 auto s = view_policy::template get<Item>(
m_data);
801 return std::span(s.data(), s.size());
807 template <
size_t Item>
808 GAIA_NODISCARD
constexpr auto set() noexcept {
809 auto s = view_policy::template set<Item>(
m_data);
810 return std::span(s.data(), s.size());
815 GAIA_NODISCARD
auto data() const noexcept {
821 GAIA_NODISCARD
auto size() const noexcept {
826 template <
typename ValueType>
829 template <
typename ValueType>
832 template <
typename ValueType>
842 template <
typename,
typename =
void>
843 struct auto_view_policy_inter {
844 static constexpr DataLayout data_layout_type = DataLayout::AoS;
846 template <
typename T>
847 struct auto_view_policy_inter<T, std::void_t<decltype(T::gaia_Data_Layout)>> {
848 static constexpr DataLayout data_layout_type = T::gaia_Data_Layout;
851 template <
typename,
typename =
void>
852 struct is_soa_layout: std::false_type {};
853 template <
typename T>
854 struct is_soa_layout<T, std::void_t<decltype(T::gaia_Data_Layout)>>:
855 std::bool_constant<!std::is_empty_v<T> && (T::gaia_Data_Layout != DataLayout::AoS)> {};
861 template <
typename T>
862 using auto_view_policy = data_view_policy<detail::auto_view_policy_inter<T>::data_layout_type, T>;
865 template <
typename T>
866 using auto_view_policy_get = data_view_policy_get<detail::auto_view_policy_inter<T>::data_layout_type, T>;
869 template <
typename T>
870 using auto_view_policy_set = data_view_policy_set<detail::auto_view_policy_inter<T>::data_layout_type, T>;
874 template <
typename T>
875 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:543
constexpr void operator=(const ValueType &val) noexcept
Assigns a copied value to the selected SoA fields.
Definition data_layout_policy.h:555
constexpr accessor(std::span< uint8_t > data, size_t idx)
Creates a value proxy.
Definition data_layout_policy.h:551
constexpr void operator=(ValueType &&val) noexcept
Assigns a moved value to the selected SoA fields.
Definition data_layout_policy.h:561
Compile-time properties of a data layout.
Definition data_layout_policy.h:71
Read-only byte view over AoS values.
Definition data_layout_policy.h:245
std::span< const uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:250
data_view_policy_aos_get(std::span< uint8_t > data)
Creates a read-only view over mutable bytes.
Definition data_layout_policy.h:254
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:282
GAIA_NODISCARD const ValueType & operator[](size_t idx) const noexcept
Returns a value by index.
Definition data_layout_policy.h:269
data_view_policy_aos_get(const C &c)
Creates a read-only view over a contiguous container.
Definition data_layout_policy.h:262
data_view_policy_aos_get(std::span< const uint8_t > data)
Creates a read-only view over bytes.
Definition data_layout_policy.h:257
GAIA_NODISCARD decltype(auto) data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:276
Mutable byte view over AoS values.
Definition data_layout_policy.h:293
data_view_policy_aos_set(std::span< const uint8_t > data)
Creates a mutable view from a byte span.
Definition data_layout_policy.h:305
GAIA_NODISCARD ValueType & operator[](size_t idx) noexcept
Returns a mutable value by index.
Definition data_layout_policy.h:317
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:338
std::span< uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:298
data_view_policy_aos_set(const C &c)
Creates a mutable view over a contiguous container.
Definition data_layout_policy.h:310
GAIA_NODISCARD const ValueType & operator[](size_t idx) const noexcept
Returns a read-only value by index.
Definition data_layout_policy.h:325
GAIA_NODISCARD auto data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:332
data_view_policy_aos_set(std::span< uint8_t > data)
Creates a mutable view over bytes.
Definition data_layout_policy.h:302
View policy for accessing and storing data in the AoS way. Good for random access and when accessing ...
Definition data_layout_policy.h:160
static constexpr size_t Alignment
Required byte alignment.
Definition data_layout_policy.h:167
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:173
static GAIA_NODISCARD uint8_t * alloc(size_t cnt) noexcept
Allocates raw AoS capacity. The caller constructs the live values.
Definition data_layout_policy.h:183
static void free(void *pData, size_t cnt) noexcept
Destroys and releases an AoS value range.
Definition data_layout_policy.h:207
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:218
std::add_pointer_t< ValueType > TargetCastType
Pointer type used to address stored values.
Definition data_layout_policy.h:162
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:234
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:194
static constexpr DataLayout Layout
Physical layout.
Definition data_layout_policy.h:165
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:226
Indexed read-only view metadata.
Definition data_layout_policy.h:139
Read-only view for a selected layout and item type.
Definition data_layout_policy.h:127
Indexed mutable view metadata.
Definition data_layout_policy.h:145
Mutable view for a selected layout and item type.
Definition data_layout_policy.h:132
Type-erased policy for addressing one field value in SoA storage. The field arrays use the same align...
Definition data_layout_policy.h:348
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:358
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:380
Metadata for a selected field.
Definition data_layout_policy.h:665
typename view_policy::template const_value_type< Item > const_value_type
Const-qualified field type.
Definition data_layout_policy.h:667
Read-only byte view over SoA values.
Definition data_layout_policy.h:656
data_view_policy_soa_get(std::span< const uint8_t > data)
Creates a read-only view over bytes.
Definition data_layout_policy.h:678
data_view_policy_soa_get(std::span< uint8_t > data)
Creates a read-only view over mutable bytes.
Definition data_layout_policy.h:675
std::span< const uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:671
GAIA_NODISCARD decltype(auto) data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:705
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:711
data_view_policy_soa_get(const C &c)
Creates a read-only view over a contiguous container.
Definition data_layout_policy.h:683
GAIA_NODISCARD constexpr auto get() const noexcept
Returns a read-only span over one field.
Definition data_layout_policy.h:698
Proxy used to assign one complete value.
Definition data_layout_policy.h:764
constexpr void operator=(ValueType &&val) noexcept
Assigns a moved value.
Definition data_layout_policy.h:777
constexpr void operator=(const ValueType &val) noexcept
Assigns a copied value.
Definition data_layout_policy.h:772
size_t m_idx
Value index.
Definition data_layout_policy.h:768
std::span< uint8_t > m_data
Backing byte span.
Definition data_layout_policy.h:766
Metadata for a selected field.
Definition data_layout_policy.h:739
typename view_policy::template const_value_type< Item > const_value_type
Const-qualified field type.
Definition data_layout_policy.h:743
typename view_policy::template value_type< Item > value_type
Mutable field type.
Definition data_layout_policy.h:741
Mutable byte view over SoA values.
Definition data_layout_policy.h:730
GAIA_NODISCARD constexpr auto set() noexcept
Returns a mutable span over one field.
Definition data_layout_policy.h:808
data_view_policy_soa_set(std::span< uint8_t > data)
Creates a mutable view over bytes.
Definition data_layout_policy.h:751
data_view_policy_soa_set(const C &c)
Creates a mutable view over a contiguous container.
Definition data_layout_policy.h:759
std::span< uint8_t > m_data
Raw data pointed to by the view policy.
Definition data_layout_policy.h:747
GAIA_NODISCARD constexpr auto operator[](size_t idx) noexcept
Returns a mutable proxy by index.
Definition data_layout_policy.h:791
data_view_policy_soa_set(std::span< const uint8_t > data)
Creates a mutable view from a byte span.
Definition data_layout_policy.h:754
GAIA_NODISCARD auto size() const noexcept
Returns the backing span size.
Definition data_layout_policy.h:821
GAIA_NODISCARD constexpr auto get() const noexcept
Returns a read-only span over one field.
Definition data_layout_policy.h:799
GAIA_NODISCARD auto data() const noexcept
Returns the backing byte address.
Definition data_layout_policy.h:815
View policy for accessing and storing data in the SoA way. Good for SIMD processing.
Definition data_layout_policy.h:398
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:526
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:510
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:460
uint8_t * TargetCastType
Pointer type used to address SoA storage.
Definition data_layout_policy.h:404
static constexpr DataLayout Layout
Physical layout.
Definition data_layout_policy.h:407
static constexpr size_t Alignment
Required byte alignment.
Definition data_layout_policy.h:409
typename std::add_const< value_type< Item > >::type const_value_type
Const-qualified type of a reflected field.
Definition data_layout_policy.h:421
static GAIA_NODISCARD uint8_t * alloc(size_t cnt) noexcept
Allocates an SoA value range.
Definition data_layout_policy.h:437
decltype(meta::struct_to_tuple(std::declval< ValueType >())) TTuple
Tuple representation of the reflected value fields.
Definition data_layout_policy.h:402
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:427
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:476
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:578
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:493
static void free(void *pData, size_t cap, size_t cnt) noexcept
Releases an instrumented SoA value range.
Definition data_layout_policy.h:448
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:588
static constexpr size_t TTupleItems
Number of reflected fields.
Definition data_layout_policy.h:411
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:536
typename std::tuple_element< Item, TTuple >::type value_type
Type of a reflected field.
Definition data_layout_policy.h:417
Storage policy for a selected layout and item type.
Definition data_layout_policy.h:121