pub struct AtomicRawBufferVec<T>where
T: AtomicPod,{ /* private fields */ }Expand description
A RawBufferVec that holds data that implements AtomicPod.
This allows multiple threads to update the buffer to be sent to the GPU simultaneously. Note that they may only update existing data; pushing new data still requires exclusive access.
Implementations§
Source§impl<T> AtomicRawBufferVec<T>where
T: AtomicPod,
impl<T> AtomicRawBufferVec<T>where
T: AtomicPod,
Sourcepub const fn new(buffer_usage: BufferUsages) -> Self
pub const fn new(buffer_usage: BufferUsages) -> Self
Creates a new AtomicRawBufferVec.
The buffer_usage parameter tells wgpu which usages are allowed for
the backing buffer.
Sourcepub fn with_label(buffer_usage: BufferUsages, label: &str) -> Self
pub fn with_label(buffer_usage: BufferUsages, label: &str) -> Self
Creates a new AtomicRawBufferVec with a custom label.
The buffer_usage parameter tells wgpu which usages are allowed for
the backing buffer.
Sourcepub fn push(&mut self, value: T) -> u32
pub fn push(&mut self, value: T) -> u32
Adds a new value to the buffer, and returns its index.
Internally, the value is converted to its blob representation.
Sourcepub fn set(&self, index: u32, value: T)
pub fn set(&self, index: u32, value: T)
Sets the value at the given index.
If the index isn’t in range of the buffer, this method panics.
Internally, the value is converted to its blob representation.
Note that this method is thread-safe and doesn’t require &mut self.
It’s your responsibility, however, to ensure synchronization; though
this method is memory-safe, it’s possible for other threads to observe
partially-overwritten values if Self::get or similar methods are
called while the write operation is occurring.
Sourcepub fn reserve(&mut self, capacity: usize, device: &RenderDevice)
pub fn reserve(&mut self, capacity: usize, device: &RenderDevice)
Creates a Buffer on the RenderDevice with size
at least size_of::<T>() * capacity, unless a such a buffer already exists.
If a Buffer exists, but is too small, references to it will be discarded,
and a new Buffer will be created. Any previously created Buffers
that are no longer referenced will be deleted by the RenderDevice
once it is done using them (typically 1-2 frames).
In addition to any BufferUsages provided when
the AtomicRawBufferVec was created, the buffer on the RenderDevice
is marked as BufferUsages::COPY_DST.
Sourcepub fn write_buffer(&mut self, device: &RenderDevice, queue: &RenderQueue)
pub fn write_buffer(&mut self, device: &RenderDevice, queue: &RenderQueue)
Queues writing of data from system RAM to VRAM using the
RenderDevice and the provided RenderQueue.
Before queuing the write, a reserve
operation is executed.
Sourcepub fn write_buffer_range(
&mut self,
range: Range<usize>,
device: &RenderDevice,
queue: &RenderQueue,
)
pub fn write_buffer_range( &mut self, range: Range<usize>, device: &RenderDevice, queue: &RenderQueue, )
Queues writing of data from system RAM to VRAM using the
RenderDevice and the provided RenderQueue.
Before queuing the write, a reserve
operation is executed.
Sourcepub fn buffer(&self) -> Option<&Buffer>
pub fn buffer(&self) -> Option<&Buffer>
Returns a handle to the buffer, if the data has been uploaded.
Auto Trait Implementations§
impl<T> Freeze for AtomicRawBufferVec<T>
impl<T> !RefUnwindSafe for AtomicRawBufferVec<T>
impl<T> Send for AtomicRawBufferVec<T>
impl<T> Sync for AtomicRawBufferVec<T>
impl<T> Unpin for AtomicRawBufferVec<T>
impl<T> UnsafeUnpin for AtomicRawBufferVec<T>
impl<T> !UnwindSafe for AtomicRawBufferVec<T>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more