pub enum Constructor<T> {
PartialVector {
size: VectorSize,
},
PartialMatrix {
columns: VectorSize,
rows: VectorSize,
},
PartialArray,
Type(T),
}Expand description
A constructor built-in function.
WGSL has two types of such functions:
-
Those that fully specify the type being constructed, like
vec3<f32>(x,y,z), which obviously constructs avec3<f32>. -
Those that leave the component type of the composite being constructed implicit, to be inferred from the argument types, like
vec3(x,y,z), which constructs avec3<T>whereTis the type ofx,y, andz.
This enum represents both cases. The PartialFoo variants
represent the second case, where the component type is implicit.
Variants§
PartialVector
A vector construction whose component type is inferred from the
argument: vec3(1.0).
Fields
size: VectorSizePartialMatrix
A matrix construction whose component type is inferred from the
argument: mat2x2(1,2,3,4).
PartialArray
An array whose component type and size are inferred from the arguments:
array(3,4,5).
Type(T)
A known Naga type.
When we match on this type, we need to see the TypeInner here, but at
the point that we build this value we’ll still need mutable access to
the module later. To avoid borrowing from the module, the type parameter
T is Handle<Type> initially. Then we use borrow_inner to produce a
version holding a tuple (Handle<Type>, &TypeInner).
Implementations§
Source§impl Constructor<Handle<Type>>
impl Constructor<Handle<Type>>
Sourcefn borrow_inner(
self,
module: &Module,
) -> Constructor<(Handle<Type>, &TypeInner)>
fn borrow_inner( self, module: &Module, ) -> Constructor<(Handle<Type>, &TypeInner)>
Return an equivalent Constructor value that includes borrowed
TypeInner values alongside any type handles.
The returned form is more convenient to match on, since the patterns can actually see what the handle refers to.