pub struct RawBuffer { /* private fields */ }
Expand description
A raw buffer, with no memory backing it.
This is the basic buffer type, a direct translation of a VkBuffer
object, but it is mostly
useless in this form. After creating a raw buffer, you must call bind_memory
to make a
complete buffer object.
Implementations§
Source§impl RawBuffer
impl RawBuffer
Sourcepub fn new(
device: Arc<Device>,
create_info: BufferCreateInfo,
) -> Result<Self, Validated<VulkanError>>
pub fn new( device: Arc<Device>, create_info: BufferCreateInfo, ) -> Result<Self, Validated<VulkanError>>
Creates a new RawBuffer
.
§Panics
- Panics if
create_info.sharing
isConcurrent
with less than 2 items. - Panics if
create_info.size
is zero. - Panics if
create_info.usage
is empty.
Sourcepub unsafe fn from_handle(
device: Arc<Device>,
handle: Buffer,
create_info: BufferCreateInfo,
) -> Self
pub unsafe fn from_handle( device: Arc<Device>, handle: Buffer, create_info: BufferCreateInfo, ) -> Self
Creates a new RawBuffer
from a raw object handle.
§Safety
handle
must be a valid Vulkan object handle created fromdevice
.create_info
must match the info used to create the object.- If the buffer has memory bound to it,
bind_memory
must not be called on the returnedRawBuffer
.
Sourcepub unsafe fn from_handle_borrowed(
device: Arc<Device>,
handle: Buffer,
create_info: BufferCreateInfo,
) -> Self
pub unsafe fn from_handle_borrowed( device: Arc<Device>, handle: Buffer, create_info: BufferCreateInfo, ) -> Self
Creates a new RawBuffer
from a raw object handle. Unlike from_handle
, the created
RawBuffer
does not destroy the inner buffer when dropped.
§Safety
handle
must be a valid Vulkan object handle created fromdevice
.create_info
must match the info used to create the object.- If the buffer has memory bound to it,
bind_memory
must not be called on the returnedRawBuffer
. - Caller must ensure that the handle will not be destroyed for the lifetime of returned
RawBuffer
.
Sourcepub fn bind_memory(
self,
allocation: ResourceMemory,
) -> Result<Buffer, (Validated<VulkanError>, RawBuffer, ResourceMemory)>
pub fn bind_memory( self, allocation: ResourceMemory, ) -> Result<Buffer, (Validated<VulkanError>, RawBuffer, ResourceMemory)>
Binds device memory to this buffer.
Sourcepub unsafe fn assume_bound(self) -> Buffer
pub unsafe fn assume_bound(self) -> Buffer
Converts a raw buffer into a full buffer without binding any memory.
§Safety
If self.flags()
does not contain BufferCreateFlags::SPARSE_BINDING
:
- The buffer must already have a suitable memory allocation bound to it.
If self.flags()
does contain BufferCreateFlags::SPARSE_BINDING
:
- If
self.flags()
does not containBufferCreateFlags::SPARSE_RESIDENCY
, then the buffer must be fully bound with memory before its memory is accessed by the device. - If
self.flags()
containsBufferCreateFlags::SPARSE_RESIDENCY
, then you must ensure that any reads from the buffer are prepared to handle unexpected or inconsistent values, as determined by theresidency_non_resident_strict
device property.
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.