Struct vulkano::buffer::immutable::ImmutableBuffer
source · pub struct ImmutableBuffer<T: ?Sized, A = PotentialDedicatedAllocation<StdMemoryPoolAlloc>> { /* private fields */ }
Expand description
Buffer that is written once then read for as long as it is alive.
Implementations
sourceimpl<T: ?Sized> ImmutableBuffer<T>
impl<T: ?Sized> ImmutableBuffer<T>
sourcepub fn from_data(
data: T,
usage: BufferUsage,
queue: Arc<Queue>
) -> Result<(Arc<ImmutableBuffer<T>>, CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), DeviceMemoryAllocError>where
T: 'static + Send + Sync + Sized,
pub fn from_data(
data: T,
usage: BufferUsage,
queue: Arc<Queue>
) -> Result<(Arc<ImmutableBuffer<T>>, CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), DeviceMemoryAllocError>where
T: 'static + Send + Sync + Sized,
Builds an ImmutableBuffer
from some data.
This function builds a memory-mapped intermediate buffer, writes the data to it, builds a command buffer that copies from this intermediate buffer to the final buffer, and finally submits the command buffer as a future.
This function returns two objects: the newly-created buffer, and a future representing
the initial upload operation. In order to be allowed to use the ImmutableBuffer
, you must
either submit your operation after this future, or execute this future and wait for it to
be finished before submitting your own operation.
sourcepub fn from_buffer<B>(
source: B,
usage: BufferUsage,
queue: Arc<Queue>
) -> Result<(Arc<ImmutableBuffer<T>>, CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), DeviceMemoryAllocError>where
B: BufferAccess + TypedBufferAccess<Content = T> + 'static + Clone + Send + Sync,
T: 'static + Send + Sync,
pub fn from_buffer<B>(
source: B,
usage: BufferUsage,
queue: Arc<Queue>
) -> Result<(Arc<ImmutableBuffer<T>>, CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), DeviceMemoryAllocError>where
B: BufferAccess + TypedBufferAccess<Content = T> + 'static + Clone + Send + Sync,
T: 'static + Send + Sync,
Builds an ImmutableBuffer
that copies its data from another buffer.
This function returns two objects: the newly-created buffer, and a future representing
the initial upload operation. In order to be allowed to use the ImmutableBuffer
, you must
either submit your operation after this future, or execute this future and wait for it to
be finished before submitting your own operation.
sourceimpl<T> ImmutableBuffer<T>
impl<T> ImmutableBuffer<T>
sourcepub unsafe fn uninitialized(
device: Arc<Device>,
usage: BufferUsage
) -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), DeviceMemoryAllocError>
pub unsafe fn uninitialized(
device: Arc<Device>,
usage: BufferUsage
) -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), DeviceMemoryAllocError>
Builds a new buffer with uninitialized data. Only allowed for sized data.
Returns two things: the buffer, and a special access that should be used for the initial upload to the buffer.
You will get an error if you try to use the buffer before using the initial upload access. However this function doesn’t check whether you actually used this initial upload to fill the buffer like you’re supposed to do.
You will also get an error if you try to get exclusive access to the final buffer.
Safety
- The
ImmutableBufferInitialization
should be used to fill the buffer with some initial data, otherwise the content is undefined.
sourceimpl<T> ImmutableBuffer<[T]>
impl<T> ImmutableBuffer<[T]>
pub fn from_iter<D>(
data: D,
usage: BufferUsage,
queue: Arc<Queue>
) -> Result<(Arc<ImmutableBuffer<[T]>>, CommandBufferExecFuture<NowFuture, AutoCommandBuffer>), DeviceMemoryAllocError>where
D: ExactSizeIterator<Item = T>,
T: 'static + Send + Sync + Sized,
sourcepub unsafe fn uninitialized_array(
device: Arc<Device>,
len: usize,
usage: BufferUsage
) -> Result<(Arc<ImmutableBuffer<[T]>>, ImmutableBufferInitialization<[T]>), DeviceMemoryAllocError>
pub unsafe fn uninitialized_array(
device: Arc<Device>,
len: usize,
usage: BufferUsage
) -> Result<(Arc<ImmutableBuffer<[T]>>, ImmutableBufferInitialization<[T]>), DeviceMemoryAllocError>
Builds a new buffer with uninitialized data. Can be used for arrays.
Returns two things: the buffer, and a special access that should be used for the initial upload to the buffer.
You will get an error if you try to use the buffer before using the initial upload access. However this function doesn’t check whether you actually used this initial upload to fill the buffer like you’re supposed to do.
You will also get an error if you try to get exclusive access to the final buffer.
Safety
- The
ImmutableBufferInitialization
should be used to fill the buffer with some initial data, otherwise the content is undefined.
sourceimpl<T: ?Sized> ImmutableBuffer<T>
impl<T: ?Sized> ImmutableBuffer<T>
sourcepub unsafe fn raw<'a, I>(
device: Arc<Device>,
size: usize,
usage: BufferUsage,
queue_families: I
) -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), DeviceMemoryAllocError>where
I: IntoIterator<Item = QueueFamily<'a>>,
pub unsafe fn raw<'a, I>(
device: Arc<Device>,
size: usize,
usage: BufferUsage,
queue_families: I
) -> Result<(Arc<ImmutableBuffer<T>>, ImmutableBufferInitialization<T>), DeviceMemoryAllocError>where
I: IntoIterator<Item = QueueFamily<'a>>,
Builds a new buffer without checking the size and granting free access for the initial upload.
Returns two things: the buffer, and a special access that should be used for the initial upload to the buffer. You will get an error if you try to use the buffer before using the initial upload access. However this function doesn’t check whether you used this initial upload to fill the buffer. You will also get an error if you try to get exclusive access to the final buffer.
Safety
- You must ensure that the size that you pass is correct for
T
. - The
ImmutableBufferInitialization
should be used to fill the buffer with some initial data.
sourceimpl<T: ?Sized, A> ImmutableBuffer<T, A>
impl<T: ?Sized, A> ImmutableBuffer<T, A>
sourcepub fn queue_families(&self) -> Vec<QueueFamily<'_>>
pub fn queue_families(&self) -> Vec<QueueFamily<'_>>
Returns the queue families this buffer can be used on.
Trait Implementations
sourceimpl<T: ?Sized, A> BufferAccess for ImmutableBuffer<T, A>
impl<T: ?Sized, A> BufferAccess for ImmutableBuffer<T, A>
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
) -> Result<(), AccessError>
fn try_gpu_lock(
&self,
exclusive_access: bool,
_: &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.