pub enum ConstructorType<'a> {
Scalar(Scalar),
PartialVector {
size: VectorSize,
},
Vector {
size: VectorSize,
ty: Handle<Type<'a>>,
ty_span: Span,
},
PartialMatrix {
columns: VectorSize,
rows: VectorSize,
},
Matrix {
columns: VectorSize,
rows: VectorSize,
ty: Handle<Type<'a>>,
ty_span: Span,
},
PartialArray,
Array {
base: Handle<Type<'a>>,
size: ArraySize<'a>,
},
Type(Handle<Type>),
}
Expand description
A type at the head of a Construct
expression.
WGSL has two types of type constructor expressions
:
-
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>
whereT
is the type ofx
,y
, andz
.
This enum represents the head type of both cases. The PartialFoo
variants
represent the second case, where the component type is implicit.
This does not cover structs or types referred to by type aliases. See the
documentation for Construct
and Call
expressions for details.
Variants§
Scalar(Scalar)
A scalar type or conversion: f32(1)
.
PartialVector
A vector construction whose component type is inferred from the
argument: vec3(1.0)
.
Fields
size: VectorSize
Vector
A vector construction whose component type is written out:
vec3<f32>(1.0)
.
PartialMatrix
A matrix construction whose component type is inferred from the
argument: mat2x2(1,2,3,4)
.
Matrix
A matrix construction whose component type is written out:
mat2x2<f32>(1,2,3,4)
.
PartialArray
An array whose component type and size are inferred from the arguments:
array(3,4,5)
.
Array
An array whose component type and size are written out:
array<u32, 4>(3,4,5)
.
Type(Handle<Type>)
Constructing a value of a known Naga IR type.
This variant is produced only during lowering, when we have Naga types available, never during parsing.