pub struct ParticleBuffer { /* private fields */ }Expand description
Double-buffered particle storage for ping-pong compute dispatch.
One buffer is the “read” (source) and the other is the “write” (target).
After a compute dispatch, call swap() to flip them.
Implementations§
Source§impl ParticleBuffer
impl ParticleBuffer
Sourcepub fn create(
gl: &Context,
capacity: usize,
binding_read: u32,
binding_write: u32,
tracker: Arc<MemoryTracker>,
) -> Self
pub fn create( gl: &Context, capacity: usize, binding_read: u32, binding_write: u32, tracker: Arc<MemoryTracker>, ) -> Self
Create a double-buffered particle buffer.
Sourcepub fn bind(&self, gl: &Context)
pub fn bind(&self, gl: &Context)
Bind the read buffer to binding_read and write buffer to binding_write.
Sourcepub fn upload_initial(&mut self, gl: &Context, data: &[ParticleGpuData])
pub fn upload_initial(&mut self, gl: &Context, data: &[ParticleGpuData])
Upload initial particle data into the read buffer.
Sourcepub fn download(&self, gl: &Context) -> Vec<ParticleGpuData>
pub fn download(&self, gl: &Context) -> Vec<ParticleGpuData>
Download current read-buffer contents.
Sourcepub fn set_active_count(&mut self, count: usize)
pub fn set_active_count(&mut self, count: usize)
Set the active particle count (usually read back from atomic counter).
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Get the current active count.
Sourcepub fn resize(&mut self, gl: &Context, new_capacity: usize)
pub fn resize(&mut self, gl: &Context, new_capacity: usize)
Resize both buffers. Existing data is lost.
Sourcepub fn read_handle(&self) -> BufferHandle
pub fn read_handle(&self) -> BufferHandle
Read buffer handle (current source).
Sourcepub fn write_handle(&self) -> BufferHandle
pub fn write_handle(&self) -> BufferHandle
Write buffer handle (current target).
Auto Trait Implementations§
impl Freeze for ParticleBuffer
impl RefUnwindSafe for ParticleBuffer
impl Send for ParticleBuffer
impl Sync for ParticleBuffer
impl Unpin for ParticleBuffer
impl UnsafeUnpin for ParticleBuffer
impl UnwindSafe for ParticleBuffer
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<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>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> 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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.