pub enum Instance {
Literal(LiteralInstance),
Struct(StructInstance),
Array(ArrayInstance),
Vec(VecInstance),
Mat(MatInstance),
Ptr(PtrInstance),
Ref(RefInstance),
Atomic(AtomicInstance),
Deferred(Type),
}Expand description
Instance of a plain type.
Variants§
Literal(LiteralInstance)
Struct(StructInstance)
Array(ArrayInstance)
Vec(VecInstance)
Mat(MatInstance)
Ptr(PtrInstance)
Ref(RefInstance)
Atomic(AtomicInstance)
Deferred(Type)
For instances that cannot be computed currently, we store the type. TODO: remove this
Implementations§
Source§impl Instance
impl Instance
Sourcepub fn to_buffer(&self) -> Option<Vec<u8>>
pub fn to_buffer(&self) -> Option<Vec<u8>>
Memory representation of host-shareable instances.
Returns None if the type is not host-shareable.
Sourcepub fn from_buffer(buf: &[u8], ty: &Type) -> Option<Self>
pub fn from_buffer(buf: &[u8], ty: &Type) -> Option<Self>
Load an instance from a byte buffer.
Returns None if the type is not host-shareable, or if the buffer is too small.
The buffer can be larger than the type; extra bytes will be ignored.
Source§impl Instance
impl Instance
Sourcepub fn zero_value(ty: &Type) -> Result<Self, Error>
pub fn zero_value(ty: &Type) -> Result<Self, Error>
Zero-value initialize an instance of a given type.
Source§impl Instance
impl Instance
pub fn op_neg(&self) -> Result<Self, Error>
pub fn op_or(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_and(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_add(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
pub fn op_sub(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
pub fn op_mul(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
pub fn op_div(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
pub fn op_rem(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
Source§impl Instance
impl Instance
pub fn op_eq(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_ne(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_lt(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_le(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_gt(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_ge(&self, rhs: &Self) -> Result<Self, Error>
Source§impl Instance
impl Instance
pub fn op_bitnot(&self) -> Result<Self, Error>
Sourcepub fn op_bitor(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_bitor(&self, rhs: &Self) -> Result<Self, Error>
Note: this is both the “bitwise OR” and “logical OR” operator.
Sourcepub fn op_bitand(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_bitand(&self, rhs: &Self) -> Result<Self, Error>
Note: this is both the “bitwise AND” and “logical AND” operator.
pub fn op_bitxor(&self, rhs: &Self) -> Result<Self, Error>
pub fn op_shl(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
pub fn op_shr(&self, rhs: &Self, stage: ShaderStage) -> Result<Self, Error>
Source§impl Instance
impl Instance
pub fn is_convertible_to(&self, ty: &Type) -> bool
Sourcepub fn loaded(self) -> Result<Self, Error>
pub fn loaded(self) -> Result<Self, Error>
Apply the load rule.
Reference: https://www.w3.org/TR/WGSL/#load-rule
Source§impl Instance
impl Instance
pub fn unwrap_literal(self) -> LiteralInstance
pub fn unwrap_literal_ref(&self) -> &LiteralInstance
pub fn unwrap_vec(self) -> VecInstance
pub fn unwrap_vec_ref(&self) -> &VecInstance
pub fn unwrap_vec_mut(&mut self) -> &mut VecInstance
Source§impl Instance
impl Instance
Sourcepub fn view(&self, view: &MemView) -> Result<&Instance, Error>
pub fn view(&self, view: &MemView) -> Result<&Instance, Error>
Get an instance representing a memory view.
There are two ways to create a memory view:
- Accessing a
structcomponent (struct.member) - Indexing an
array,vec, ormat(arr[n])
Reference: https://www.w3.org/TR/WGSL/#memory-views
Trait Implementations§
Source§impl Convert for Instance
impl Convert for Instance
Source§fn convert_to(&self, ty: &Type) -> Option<Self>
fn convert_to(&self, ty: &Type) -> Option<Self>
Source§fn convert_inner_to(&self, ty: &Type) -> Option<Self>
fn convert_inner_to(&self, ty: &Type) -> Option<Self>
Source§fn concretize(&self) -> Option<Self>
fn concretize(&self) -> Option<Self>
Source§impl From<ArrayInstance> for Instance
impl From<ArrayInstance> for Instance
Source§fn from(value: ArrayInstance) -> Self
fn from(value: ArrayInstance) -> Self
Source§impl From<AtomicInstance> for Instance
impl From<AtomicInstance> for Instance
Source§fn from(value: AtomicInstance) -> Self
fn from(value: AtomicInstance) -> Self
Source§impl From<LiteralInstance> for Instance
impl From<LiteralInstance> for Instance
Source§fn from(value: LiteralInstance) -> Self
fn from(value: LiteralInstance) -> Self
Source§impl From<MatInstance> for Instance
impl From<MatInstance> for Instance
Source§fn from(value: MatInstance) -> Self
fn from(value: MatInstance) -> Self
Source§impl From<PtrInstance> for Instance
impl From<PtrInstance> for Instance
Source§fn from(value: PtrInstance) -> Self
fn from(value: PtrInstance) -> Self
Source§impl From<RefInstance> for Instance
impl From<RefInstance> for Instance
Source§fn from(value: RefInstance) -> Self
fn from(value: RefInstance) -> Self
Source§impl From<StructInstance> for Instance
impl From<StructInstance> for Instance
Source§fn from(value: StructInstance) -> Self
fn from(value: StructInstance) -> Self
Source§impl From<VecInstance> for Instance
impl From<VecInstance> for Instance
Source§fn from(value: VecInstance) -> Self
fn from(value: VecInstance) -> Self
impl StructuralPartialEq for Instance
Auto Trait Implementations§
impl Freeze for Instance
impl !RefUnwindSafe for Instance
impl !Send for Instance
impl !Sync for Instance
impl Unpin for Instance
impl !UnwindSafe for Instance
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more