Skip to main content

WGSLPrimitiveHelper

Struct WGSLPrimitiveHelper 

Source
pub struct WGSLPrimitiveHelper;
Expand description

Helpers for constructing common WGSL primitive expressions and patterns.

Implementations§

Source§

impl WGSLPrimitiveHelper

Source

pub fn vec2f(x: f32, y: f32) -> String

Generate a vec2f(x, y) constructor expression.

Source

pub fn vec3f(x: f32, y: f32, z: f32) -> String

Generate a vec3f(x, y, z) constructor expression.

Source

pub fn vec4f(x: f32, y: f32, z: f32, w: f32) -> String

Generate a vec4f(x, y, z, w) constructor expression.

Source

pub fn vec2u(x: u32, y: u32) -> String

Generate a vec2u(x, y) constructor expression.

Source

pub fn vec3u(x: u32, y: u32, z: u32) -> String

Generate a vec3u(x, y, z) constructor expression.

Source

pub fn mat4x4_identity() -> String

Generate a mat4x4<f32> identity matrix constructor.

Source

pub fn perspective_matrix( fov_y_rad: f32, aspect: f32, near: f32, far: f32, ) -> String

Generate a mat4x4f perspective projection matrix.

Source

pub fn ortho_matrix( left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32, ) -> String

Generate an orthographic projection matrix.

Source

pub fn swizzle(base: &str, components: &str) -> String

Generate a swizzle expression (e.g., v.xyz).

Source

pub fn select(false_val: &str, true_val: &str, cond: &str) -> String

Generate a ternary select expression: select(false_val, true_val, cond).

Source

pub fn atomic_add(ptr: &str, val: &str) -> String

Generate an atomicAdd expression.

Source

pub fn barrier() -> &'static str

Generate a workgroupBarrier() call statement.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.