pub struct SharedMemoryDecl {
pub name: String,
pub element_type: WgslType,
pub dimensions: Vec<u32>,
}Expand description
Declaration of a shared memory variable.
Fields§
§name: StringVariable name.
element_type: WgslTypeElement type.
dimensions: Vec<u32>Dimensions (1D, 2D, etc.).
Implementations§
Sourcepub fn new_1d(name: &str, element_type: WgslType, size: u32) -> Self
pub fn new_1d(name: &str, element_type: WgslType, size: u32) -> Self
Create a 1D shared memory declaration.
Sourcepub fn new_2d(
name: &str,
element_type: WgslType,
width: u32,
height: u32,
) -> Self
pub fn new_2d( name: &str, element_type: WgslType, width: u32, height: u32, ) -> Self
Create a 2D shared memory declaration.
Sourcepub fn new_3d(
name: &str,
element_type: WgslType,
width: u32,
height: u32,
depth: u32,
) -> Self
pub fn new_3d( name: &str, element_type: WgslType, width: u32, height: u32, depth: u32, ) -> Self
Create a 3D shared memory declaration.
Sourcepub fn total_elements(&self) -> u32
pub fn total_elements(&self) -> u32
Total number of elements across all dimensions.
Sourcepub fn to_wgsl(&self) -> String
pub fn to_wgsl(&self) -> String
Generate WGSL declaration.
Generates nested arrays for multi-dimensional shared memory:
- 1D:
array<T, N> - 2D:
array<array<T, W>, H>(accessed asarr[y][x]) - 3D:
array<array<array<T, X>, Y>, Z>(accessed asarr[z][y][x]) - 4D+: Linearized 1D array with accessor comment
Sourcepub fn linearized_index_formula(&self, index_vars: &[&str]) -> Option<String>
pub fn linearized_index_formula(&self, index_vars: &[&str]) -> Option<String>
Generate index calculation for linearized access to higher-dimensional arrays.
For 4D+ arrays that are linearized, this generates the index formula.
E.g., for dims [W, H, D, T]: x + y * W + z * W * H + t * W * H * D
Trait Implementations§
Source§fn clone(&self) -> SharedMemoryDecl
fn clone(&self) -> SharedMemoryDecl
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
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