42 PH_ASSERT(out_regionInfo);
44 const Region region = regionStatus.getRegion();
45 const ERegionStatus status = regionStatus.getStatus();
47 out_regionInfo->
xPx =
static_cast<PhUInt32>(region.getMinVertex().x());
48 out_regionInfo->
yPx =
static_cast<PhUInt32>(region.getMinVertex().y());
56 std::size_t numArrayElements,
58 bool allowBufferGrowth)
62 using NonConstT = std::remove_const_t<T>;
64 static_assert(std::is_default_constructible_v<NonConstT>);
65 static_assert(std::is_trivially_destructible_v<NonConstT>);
67 const auto alignmentInBytes =
alignof(NonConstT);
68 const auto arraySizeInBytes =
sizeof(NonConstT) * numArrayElements;
70 void* ptr = buffer.getBytes().data() + buffer.getWritePosition();
71 std::size_t availableBytes = buffer.numBytes() - buffer.getWritePosition();
72 void* alignedPtr = std::align(alignmentInBytes, arraySizeInBytes, ptr, availableBytes);
75 if(!alignedPtr && allowBufferGrowth)
78 buffer.setNumBytes(buffer.getWritePosition() + arraySizeInBytes + alignmentInBytes);
81 ptr = buffer.getBytes().data() + buffer.getWritePosition();
82 availableBytes = buffer.numBytes() - buffer.getWritePosition();
83 alignedPtr = std::align(alignmentInBytes, arraySizeInBytes, ptr, availableBytes);
85 PH_ASSERT(alignedPtr);
94 PH_ASSERT(alignedPtr);
99 std::byte* endPtr =
static_cast<std::byte*
>(ptr) + arraySizeInBytes;
100 buffer.setWritePosition(endPtr - buffer.getBytes().data());
103 PH_ASSERT_GE(availableBytes, arraySizeInBytes);
108 NonConstT*
const storage = start_implicit_lifetime_as_array<NonConstT>(alignedPtr, arraySizeInBytes);
111 std::uninitialized_default_construct_n(storage, numArrayElements);
114 return TSpan<NonConstT>(storage, numArrayElements);
TSpan< T > make_array_from_buffer(std::size_t numArrayElements, ByteBuffer &buffer, bool allowBufferGrowth=false)
Make an array of default constructed objects of type T.
Definition api_helpers.ipp:55
PhEndian
Indicates the endianness. This type is not for detecting endianness of the current platform,...
Definition ph_c_core_types.h:35