Struct vulkano::buffer::cpu_access::CpuAccessibleBuffer
source · [−]pub struct CpuAccessibleBuffer<T, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> where
T: BufferContents + ?Sized, { /* private fields */ }
Expand description
Buffer whose content is accessible by the CPU.
Setting the host_cached
field on the various initializers to true
will make it so
the CpuAccessibleBuffer
prefers to allocate from host_cached memory. Host cached
memory caches GPU data on the CPU side. This can be more performant in cases where
the cpu needs to read data coming off the GPU.
Implementations
sourceimpl<T> CpuAccessibleBuffer<T> where
T: BufferContents,
impl<T> CpuAccessibleBuffer<T> where
T: BufferContents,
sourcepub fn from_data(
device: Arc<Device>,
usage: BufferUsage,
host_cached: bool,
data: T
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocationError>
pub fn from_data(
device: Arc<Device>,
usage: BufferUsage,
host_cached: bool,
data: T
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocationError>
Builds a new buffer with some data in it. Only allowed for sized data.
Panics
- Panics if
T
has zero size.
sourcepub unsafe fn uninitialized(
device: Arc<Device>,
usage: BufferUsage,
host_cached: bool
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocationError>
pub unsafe fn uninitialized(
device: Arc<Device>,
usage: BufferUsage,
host_cached: bool
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocationError>
sourceimpl<T> CpuAccessibleBuffer<[T]> where
[T]: BufferContents,
impl<T> CpuAccessibleBuffer<[T]> where
[T]: BufferContents,
sourcepub fn from_iter<I>(
device: Arc<Device>,
usage: BufferUsage,
host_cached: bool,
data: I
) -> Result<Arc<CpuAccessibleBuffer<[T]>>, DeviceMemoryAllocationError> where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
pub fn from_iter<I>(
device: Arc<Device>,
usage: BufferUsage,
host_cached: bool,
data: I
) -> Result<Arc<CpuAccessibleBuffer<[T]>>, DeviceMemoryAllocationError> where
I: IntoIterator<Item = T>,
I::IntoIter: ExactSizeIterator,
Builds a new buffer that contains an array T
. The initial data comes from an iterator
that produces that list of Ts.
Panics
- Panics if
T
has zero size. - Panics if
data
is empty.
sourcepub unsafe fn uninitialized_array(
device: Arc<Device>,
len: DeviceSize,
usage: BufferUsage,
host_cached: bool
) -> Result<Arc<CpuAccessibleBuffer<[T]>>, DeviceMemoryAllocationError>
pub unsafe fn uninitialized_array(
device: Arc<Device>,
len: DeviceSize,
usage: BufferUsage,
host_cached: bool
) -> Result<Arc<CpuAccessibleBuffer<[T]>>, DeviceMemoryAllocationError>
Builds a new buffer. Can be used for arrays.
Panics
- Panics if
T
has zero size. - Panics if
len
is zero.
sourceimpl<T> CpuAccessibleBuffer<T> where
T: BufferContents + ?Sized,
impl<T> CpuAccessibleBuffer<T> where
T: BufferContents + ?Sized,
sourcepub unsafe fn raw<'a, I>(
device: Arc<Device>,
size: DeviceSize,
usage: BufferUsage,
host_cached: bool,
queue_families: I
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocationError> where
I: IntoIterator<Item = QueueFamily<'a>>,
pub unsafe fn raw<'a, I>(
device: Arc<Device>,
size: DeviceSize,
usage: BufferUsage,
host_cached: bool,
queue_families: I
) -> Result<Arc<CpuAccessibleBuffer<T>>, DeviceMemoryAllocationError> where
I: IntoIterator<Item = QueueFamily<'a>>,
sourceimpl<T, A> CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
impl<T, A> CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
sourcepub fn queue_families(&self) -> Vec<QueueFamily<'_>>
pub fn queue_families(&self) -> Vec<QueueFamily<'_>>
Returns the queue families this buffer can be used on.
sourceimpl<T, A> CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: MemoryPoolAlloc,
impl<T, A> CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: MemoryPoolAlloc,
sourcepub fn read(&self) -> Result<ReadLock<'_, T>, ReadLockError>
pub fn read(&self) -> Result<ReadLock<'_, T>, ReadLockError>
Locks the buffer in order to read its content from the CPU.
If the buffer is currently used in exclusive mode by the GPU, this function will return
an error. Similarly if you called write()
on the buffer and haven’t dropped the lock,
this function will return an error as well.
After this function successfully locks the buffer, any attempt to submit a command buffer that uses it in exclusive mode will fail. You can still submit this buffer for non-exclusive accesses (ie. reads).
sourcepub fn write(&self) -> Result<WriteLock<'_, T>, WriteLockError>
pub fn write(&self) -> Result<WriteLock<'_, T>, WriteLockError>
Locks the buffer in order to write its content from the CPU.
If the buffer is currently in use by the GPU, this function will return an error. Similarly
if you called read()
on the buffer and haven’t dropped the lock, this function will
return an error as well.
After this function successfully locks the buffer, any attempt to submit a command buffer
that uses it and any attempt to call read()
will return an error.
Trait Implementations
sourceimpl<T, A> BufferAccess for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
impl<T, A> BufferAccess for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
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.
sourcefn conflict_key(&self) -> (u64, u64)
fn conflict_key(&self) -> (u64, u64)
Returns a key that uniquely identifies the buffer. Two buffers or images that potentially overlap in memory must return the same key. Read more
sourcefn try_gpu_lock(
&self,
exclusive_access: bool,
_: &Queue
) -> Result<(), AccessError>
fn try_gpu_lock(
&self,
exclusive_access: bool,
_: &Queue
) -> Result<(), AccessError>
Locks the resource for usage on the GPU. Returns an error if the lock can’t be acquired. Read more
sourceunsafe fn increase_gpu_lock(&self)
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. Read more
sourceunsafe fn unlock(&self)
unsafe fn unlock(&self)
Unlocks the resource previously acquired with try_gpu_lock
or increase_gpu_lock
. Read more
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. Read more
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. Read more
sourcefn raw_device_address(&self) -> Result<NonZeroU64, BufferDeviceAddressError>
fn raw_device_address(&self) -> Result<NonZeroU64, BufferDeviceAddressError>
Gets the device address for this buffer. Read more
sourceimpl<T: Debug, A: Debug> Debug for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
impl<T: Debug, A: Debug> Debug for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
sourceimpl<T, A> DeviceOwned for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
impl<T, A> DeviceOwned for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
sourceimpl<T, A> Hash for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
impl<T, A> Hash for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
sourceimpl<T, A> PartialEq<CpuAccessibleBuffer<T, A>> for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
impl<T, A> PartialEq<CpuAccessibleBuffer<T, A>> for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
sourceimpl<T, A> TypedBufferAccess for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
impl<T, A> TypedBufferAccess for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
type Content = T
type Content = T
The type of the content.
sourcefn len(&self) -> DeviceSize
fn len(&self) -> DeviceSize
Returns the length of the buffer in number of elements. Read more
impl<T, A> Eq for CpuAccessibleBuffer<T, A> where
T: BufferContents + ?Sized,
A: Send + Sync,
Auto Trait Implementations
impl<T, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> !RefUnwindSafe for CpuAccessibleBuffer<T, A>
impl<T: ?Sized, A> Send for CpuAccessibleBuffer<T, A> where
A: Send,
impl<T: ?Sized, A> Sync for CpuAccessibleBuffer<T, A> where
A: Sync,
impl<T: ?Sized, A> Unpin for CpuAccessibleBuffer<T, A> where
A: Unpin,
impl<T: ?Sized, A> UnwindSafe for CpuAccessibleBuffer<T, A> where
A: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more