Struct vulkano::buffer::cpu_pool::CpuBufferPool
[−]
[src]
pub struct CpuBufferPool<T: ?Sized, A = Arc<StdMemoryPool>> where
A: MemoryPool, { /* fields omitted */ }
Buffer from which "sub-buffers" of fixed size can be individually allocated.
This buffer is especially suitable when you want to upload or download some data at each frame.
BufferUsage
A CpuBufferPool
is a bit similar to a Vec
. You start by creating an empty pool, then you
grab elements from the pool and use them, and if the pool is full it will automatically grow
in size.
But contrary to a Vec
, elements automatically free themselves when they are dropped (ie.
usually when they are no longer in use by the GPU).
Arc-like
The CpuBufferPool
struct internally contains an Arc
. You can clone the CpuBufferPool
for
a cheap cost, and all the clones will share the same underlying buffer.
Methods
impl<T> CpuBufferPool<T>
[src]
fn new<'a, I>(
device: Arc<Device>,
usage: BufferUsage,
queue_families: I
) -> CpuBufferPool<T> where
I: IntoIterator<Item = QueueFamily<'a>>,
device: Arc<Device>,
usage: BufferUsage,
queue_families: I
) -> CpuBufferPool<T> where
I: IntoIterator<Item = QueueFamily<'a>>,
fn upload(device: Arc<Device>) -> CpuBufferPool<T>
Builds a CpuBufferPool
meant for simple uploads.
Shortcut for a pool that can only be used as transfer sources and with exclusive queue family accesses.
impl<T> CpuBufferPool<[T]>
[src]
fn array<'a, I>(
device: Arc<Device>,
len: usize,
usage: BufferUsage,
queue_families: I
) -> CpuBufferPool<[T]> where
I: IntoIterator<Item = QueueFamily<'a>>,
device: Arc<Device>,
len: usize,
usage: BufferUsage,
queue_families: I
) -> CpuBufferPool<[T]> where
I: IntoIterator<Item = QueueFamily<'a>>,
impl<T: ?Sized> CpuBufferPool<T>
[src]
unsafe fn raw<'a, I>(
device: Arc<Device>,
one_size: usize,
usage: BufferUsage,
queue_families: I
) -> CpuBufferPool<T> where
I: IntoIterator<Item = QueueFamily<'a>>,
device: Arc<Device>,
one_size: usize,
usage: BufferUsage,
queue_families: I
) -> CpuBufferPool<T> where
I: IntoIterator<Item = QueueFamily<'a>>,
fn capacity(&self) -> usize
Returns the current capacity of the pool.
impl<T, A> CpuBufferPool<T, A> where
A: MemoryPool,
[src]
A: MemoryPool,
fn reserve(&self, capacity: usize) -> Result<(), OomError>
Sets the capacity to capacity
, or does nothing if the capacity is already higher.
Since this can involve a memory allocation, an OomError
can happen.
fn next(&self, data: T) -> CpuBufferPoolSubbuffer<T, A>
Grants access to a new subbuffer and puts data
in it.
If no subbuffer is available (because they are still in use by the GPU), a new buffer will automatically be allocated.
Note: You can think of it like a
Vec
. If you insert an element and theVec
is not large enough, a new chunk of memory is automatically allocated.
fn try_next(&self, data: T) -> Option<CpuBufferPoolSubbuffer<T, A>>
Grants access to a new subbuffer and puts data
in it.
Returns None
if no subbuffer is available.
A CpuBufferPool
is always empty the first time you use it, so you shouldn't use
try_next
the first time you use it.
Trait Implementations
impl<T: ?Sized, A> Clone for CpuBufferPool<T, A> where
A: MemoryPool + Clone,
[src]
A: MemoryPool + Clone,
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: ?Sized, A> DeviceOwned for CpuBufferPool<T, A> where
A: MemoryPool,
[src]
A: MemoryPool,