-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Description
We have time to figure this out after we get more of the AST important pieces in place. But we will soon need to consider conversions. We also need a coresponding spec issue for this.
In clang/lib/Sema/SemaOverload.cpp we handle vectors via an IsVectorConversion. We need something similar to handle Matrix Splat and Matrix Truncation.
else if (IsVectorConversion(S, FromType, ToType, SecondICK, DimensionICK,
From, InOverloadResolution, CStyle)) {
SCS.Second = SecondICK;
SCS.Dimension = DimensionICK;
FromType = ToType.getUnqualifiedType();
}
So Matrix Splat is not as permissive as vectors only scalars or scalar adjacent vec1 or mat1x1 types can be splatted
https://godbolt.org/z/s1jx5oW4a
The Matrix splat spec ia written as
what does this mean for HLSL matrix types: 2 A glvalue of type T
can be converted to a cxvalue of type matrix<T,x,y> or a prvalue of type
T can be converted to a prvalue of type matrix<T,x,y>. The destination
value is the source value replicated into each element of the destination.
That matches with what we are seing in godbolt
The Matrix truncation spec is already written as
Vector and matrix truncation conversion {#Conv.vtrunc}
A prvalue of type vector<T, x>
can be converted to a prvalue of type:
vector<T, y>
only if ( y < x ), orT
The resulting value of vector truncation is comprised of elements [0..y)
, dropping elements [y..x)
.
A prvalue of type matrix<T, x, y>
can be converted to a prvalue of type:
matrix<T, z, w>
only if ( x \geq z ) and ( y \geq w ),vector<T, z>
only if ( x \geq z ), orT
Matrix truncation is performed on each row and column dimension separately.
The resulting value is comprised of vectors [0..z)
which are each separately comprised of elements [0..w)
.
Trailing vectors and elements are dropped.
Reducing the dimension of a vector to one (vector<T, 1>
) can produce either a single-element vector or a scalar of type T
.
Reducing the rows of a matrix to one (matrix<T, x, 1>
) can produce either a single-row matrix, a vector of type vector<T, x>
, or a scalar of type T
.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status