Trait vulkano::buffer::BufferAccess
[−]
[src]
pub unsafe trait BufferAccess: DeviceOwned { fn inner(&self) -> BufferInner; fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>; unsafe fn increase_gpu_lock(&self); fn size(&self) -> usize { ... } fn len(&self) -> usize
where
Self: TypedBufferAccess,
Self::Content: Content, { ... } fn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self>
where
Self: Sized + TypedBufferAccess, { ... } fn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>>
where
Self: Sized + TypedBufferAccess<Content = [T]>, { ... } fn into_buffer_slice(self) -> BufferSlice<Self::Content, Self>
where
Self: Sized + TypedBufferAccess, { ... } fn index<T>(&self, index: usize) -> Option<BufferSlice<[T], &Self>>
where
Self: Sized + TypedBufferAccess<Content = [T]>, { ... } fn conflicts_buffer(
&self,
self_offset: usize,
self_size: usize,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool { ... } fn conflicts_image(
&self,
self_offset: usize,
self_size: usize,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool { ... } fn conflict_key(&self, self_offset: usize, self_size: usize) -> u64 { ... } fn conflicts_buffer_all(&self, other: &BufferAccess) -> bool { ... } fn conflicts_image_all(&self, other: &ImageAccess) -> bool { ... } fn conflict_key_all(&self) -> u64 { ... } }
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
fn inner(&self) -> BufferInner
Returns the inner information about this buffer.
fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
Locks the resource for usage on the GPU. Returns false
if the lock was already acquired.
This function implementation should remember that it has been called and return false
if
it gets called a second time.
The only way to know that the GPU has stopped accessing a queue is when the buffer object gets destroyed. Therefore you are encouraged to use temporary objects or handles (similar to a lock) in order to represent a GPU access.
unsafe fn increase_gpu_lock(&self)
Locks the resource for usage on the GPU. Supposes that the resource is already locked, and simply increases the lock by one.
Must only be called after try_gpu_lock()
succeeded.
Provided Methods
fn size(&self) -> usize
Returns the size of the buffer in bytes.
fn len(&self) -> usize where
Self: TypedBufferAccess,
Self::Content: Content,
Self: TypedBufferAccess,
Self::Content: Content,
Returns the length of the buffer in number of elements.
This method can only be called for buffers whose type is known to be an array.
fn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self> where
Self: Sized + TypedBufferAccess,
Self: Sized + TypedBufferAccess,
Builds a BufferSlice
object holding the buffer by reference.
fn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>> where
Self: Sized + TypedBufferAccess<Content = [T]>,
Self: Sized + TypedBufferAccess<Content = [T]>,
Builds a BufferSlice
object holding part of the buffer by reference.
This method can only be called for buffers whose type is known to be an array.
This method can be used when you want to perform an operation on some part of the buffer and not on the whole buffer.
Returns None
if out of range.
fn into_buffer_slice(self) -> BufferSlice<Self::Content, Self> where
Self: Sized + TypedBufferAccess,
Self: Sized + TypedBufferAccess,
Builds a BufferSlice
object holding the buffer by value.
fn index<T>(&self, index: usize) -> Option<BufferSlice<[T], &Self>> where
Self: Sized + TypedBufferAccess<Content = [T]>,
Self: Sized + TypedBufferAccess<Content = [T]>,
Builds a BufferSlice
object holding part of the buffer by reference.
This method can only be called for buffers whose type is known to be an array.
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.
Returns None
if out of range.
fn conflicts_buffer(
&self,
self_offset: usize,
self_size: usize,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool
&self,
self_offset: usize,
self_size: usize,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool
Returns true if an access to self
(as defined by self_offset
and self_size
)
potentially overlaps the same memory as an access to other
(as defined by other_offset
and other_size
).
If this function returns false
, this means that we are allowed to access the offset/size
of self
at the same time as the offset/size of other
without causing a data race.
fn conflicts_image(
&self,
self_offset: usize,
self_size: usize,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool
&self,
self_offset: usize,
self_size: usize,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool
Returns true if an access to self
(as defined by self_offset
and self_size
)
potentially overlaps the same memory as an access to other
(as defined by
other_first_layer
, other_num_layers
, other_first_mipmap
and other_num_mipmaps
).
If this function returns false
, this means that we are allowed to access the offset/size
of self
at the same time as the offset/size of other
without causing a data race.
fn conflict_key(&self, self_offset: usize, self_size: usize) -> u64
Returns a key that uniquely identifies the range given by offset/size.
Two ranges that potentially overlap in memory should return the same key.
The key is shared amongst all buffers and images, which means that you can make several different buffer objects share the same memory, or make some buffer objects share memory with images, as long as they return the same key.
Since it is possible to accidentally return the same key for memory ranges that don't
overlap, the conflicts_buffer
or conflicts_image
function should always be called to
verify whether they actually overlap.
fn conflicts_buffer_all(&self, other: &BufferAccess) -> bool
Shortcut for conflicts_buffer
that compares the whole buffer to another.
fn conflicts_image_all(&self, other: &ImageAccess) -> bool
Shortcut for conflicts_image
that compares the whole buffer to a whole image.
fn conflict_key_all(&self) -> u64
Shortcut for conflict_key
that grabs the key of the whole buffer.
Implementors
impl<T: ?Sized, A> BufferAccess for CpuAccessibleBuffer<T, A> where
T: 'static + Send + Sync,
A: MemoryPool,impl<T: ?Sized, A> BufferAccess for CpuBufferPoolSubbuffer<T, A> where
A: MemoryPool,impl<P, T: ?Sized, A> BufferAccess for DeviceLocalBufferAccess<P> where
P: SafeDeref<Target = DeviceLocalBuffer<T, A>>,
T: 'static + Send + Sync,
A: MemoryPool + 'static,impl<T: ?Sized, A> BufferAccess for ImmutableBuffer<T, A>
impl<T: ?Sized, A> BufferAccess for ImmutableBufferInitialization<T, A>
impl<T: ?Sized, B> BufferAccess for BufferSlice<T, B> where
B: BufferAccess,impl<T> BufferAccess for T where
T: SafeDeref,
T::Target: BufferAccess,