Trait vulkano::buffer::BufferAccess
source · [−]pub unsafe trait BufferAccess: DeviceOwned + Send + Sync {
fn inner(&self) -> BufferInner<'_>;
fn size(&self) -> DeviceSize;
fn usage(&self) -> &BufferUsage { ... }
fn into_buffer_slice(
self: &Arc<Self>
) -> Arc<BufferSlice<Self::Content, Self>>
where
Self: Sized + TypedBufferAccess,
{ ... }
fn slice<T>(
self: &Arc<Self>,
range: Range<DeviceSize>
) -> Option<Arc<BufferSlice<[T], Self>>>
where
Self: Sized + TypedBufferAccess<Content = [T]>,
{ ... }
fn index<T>(
self: &Arc<Self>,
index: DeviceSize
) -> Option<Arc<BufferSlice<T, Self>>>
where
Self: Sized + TypedBufferAccess<Content = [T]>,
{ ... }
fn raw_device_address(&self) -> Result<NonZeroU64, BufferDeviceAddressError> { ... }
}
Expand description
Trait for objects that represent a way for the GPU to have access to a buffer or a slice of a buffer.
See also TypedBufferAccess
.
Required Methods
sourcefn inner(&self) -> BufferInner<'_>
fn inner(&self) -> BufferInner<'_>
Returns the inner information about this buffer.
sourcefn size(&self) -> DeviceSize
fn size(&self) -> DeviceSize
Returns the size of the buffer in bytes.
Provided Methods
sourcefn usage(&self) -> &BufferUsage
fn usage(&self) -> &BufferUsage
Returns the usage the buffer was created with.
sourcefn into_buffer_slice(self: &Arc<Self>) -> Arc<BufferSlice<Self::Content, Self>>where
Self: Sized + TypedBufferAccess,
fn into_buffer_slice(self: &Arc<Self>) -> Arc<BufferSlice<Self::Content, Self>>where
Self: Sized + TypedBufferAccess,
Returns a BufferSlice
covering the whole buffer.
sourcefn slice<T>(
self: &Arc<Self>,
range: Range<DeviceSize>
) -> Option<Arc<BufferSlice<[T], Self>>>where
Self: Sized + TypedBufferAccess<Content = [T]>,
fn slice<T>(
self: &Arc<Self>,
range: Range<DeviceSize>
) -> Option<Arc<BufferSlice<[T], Self>>>where
Self: Sized + TypedBufferAccess<Content = [T]>,
Returns a BufferSlice
for a subrange of elements in the buffer. Returns None
if
out of range.
This method can be used when you want to perform an operation on some part of the buffer and not on the whole buffer.
sourcefn index<T>(
self: &Arc<Self>,
index: DeviceSize
) -> Option<Arc<BufferSlice<T, Self>>>where
Self: Sized + TypedBufferAccess<Content = [T]>,
fn index<T>(
self: &Arc<Self>,
index: DeviceSize
) -> Option<Arc<BufferSlice<T, Self>>>where
Self: Sized + TypedBufferAccess<Content = [T]>,
Returns a BufferSlice
for a single element in the buffer. Returns None
if out of range.
This method can be used when you want to perform an operation on a specific element of the buffer and not on the whole buffer.
sourcefn raw_device_address(&self) -> Result<NonZeroU64, BufferDeviceAddressError>
fn raw_device_address(&self) -> Result<NonZeroU64, BufferDeviceAddressError>
Gets the device address for this buffer.
Safety
No lock checking or waiting is performed. This is nevertheless still safe because the returned value isn’t directly dereferencable. Unsafe code is required to dereference the value in a shader.