pub struct FluidGpuBuffer {
pub front: Vec<f64>,
pub back: Vec<f64>,
pub width: usize,
pub height: usize,
pub depth: usize,
pub components: usize,
}Expand description
A double-buffered GPU field for ping-pong updates.
front is the current read buffer; back is the current write buffer.
Call FluidGpuBuffer::swap after each kernel dispatch to advance.
Fields§
§front: Vec<f64>Front (read) buffer — size equals width * height * depth * components.
back: Vec<f64>Back (write) buffer — same size as front.
width: usizeNumber of grid cells in the x direction.
height: usizeNumber of grid cells in the y direction.
depth: usizeNumber of grid cells in the z direction (1 for 2-D grids).
components: usizeNumber of scalar components per cell (e.g. 3 for velocity, 1 for pressure).
Implementations§
Source§impl FluidGpuBuffer
impl FluidGpuBuffer
Sourcepub fn new(width: usize, height: usize, depth: usize, components: usize) -> Self
pub fn new(width: usize, height: usize, depth: usize, components: usize) -> Self
Allocate a zeroed double buffer for a width × height × depth grid with
components scalars per cell.
Sourcepub fn idx(&self, x: usize, y: usize, z: usize, c: usize) -> usize
pub fn idx(&self, x: usize, y: usize, z: usize, c: usize) -> usize
Flat index for cell (x, y, z) and component c.
Sourcepub fn read(&self, x: usize, y: usize, z: usize, c: usize) -> f64
pub fn read(&self, x: usize, y: usize, z: usize, c: usize) -> f64
Read a scalar from the front buffer.
Sourcepub fn write(&mut self, x: usize, y: usize, z: usize, c: usize, val: f64)
pub fn write(&mut self, x: usize, y: usize, z: usize, c: usize, val: f64)
Write a scalar to the back buffer.
Sourcepub fn copy_front_to_back(&mut self)
pub fn copy_front_to_back(&mut self)
Copy front into back.
Trait Implementations§
Source§impl Clone for FluidGpuBuffer
impl Clone for FluidGpuBuffer
Source§fn clone(&self) -> FluidGpuBuffer
fn clone(&self) -> FluidGpuBuffer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FluidGpuBuffer
impl RefUnwindSafe for FluidGpuBuffer
impl Send for FluidGpuBuffer
impl Sync for FluidGpuBuffer
impl Unpin for FluidGpuBuffer
impl UnsafeUnpin for FluidGpuBuffer
impl UnwindSafe for FluidGpuBuffer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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