Struct vulkano::buffer::subbuffer::BufferContentsLayout
source · 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) -> DeviceSize
pub const fn head_size(&self) -> DeviceSize
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<DeviceSize>
pub const fn element_size(&self) -> Option<DeviceSize>
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: NonZeroDeviceSize
) -> Option<DeviceLayout>
pub const fn layout_for_len( &self, len: NonZeroDeviceSize ) -> 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 moresource§impl Debug for BufferContentsLayout
impl Debug for BufferContentsLayout
source§impl Hash for BufferContentsLayout
impl Hash for BufferContentsLayout
source§impl PartialEq for BufferContentsLayout
impl PartialEq for BufferContentsLayout
source§fn eq(&self, other: &BufferContentsLayout) -> bool
fn eq(&self, other: &BufferContentsLayout) -> bool
self
and other
values to be equal, and is used
by ==
.