Trait encase::ShaderType
source · pub trait ShaderType {
// Provided methods
fn min_size() -> NonZeroU64 { ... }
fn size(&self) -> NonZeroU64 { ... }
fn assert_uniform_compat() { ... }
}
Expand description
Base trait for all WGSL host-shareable types
Provided Methods§
sourcefn min_size() -> NonZeroU64
fn min_size() -> NonZeroU64
Represents the minimum size of Self
(equivalent to GPUBufferBindingLayout.minBindingSize)
For WGSL fixed-footprint types
it represents WGSL Size
(equivalent to ShaderSize::SHADER_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
sourcefn size(&self) -> NonZeroU64
fn size(&self) -> NonZeroU64
Returns the size of Self
at runtime
For WGSL fixed-footprint types
it’s equivalent to Self::min_size
and ShaderSize::SHADER_SIZE
sourcefn assert_uniform_compat()
fn assert_uniform_compat()
Asserts that Self
meets the requirements of the
uniform address space restrictions on stored values and the
uniform address space layout constraints
§Examples
§Array
Will panic since runtime-sized arrays are not compatible with the uniform address space restrictions on stored values
<Vec<mint::Vector4<f32>>>::assert_uniform_compat();
Will panic since the stride is 4 bytes
<[f32; 2]>::assert_uniform_compat();
Will not panic since the stride is 16 bytes
<[mint::Vector4<f32>; 2]>::assert_uniform_compat();
§Struct
Will panic since runtime-sized arrays are not compatible with the uniform address space restrictions on stored values
#[derive(ShaderType)]
struct Invalid {
#[size(runtime)]
vec: Vec<mint::Vector4<f32>>
}
Invalid::assert_uniform_compat();
Will panic since the inner struct’s size must be a multiple of 16
#[derive(ShaderType)]
struct S {
x: f32,
}
#[derive(ShaderType)]
struct Invalid {
a: f32,
b: S, // offset between fields 'a' and 'b' must be at least 16 (currently: 4)
}
Invalid::assert_uniform_compat();
Will not panic (fixed via align attribute)
#[derive(ShaderType)]
struct Valid {
a: f32,
#[align(16)]
b: S,
}
Valid::assert_uniform_compat();
Will not panic (fixed via size attribute)
#[derive(ShaderType)]
struct Valid {
#[size(16)]
a: f32,
b: S,
}
Valid::assert_uniform_compat();
Object Safety§
Implementations on Foreign Types§
impl ShaderType for Option<NonZeroI32>
impl ShaderType for Option<NonZeroU32>
impl ShaderType for f32
impl ShaderType for i32
impl ShaderType for u32
impl ShaderType for Wrapping<i32>
impl ShaderType for Wrapping<u32>
impl ShaderType for AtomicI32
impl ShaderType for AtomicU32
impl ShaderType for Mat3where
f32: ShaderSize,
glam
only.impl ShaderType for Mat2where
f32: ShaderSize,
glam
only.impl ShaderType for Mat4where
f32: ShaderSize,
glam
only.impl ShaderType for Vec4where
f32: ShaderSize,
glam
only.impl ShaderType for Vec2where
f32: ShaderSize,
glam
only.impl ShaderType for Vec3where
f32: ShaderSize,
glam
only.impl ShaderType for IVec2where
i32: ShaderSize,
glam
only.impl ShaderType for IVec3where
i32: ShaderSize,
glam
only.impl ShaderType for IVec4where
i32: ShaderSize,
glam
only.impl ShaderType for UVec2where
u32: ShaderSize,
glam
only.impl ShaderType for UVec3where
u32: ShaderSize,
glam
only.impl ShaderType for UVec4where
u32: ShaderSize,
glam
only.impl ShaderType for IVec2where
i32: ShaderSize,
ultraviolet
only.impl ShaderType for IVec3where
i32: ShaderSize,
ultraviolet
only.impl ShaderType for IVec4where
i32: ShaderSize,
ultraviolet
only.impl ShaderType for UVec2where
u32: ShaderSize,
ultraviolet
only.impl ShaderType for UVec3where
u32: ShaderSize,
ultraviolet
only.impl ShaderType for UVec4where
u32: ShaderSize,
ultraviolet
only.impl ShaderType for Mat2where
f32: ShaderSize,
ultraviolet
only.impl ShaderType for Mat3where
f32: ShaderSize,
ultraviolet
only.impl ShaderType for Mat4where
f32: ShaderSize,
ultraviolet
only.impl ShaderType for Vec2where
f32: ShaderSize,
ultraviolet
only.impl ShaderType for Vec3where
f32: ShaderSize,
ultraviolet
only.impl ShaderType for Vec4where
f32: ShaderSize,
ultraviolet
only.source§impl<T> ShaderType for Cow<'_, T>
impl<T> ShaderType for Cow<'_, T>
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for &Twhere
T: ShaderType + ?Sized,
impl<T> ShaderType for &Twhere
T: ShaderType + ?Sized,
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for &mut Twhere
T: ShaderType + ?Sized,
impl<T> ShaderType for &mut Twhere
T: ShaderType + ?Sized,
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for [T]
impl<T> ShaderType for [T]
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Box<T>where
T: ShaderType + ?Sized,
impl<T> ShaderType for Box<T>where
T: ShaderType + ?Sized,
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for LinkedList<T>
impl<T> ShaderType for LinkedList<T>
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for VecDeque<T>
impl<T> ShaderType for VecDeque<T>
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Rc<T>where
T: ShaderType + ?Sized,
impl<T> ShaderType for Rc<T>where
T: ShaderType + ?Sized,
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Arc<T>where
T: ShaderType + ?Sized,
impl<T> ShaderType for Arc<T>where
T: ShaderType + ?Sized,
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Vec<T>
impl<T> ShaderType for Vec<T>
fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Cell<T>where
T: ShaderType + Copy,
impl<T> ShaderType for Cell<T>where
T: ShaderType + Copy,
fn size(&self) -> NonZeroU64
impl<T> ShaderType for Matrix2<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Matrix3<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Matrix4<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Point2<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Point3<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Vector2<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Vector3<T>where
T: ShaderSize,
cgmath
only.impl<T> ShaderType for Vector4<T>where
T: ShaderSize,
cgmath
only.source§impl<T> ShaderType for Vector<T>
Available on crate feature im-rc
only.
impl<T> ShaderType for Vector<T>
im-rc
only.fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Vector<T>
Available on crate feature im
only.
impl<T> ShaderType for Vector<T>
im
only.fn size(&self) -> NonZeroU64
source§impl<T> ShaderType for Vector<T>
Available on crate feature imbl
only.
impl<T> ShaderType for Vector<T>
imbl
only.fn size(&self) -> NonZeroU64
impl<T> ShaderType for ColumnMatrix2<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix2x3<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix2x4<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix3<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix3x2<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix3x4<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix4<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix4x2<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for ColumnMatrix4x3<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for Point2<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for Point3<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for Vector2<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for Vector3<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for Vector4<T>where
T: ShaderSize,
mint
only.impl<T> ShaderType for Mat2<T>where
T: ShaderSize,
vek
only.impl<T> ShaderType for Mat3<T>where
T: ShaderSize,
vek
only.impl<T> ShaderType for Mat4<T>where
T: ShaderSize,
vek
only.impl<T> ShaderType for Vec2<T>where
T: ShaderSize,
vek
only.impl<T> ShaderType for Vec3<T>where
T: ShaderSize,
vek
only.impl<T> ShaderType for Vec4<T>where
T: ShaderSize,
vek
only.impl<T> ShaderType for Matrix2<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix2x3<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix2x4<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix3<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix3x2<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix3x4<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix4<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix4x2<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Matrix4x3<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Vector2<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Vector3<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for Vector4<T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView2x3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView2x4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView3x2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView3x4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView4x2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixView4x3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut2x3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut2x4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut3x2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut3x4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut4x2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for MatrixViewMut4x3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for VectorView2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for VectorView3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for VectorView4<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for VectorViewMut2<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for VectorViewMut3<'_, T>where
T: ShaderSize,
nalgebra
only.impl<T> ShaderType for VectorViewMut4<'_, T>where
T: ShaderSize,
nalgebra
only.source§impl<T, A: Array<Item = T>> ShaderType for SmallVec<A>
Available on crate feature smallvec
only.
impl<T, A: Array<Item = T>> ShaderType for SmallVec<A>
smallvec
only.fn size(&self) -> NonZeroU64
source§impl<T, A: Array<Item = T>> ShaderType for TinyVec<A>
Available on crate feature tinyvec
only.
impl<T, A: Array<Item = T>> ShaderType for TinyVec<A>
tinyvec
only.fn size(&self) -> NonZeroU64
source§impl<T, A: Array<Item = T>> ShaderType for ArrayVec<A>
Available on crate feature tinyvec
only.
impl<T, A: Array<Item = T>> ShaderType for ArrayVec<A>
tinyvec
only.fn size(&self) -> NonZeroU64
fn size(&self) -> NonZeroU64
source§impl<T, P: SharedPointerKind> ShaderType for List<T, P>
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for List<T, P>
rpds
and archery
only.fn size(&self) -> NonZeroU64
source§impl<T, P: SharedPointerKind> ShaderType for Queue<T, P>
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for Queue<T, P>
rpds
and archery
only.fn size(&self) -> NonZeroU64
source§impl<T, P: SharedPointerKind> ShaderType for Stack<T, P>
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for Stack<T, P>
rpds
and archery
only.fn size(&self) -> NonZeroU64
source§impl<T, P: SharedPointerKind> ShaderType for Vector<T, P>
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for Vector<T, P>
rpds
and archery
only.fn size(&self) -> NonZeroU64
source§impl<T, S: RawData<Elem = T>, D: Dimension> ShaderType for ArrayBase<S, D>
Available on crate feature ndarray
only.
impl<T, S: RawData<Elem = T>, D: Dimension> ShaderType for ArrayBase<S, D>
ndarray
only.fn size(&self) -> NonZeroU64
source§impl<T, const N: usize> ShaderType for ArrayVec<T, N>
Available on crate feature arrayvec
only.
impl<T, const N: usize> ShaderType for ArrayVec<T, N>
arrayvec
only.fn size(&self) -> NonZeroU64
source§impl<T, const NUM: usize, const DEN: usize> ShaderType for StaticRc<T, NUM, DEN>where
T: ShaderType + ?Sized,
Available on crate feature static-rc
only.
impl<T, const NUM: usize, const DEN: usize> ShaderType for StaticRc<T, NUM, DEN>where
T: ShaderType + ?Sized,
static-rc
only.