[−][src]Trait vulkano::buffer::BufferAccess
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
pub fn inner(&self) -> BufferInner<'_>
[src]
Returns the inner information about this buffer.
pub fn size(&self) -> usize
[src]
Returns the size of the buffer in bytes.
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
Returns true if an access to self
potentially overlaps the same memory as an access to
other
.
If this function returns false
, this means that we are allowed to mutably access the
content of self
at the same time as the content of other
without causing a data
race.
Note that the function must be transitive. In other words if conflicts(a, b)
is true and
conflicts(b, c)
is true, then conflicts(a, c)
must be true as well.
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
Returns true if an access to self
potentially overlaps the same memory as an access to
other
.
If this function returns false
, this means that we are allowed to mutably access the
content of self
at the same time as the content of other
without causing a data
race.
Note that the function must be transitive. In other words if conflicts(a, b)
is true and
conflicts(b, c)
is true, then conflicts(a, c)
must be true as well.
pub fn conflict_key(&self) -> (u64, usize)
[src]
Returns a key that uniquely identifies the buffer. Two buffers or images that potentially overlap in memory must 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.
pub fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
[src]
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
Locks the resource for usage on the GPU. Returns an error if the lock can't be acquired.
This function exists to prevent the user from causing a data race by reading and writing to the same resource at the same time.
If you call this function, you should call unlock()
once the resource is no longer in use
by the GPU. The implementation is not expected to automatically perform any unlocking and
can rely on the fact that unlock()
is going to be called.
pub unsafe fn increase_gpu_lock(&self)
[src]
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.
If you call this function, you should call unlock()
once the resource is no longer in use
by the GPU. The implementation is not expected to automatically perform any unlocking and
can rely on the fact that unlock()
is going to be called.
pub unsafe fn unlock(&self)
[src]
Unlocks the resource previously acquired with try_gpu_lock
or increase_gpu_lock
.
Safety
Must only be called once per previous lock.
Provided methods
pub fn as_buffer_slice(&self) -> BufferSlice<Self::Content, &Self> where
Self: Sized + TypedBufferAccess,
[src]
Self: Sized + TypedBufferAccess,
Builds a BufferSlice
object holding the buffer by reference.
pub fn slice<T>(&self, range: Range<usize>) -> Option<BufferSlice<[T], &Self>> where
Self: Sized + TypedBufferAccess<Content = [T]>,
[src]
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.
pub fn into_buffer_slice(self) -> BufferSlice<Self::Content, Self> where
Self: Sized + TypedBufferAccess,
[src]
Self: Sized + TypedBufferAccess,
Builds a BufferSlice
object holding the buffer by value.
pub fn index<T>(&self, index: usize) -> Option<BufferSlice<[T], &Self>> where
Self: Sized + TypedBufferAccess<Content = [T]>,
[src]
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.
pub fn raw_device_address(
&self
) -> Result<NonZeroU64, DeviceAddressUsageNotEnabledError>
[src]
&self
) -> Result<NonZeroU64, DeviceAddressUsageNotEnabledError>
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.
Trait Implementations
impl Eq for dyn BufferAccess + Send + Sync
[src]
impl Hash for dyn BufferAccess + Send + Sync
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<dyn BufferAccess + 'static + Sync + Send> for dyn BufferAccess + Send + Sync
[src]
Implementors
impl<T> BufferAccess for T where
T: SafeDeref,
T::Target: BufferAccess,
[src]
T: SafeDeref,
T::Target: BufferAccess,
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
[src]
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T, A> BufferAccess for CpuBufferPoolChunk<T, A> where
A: MemoryPool,
[src]
A: MemoryPool,
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(&self, _: bool, _: &Queue) -> Result<(), AccessError>
[src]
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T, A> BufferAccess for CpuBufferPoolSubbuffer<T, A> where
A: MemoryPool,
[src]
A: MemoryPool,
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(&self, e: bool, q: &Queue) -> Result<(), AccessError>
[src]
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T: ?Sized, A> BufferAccess for CpuAccessibleBuffer<T, A> where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(
&self,
exclusive_access: bool,
_: &Queue
) -> Result<(), AccessError>
[src]
&self,
exclusive_access: bool,
_: &Queue
) -> Result<(), AccessError>
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T: ?Sized, A> BufferAccess for DeviceLocalBuffer<T, A> where
T: 'static + Send + Sync,
[src]
T: 'static + Send + Sync,
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(
&self,
exclusive: bool,
_: &Queue
) -> Result<(), AccessError>
[src]
&self,
exclusive: bool,
_: &Queue
) -> Result<(), AccessError>
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T: ?Sized, A> BufferAccess for ImmutableBuffer<T, A>
[src]
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(
&self,
exclusive_access: bool,
_: &Queue
) -> Result<(), AccessError>
[src]
&self,
exclusive_access: bool,
_: &Queue
) -> Result<(), AccessError>
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T: ?Sized, A> BufferAccess for ImmutableBufferInitialization<T, A>
[src]
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(&self, _: bool, _: &Queue) -> Result<(), AccessError>
[src]
pub unsafe fn increase_gpu_lock(&self)
[src]
pub unsafe fn unlock(&self)
[src]
impl<T: ?Sized, B> BufferAccess for BufferSlice<T, B> where
B: BufferAccess,
[src]
B: BufferAccess,
pub fn inner(&self) -> BufferInner<'_>
[src]
pub fn size(&self) -> usize
[src]
pub fn conflicts_buffer(&self, other: &dyn BufferAccess) -> bool
[src]
pub fn conflicts_image(&self, other: &dyn ImageAccess) -> bool
[src]
pub fn conflict_key(&self) -> (u64, usize)
[src]
pub fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
[src]
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>