logo
pub trait WgslType {
    fn min_size() -> NonZeroU64 { ... }
fn size(&self) -> NonZeroU64 { ... }
fn assert_uniform_compat() { ... } }
Expand description

Base trait for all WGSL host-shareable types

Provided methods

Represents the minimum size of Self (equivalent to GPUBufferBindingLayout.minBindingSize)

For WGSL fixed-footprint types it represents WGSL Size (equivalent to Size::SIZE)

For WGSL runtime-sized arrays and WGSL structs containing runtime-sized arrays (non fixed-footprint types) this will be calculated by assuming the array has one element

Returns the size of Self at runtime

For WGSL fixed-footprint types it’s equivalent to Self::min_size and Size::SIZE

Asserts at compile time that Self meets the requirements of the uniform address space restrictions on stored values and the uniform address space layout constraints

Examples

Will not compile since runtime-sized arrays are not compatible with the uniform address space restrictions on stored values

<Vec<mint::Vector4<f32>>>::assert_uniform_compat();

Will not compile since the stride is 4 bytes

<[f32; 2]>::assert_uniform_compat();

Will compile since the stride is 16 bytes

<[mint::Vector4<f32>; 2]>::assert_uniform_compat();

Implementations on Foreign Types

Implementors