pub struct Buffer { /* private fields */ }
Expand description
A storage for raw bytes.
Unlike RawBuffer
, a Buffer
has memory backing it, and can be used normally.
Implementations§
source§impl Buffer
impl Buffer
sourcepub fn memory(&self) -> &BufferMemory
pub fn memory(&self) -> &BufferMemory
Returns the type of memory that is backing this buffer.
sourcepub fn memory_requirements(&self) -> &MemoryRequirements
pub fn memory_requirements(&self) -> &MemoryRequirements
Returns the memory requirements for this buffer.
sourcepub fn flags(&self) -> BufferCreateFlags
pub fn flags(&self) -> BufferCreateFlags
Returns the flags the buffer was created with.
sourcepub fn size(&self) -> DeviceSize
pub fn size(&self) -> DeviceSize
Returns the size of the buffer in bytes.
sourcepub fn usage(&self) -> &BufferUsage
pub fn usage(&self) -> &BufferUsage
Returns the usage the buffer was created with.
sourcepub fn sharing(&self) -> &Sharing<SmallVec<[u32; 4]>>
pub fn sharing(&self) -> &Sharing<SmallVec<[u32; 4]>>
Returns the sharing the buffer was created with.
sourcepub fn external_memory_handle_types(&self) -> ExternalMemoryHandleTypes
pub fn external_memory_handle_types(&self) -> ExternalMemoryHandleTypes
Returns the external memory handle types that are supported with this buffer.
sourcepub fn read(
&self,
range: Range<DeviceSize>
) -> Result<BufferReadGuard<'_, [u8]>, BufferError>
pub fn read(
&self,
range: Range<DeviceSize>
) -> Result<BufferReadGuard<'_, [u8]>, BufferError>
Locks the buffer in order to read its content from the host.
If the buffer is currently used in exclusive mode by the device, this function will return
an error. Similarly if you called write()
on the buffer and haven’t dropped the lock,
this function will return an error as well.
After this function successfully locks the buffer, any attempt to submit a command buffer that uses it in exclusive mode will fail. You can still submit this buffer for non-exclusive accesses (ie. reads).
sourcepub fn write(
&self,
range: Range<DeviceSize>
) -> Result<BufferWriteGuard<'_>, BufferError>
pub fn write(
&self,
range: Range<DeviceSize>
) -> Result<BufferWriteGuard<'_>, BufferError>
Locks the buffer in order to write its content from the host.
If the buffer is currently in use by the device, this function will return an error.
Similarly if you called read()
on the buffer and haven’t dropped the lock, this function
will return an error as well.
After this function successfully locks the buffer, any attempt to submit a command buffer
that uses it and any attempt to call read()
will return an error.