Trait encase::ShaderType
source · [−]pub trait ShaderType {
fn min_size() -> NonZeroU64 { ... }
fn size(&self) -> NonZeroU64 { ... }
fn assert_uniform_compat() { ... }
}
Expand description
Base trait for all WGSL host-shareable types
Provided Methods
fn 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 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
fn 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 Size::SIZE
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();
Implementations on Foreign Types
impl ShaderType for f32
impl ShaderType for u32
impl ShaderType for i32
impl ShaderType for Option<NonZeroU32>
impl ShaderType for Option<NonZeroI32>
impl ShaderType for Wrapping<u32>
impl ShaderType for Wrapping<i32>
impl ShaderType for AtomicU32
impl ShaderType for AtomicI32
impl<T: ShaderType + Size, const N: usize> ShaderType for [T; N]
sourceimpl<T> ShaderType for [T] where
T: ShaderType + Size,
Self: Length,
impl<T> ShaderType for [T] where
T: ShaderType + Size,
Self: Length,
fn size(&self) -> NonZeroU64
sourceimpl<T> ShaderType for Vec<T> where
T: ShaderType + Size,
Self: Length,
impl<T> ShaderType for Vec<T> where
T: ShaderType + Size,
Self: Length,
fn size(&self) -> NonZeroU64
sourceimpl<T> ShaderType for VecDeque<T> where
T: ShaderType + Size,
Self: Length,
impl<T> ShaderType for VecDeque<T> where
T: ShaderType + Size,
Self: Length,
fn size(&self) -> NonZeroU64
sourceimpl<T> ShaderType for LinkedList<T> where
T: ShaderType + Size,
Self: Length,
impl<T> ShaderType for LinkedList<T> where
T: ShaderType + Size,
Self: Length,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized> ShaderType for &T where
T: ShaderType,
impl<T: ?Sized> ShaderType for &T where
T: ShaderType,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized> ShaderType for &mut T where
T: ShaderType,
impl<T: ?Sized> ShaderType for &mut T where
T: ShaderType,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized> ShaderType for Box<T> where
T: ShaderType,
impl<T: ?Sized> ShaderType for Box<T> where
T: ShaderType,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized + ToOwned<Owned = T>> ShaderType for Cow<'_, T> where
T: ShaderType,
impl<T: ?Sized + ToOwned<Owned = T>> ShaderType for Cow<'_, T> where
T: ShaderType,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized> ShaderType for Rc<T> where
T: ShaderType,
impl<T: ?Sized> ShaderType for Rc<T> where
T: ShaderType,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized> ShaderType for Arc<T> where
T: ShaderType,
impl<T: ?Sized> ShaderType for Arc<T> where
T: ShaderType,
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized + Copy> ShaderType for Cell<T> where
T: ShaderType,
impl<T: ?Sized + Copy> ShaderType for Cell<T> where
T: ShaderType,
fn size(&self) -> NonZeroU64
fn size(&self) -> NonZeroU64
sourceimpl<T: ?Sized, const NUM: usize, const DEN: usize> ShaderType for StaticRc<T, NUM, DEN> where
T: ShaderType,
Available on crate feature static-rc
only.
impl<T: ?Sized, const NUM: usize, const DEN: usize> ShaderType for StaticRc<T, NUM, DEN> where
T: ShaderType,
static-rc
only.fn size(&self) -> NonZeroU64
impl<T> ShaderType for Vector2<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Vector3<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Vector4<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Point2<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Point3<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Matrix2<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Matrix3<T> where
T: Size,
cgmath
only.impl<T> ShaderType for Matrix4<T> where
T: Size,
cgmath
only.impl ShaderType for Vec2 where
f32: Size,
glam
only.impl ShaderType for UVec2 where
u32: Size,
glam
only.impl ShaderType for IVec2 where
i32: Size,
glam
only.impl ShaderType for Vec3 where
f32: Size,
glam
only.impl ShaderType for UVec3 where
u32: Size,
glam
only.impl ShaderType for IVec3 where
i32: Size,
glam
only.impl ShaderType for Vec4 where
f32: Size,
glam
only.impl ShaderType for UVec4 where
u32: Size,
glam
only.impl ShaderType for IVec4 where
i32: Size,
glam
only.impl ShaderType for Mat2 where
f32: Size,
glam
only.impl ShaderType for Mat3 where
f32: Size,
glam
only.impl ShaderType for Mat4 where
f32: Size,
glam
only.impl<T> ShaderType for Vector2<T> where
T: Size,
mint
only.impl<T> ShaderType for Vector3<T> where
T: Size,
mint
only.impl<T> ShaderType for Vector4<T> where
T: Size,
mint
only.impl<T> ShaderType for Point2<T> where
T: Size,
mint
only.impl<T> ShaderType for Point3<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix2<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix2x3<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix2x4<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix3x2<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix3<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix3x4<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix4x2<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix4x3<T> where
T: Size,
mint
only.impl<T> ShaderType for ColumnMatrix4<T> where
T: Size,
mint
only.impl<T> ShaderType for VectorSlice2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for VectorSliceMut2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Vector2<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for VectorSlice3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for VectorSliceMut3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Vector3<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for VectorSlice4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for VectorSliceMut4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Vector4<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix2<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice2x3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice2x4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice3x2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut2x3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut2x4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut3x2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix2x3<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix2x4<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix3x2<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix3<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice3x4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice4x2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice4x3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut3x4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut4x2<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut4x3<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix3x4<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix4x2<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix4x3<T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSlice4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for MatrixSliceMut4<'_, T> where
T: Size,
nalgebra
only.impl<T> ShaderType for Matrix4<T> where
T: Size,
nalgebra
only.impl ShaderType for Vec2 where
f32: Size,
ultraviolet
only.impl ShaderType for UVec2 where
u32: Size,
ultraviolet
only.impl ShaderType for IVec2 where
i32: Size,
ultraviolet
only.impl ShaderType for Vec3 where
f32: Size,
ultraviolet
only.impl ShaderType for UVec3 where
u32: Size,
ultraviolet
only.impl ShaderType for IVec3 where
i32: Size,
ultraviolet
only.impl ShaderType for Vec4 where
f32: Size,
ultraviolet
only.impl ShaderType for UVec4 where
u32: Size,
ultraviolet
only.impl ShaderType for IVec4 where
i32: Size,
ultraviolet
only.impl ShaderType for Mat2 where
f32: Size,
ultraviolet
only.impl ShaderType for Mat3 where
f32: Size,
ultraviolet
only.impl ShaderType for Mat4 where
f32: Size,
ultraviolet
only.impl<T> ShaderType for Vec2<T> where
T: Size,
vek
only.impl<T> ShaderType for Vec3<T> where
T: Size,
vek
only.impl<T> ShaderType for Vec4<T> where
T: Size,
vek
only.impl<T> ShaderType for Mat2<T> where
T: Size,
vek
only.impl<T> ShaderType for Mat3<T> where
T: Size,
vek
only.impl<T> ShaderType for Mat4<T> where
T: Size,
vek
only.sourceimpl<T, const N: usize> ShaderType for ArrayVec<T, N> where
T: ShaderType + Size,
Self: Length,
Available on crate feature arrayvec
only.
impl<T, const N: usize> ShaderType for ArrayVec<T, N> where
T: ShaderType + Size,
Self: Length,
arrayvec
only.fn size(&self) -> NonZeroU64
sourceimpl<T, S: RawData<Elem = T>, D: Dimension> ShaderType for ArrayBase<S, D> where
T: ShaderType + Size,
Self: Length,
Available on crate feature ndarray
only.
impl<T, S: RawData<Elem = T>, D: Dimension> ShaderType for ArrayBase<S, D> where
T: ShaderType + Size,
Self: Length,
ndarray
only.fn size(&self) -> NonZeroU64
sourceimpl<T, A: Array<Item = T>> ShaderType for SmallVec<A> where
T: ShaderType + Size,
Self: Length,
Available on crate feature smallvec
only.
impl<T, A: Array<Item = T>> ShaderType for SmallVec<A> where
T: ShaderType + Size,
Self: Length,
smallvec
only.fn size(&self) -> NonZeroU64
sourceimpl<T, A: Array<Item = T>> ShaderType for ArrayVec<A> where
T: ShaderType + Size,
Self: Length,
Available on crate feature tinyvec
only.
impl<T, A: Array<Item = T>> ShaderType for ArrayVec<A> where
T: ShaderType + Size,
Self: Length,
tinyvec
only.fn size(&self) -> NonZeroU64
sourceimpl<T, A: Array<Item = T>> ShaderType for TinyVec<A> where
T: ShaderType + Size,
Self: Length,
Available on crate feature tinyvec
only.
impl<T, A: Array<Item = T>> ShaderType for TinyVec<A> where
T: ShaderType + Size,
Self: Length,
tinyvec
only.fn size(&self) -> NonZeroU64
sourceimpl<T: Clone> ShaderType for Vector<T> where
T: ShaderType + Size,
Self: Length,
Available on crate feature im
only.
impl<T: Clone> ShaderType for Vector<T> where
T: ShaderType + Size,
Self: Length,
im
only.fn size(&self) -> NonZeroU64
sourceimpl<T: Clone> ShaderType for Vector<T> where
T: ShaderType + Size,
Self: Length,
Available on crate feature im-rc
only.
impl<T: Clone> ShaderType for Vector<T> where
T: ShaderType + Size,
Self: Length,
im-rc
only.fn size(&self) -> NonZeroU64
sourceimpl<T: Clone> ShaderType for Vector<T> where
T: ShaderType + Size,
Self: Length,
Available on crate feature imbl
only.
impl<T: Clone> ShaderType for Vector<T> where
T: ShaderType + Size,
Self: Length,
imbl
only.fn size(&self) -> NonZeroU64
sourceimpl<T, P: SharedPointerKind> ShaderType for List<T, P> where
T: ShaderType + Size,
Self: Length,
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for List<T, P> where
T: ShaderType + Size,
Self: Length,
rpds
and archery
only.fn size(&self) -> NonZeroU64
sourceimpl<T, P: SharedPointerKind> ShaderType for Vector<T, P> where
T: ShaderType + Size,
Self: Length,
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for Vector<T, P> where
T: ShaderType + Size,
Self: Length,
rpds
and archery
only.fn size(&self) -> NonZeroU64
sourceimpl<T, P: SharedPointerKind> ShaderType for Stack<T, P> where
T: ShaderType + Size,
Self: Length,
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for Stack<T, P> where
T: ShaderType + Size,
Self: Length,
rpds
and archery
only.fn size(&self) -> NonZeroU64
sourceimpl<T, P: SharedPointerKind> ShaderType for Queue<T, P> where
T: ShaderType + Size,
Self: Length,
Available on crate features rpds
and archery
only.
impl<T, P: SharedPointerKind> ShaderType for Queue<T, P> where
T: ShaderType + Size,
Self: Length,
rpds
and archery
only.