pub struct BufferContentsLayout(/* private fields */);Expand description
Describes the layout required for a type so that it can be read from/written to a buffer. This is used to allocate (sub)buffers generically.
This is similar to DeviceLayout except that this exists for the sole purpose of describing
the layout of buffer contents specifically. Which means for example that the sizedness of the
type is captured, as well as the layout of the head and tail if the layout is for unsized data,
in order to be able to represent everything that Vulkan can stuff in a buffer.
BufferContentsLayout also has an additional invariant compared to DeviceLayout: the
alignment of the data must not exceed 64. This is because that’s the guaranteed alignment
that all DeviceMemory blocks must be aligned to at minimum, and hence any greater alignment
can’t be guaranteed. Other than that, the invariant that sizes must be non-zero applies here as
well, for both sized data and the element type of unsized data.
Implementations§
Source§impl BufferContentsLayout
impl BufferContentsLayout
Sourcepub const fn head_size(&self) -> u64
pub const fn head_size(&self) -> u64
Returns the size of the head (sized part). If the data has no sized part, then this will return 0.
Sourcepub const fn element_size(&self) -> Option<u64>
pub const fn element_size(&self) -> Option<u64>
Returns the size of the element type if the data is unsized, or returns None.
Guaranteed to be non-zero.
Sourcepub const fn alignment(&self) -> DeviceAlignment
pub const fn alignment(&self) -> DeviceAlignment
Returns the alignment required for the data. Guaranteed to not exceed 64.
Sourcepub const fn layout_for_len(&self, len: NonZero<u64>) -> Option<DeviceLayout>
pub const fn layout_for_len(&self, len: NonZero<u64>) -> Option<DeviceLayout>
Returns the DeviceLayout for the data for the given len, or returns None on
arithmetic overflow or if the total size would exceed DeviceLayout::MAX_SIZE.
Trait Implementations§
Source§impl Clone for BufferContentsLayout
impl Clone for BufferContentsLayout
Source§fn clone(&self) -> BufferContentsLayout
fn clone(&self) -> BufferContentsLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more