Struct vulkano::buffer::BufferSlice
source · pub struct BufferSlice<T: ?Sized, B> { /* private fields */ }
Expand description
A subpart of a buffer.
This object doesn’t correspond to any Vulkan object. It exists for API convenience.
Example
Creating a slice:
use vulkano::buffer::BufferSlice;
let _slice = BufferSlice::from(&buffer);
Selecting a slice of a buffer that contains [T]
:
use vulkano::buffer::BufferSlice;
let _slice = BufferSlice::from(&buffer).slice(12 .. 14).unwrap();
Implementations
sourceimpl<T: ?Sized, B> BufferSlice<T, B>
impl<T: ?Sized, B> BufferSlice<T, B>
pub fn from_typed_buffer_access(r: B) -> BufferSlice<T, B>where
B: TypedBufferAccess<Content = T>,
sourcepub unsafe fn slice_custom<F, R: ?Sized>(self, f: F) -> BufferSlice<R, B>where
F: for<'r> FnOnce(&'r T) -> &'r R,
pub unsafe fn slice_custom<F, R: ?Sized>(self, f: F) -> BufferSlice<R, B>where
F: for<'r> FnOnce(&'r T) -> &'r R,
Builds a slice that contains an element from inside the buffer.
This method builds an object that represents a slice of the buffer. No actual operation is performed.
Example
TODO
Safety
The object whose reference is passed to the closure is uninitialized. Therefore you must not access the content of the object.
You must return a reference to an element from the parameter. The closure must not panic.
sourcepub unsafe fn reinterpret<R: ?Sized>(self) -> BufferSlice<R, B>
pub unsafe fn reinterpret<R: ?Sized>(self) -> BufferSlice<R, B>
Changes the T
generic parameter of the BufferSlice
to the desired type. This can be
useful when you have a buffer with various types of data and want to create a typed slice
of a region that contains a single type of data.
Example
let blob_slice: BufferSlice<[u8], Arc<ImmutableBuffer<[u8]>>> = return;
let vertex_slice: BufferSlice<[VertexImpl], Arc<ImmutableBuffer<[u8]>>> = unsafe {
blob_slice.reinterpret::<[VertexImpl]>()
};
Safety
Correct offset
and size
must be ensured before using this BufferSlice
on the device.
See BufferSlice::slice
for adjusting these properties.
sourceimpl<T, B> BufferSlice<[T], B>
impl<T, B> BufferSlice<[T], B>
sourcepub fn index(self, index: usize) -> Option<BufferSlice<T, B>>
pub fn index(self, index: usize) -> Option<BufferSlice<T, B>>
Reduces the slice to just one element of the array.
Returns None
if out of range.
Trait Implementations
sourceimpl<T: ?Sized, B> BufferAccess for BufferSlice<T, B>where
B: BufferAccess,
impl<T: ?Sized, B> BufferAccess for BufferSlice<T, B>where
B: BufferAccess,
sourcefn inner(&self) -> BufferInner<'_>
fn inner(&self) -> BufferInner<'_>
sourcefn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
self
potentially overlaps the same memory as an access to
other
. Read moresourcefn conflicts_image(&self, other: &dyn ImageAccess) -> bool
fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
self
potentially overlaps the same memory as an access to
other
. Read moresourcefn conflict_key(&self) -> (u64, usize)
fn conflict_key(&self) -> (u64, usize)
sourcefn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
sourceunsafe fn increase_gpu_lock(&self)
unsafe fn increase_gpu_lock(&self)
sourcefn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self>where
Self: Sized + TypedBufferAccess,
fn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self>where
Self: Sized + TypedBufferAccess,
BufferSlice
object holding the buffer by reference.sourcefn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>>where
Self: Sized + TypedBufferAccess<Content = [T]>,
fn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>>where
Self: Sized + TypedBufferAccess<Content = [T]>,
BufferSlice
object holding part of the buffer by reference. Read moresourcefn into_buffer_slice(self) -> BufferSlice<Self::Content, Self>where
Self: Sized + TypedBufferAccess,
fn into_buffer_slice(self) -> BufferSlice<Self::Content, Self>where
Self: Sized + TypedBufferAccess,
BufferSlice
object holding the buffer by value.