pub struct GridPos {
pub x: i32,
pub y: i32,
pub idx: usize,
pub stride: usize,
}Expand description
Grid position context passed to stencil kernels.
This is a compile-time marker type. The transpiler recognizes method calls
on GridPos and converts them to WGSL index calculations.
Fields§
§x: i32X coordinate in the grid.
y: i32Y coordinate in the grid.
idx: usizeLinear index in the buffer.
stride: usizeBuffer stride (width).
Implementations§
Source§impl GridPos
impl GridPos
Sourcepub fn idx(&self) -> usize
pub fn idx(&self) -> usize
Get the linear index for the current position.
Maps to: idx (local variable in generated WGSL)
Sourcepub fn north<T: Copy>(&self, buffer: &[T]) -> T
pub fn north<T: Copy>(&self, buffer: &[T]) -> T
Access the north neighbor (y - 1).
Maps to: buffer[idx - buffer_width]
Sourcepub fn south<T: Copy>(&self, buffer: &[T]) -> T
pub fn south<T: Copy>(&self, buffer: &[T]) -> T
Access the south neighbor (y + 1).
Maps to: buffer[idx + buffer_width]
Sourcepub fn east<T: Copy>(&self, buffer: &[T]) -> T
pub fn east<T: Copy>(&self, buffer: &[T]) -> T
Access the east neighbor (x + 1).
Maps to: buffer[idx + 1]
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GridPos
impl RefUnwindSafe for GridPos
impl Send for GridPos
impl Sync for GridPos
impl Unpin for GridPos
impl UnwindSafe for GridPos
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