-
Notifications
You must be signed in to change notification settings - Fork 51
[HLSL] define the matrix element accessor semantics #678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
f02f52f
114ef0c
19142de
9519a35
24ef900
da289f1
5818621
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,7 @@ | |
| typename-specifier braced-init-list\br | ||
| postfix-expression \terminal{.} \opt{\terminal{template}} id-expression\br | ||
| postfix-expression \terminal{.} vector-swizzle-component-sequence\br | ||
| postfix-expression \terminal{.} matrix-swizzle-component-sequence\br | ||
| postfix-expression \terminal{++}\br | ||
| postfix-expression \terminal{--} | ||
| \end{grammar} | ||
|
|
@@ -173,7 +174,19 @@ | |
| elements in the vector, the program is ill-formed. If the value is outside the | ||
| range at runtime, the behavior is undefined. | ||
|
|
||
| \Sec{Vector Swizzle}{Expr.Post.VectorSwizzle} | ||
| \Sec{Swizzle}{Expr.Post.Swizzle} | ||
| \p A \textit{postfix-expression} followed by a dot (\texttt{.}) and a sequence | ||
| of one or more \textit{swizzle-components} is a postfix expression. The | ||
farzonl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| postfix expression before the dot is evaluated and must be of vector or matrix type. | ||
| If the postfix expression before the dot is an lvalue, the swizzle expression may | ||
| produce either an lvalue or a prvalue; otherwise it produces a prvalue. | ||
|
|
||
|
|
||
| \p If the postfix expression before the dot is | ||
| an lvalue and the \textit{swizzle-component-sequence} contains no repeated | ||
| components, the swizzle expression is an lvalue; otherwise it is a prvalue. | ||
|
|
||
| \Sec{Vector Swizzle}{Expr.Post.Swizzle.Vector} | ||
farzonl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| \begin{grammar} | ||
| \define{vector-swizzle-component-sequence}\br | ||
|
|
@@ -195,23 +208,14 @@ | |
| \terminal{x y z w} | ||
| \end{grammar} | ||
|
|
||
| \p A \textit{postfix-expression} followed by a dot (\texttt{.}) and a sequence | ||
| of one or more \textit{swizzle-components} is a postfix expression. The | ||
| postfix expression before the dot is evaluated and must be of vector type. If | ||
| the postfix expression before the dot is an lvalue, the swizzle expression may | ||
| produce either an lvalue or a prvalue; otherwise it produces a prvalue. | ||
|
|
||
| \p A \textit{swizzle-component-sequence} is a sequence of one or more swizzle | ||
| \p A \textit{vector-swizzle-component-sequence} is a sequence of one or more swizzle | ||
| components of either the \textit{swizzle-component-rgba} or | ||
| \textit{swizzle-component-xyzw} forms; the two forms may not be mixed in the | ||
| same \textit{swizzle-component-sequence}. The type of a swizzle expression is a | ||
| same \textit{vector-swizzle-component-sequence}. The type of a swizzle expression is a | ||
| vector of the same element type as the postfix expression before the dot, with a | ||
| number of elements equal to the number of components in the | ||
| \textit{swizzle-component-sequence}. If the postfix expression before the dot is | ||
| an lvalue and the \textit{swizzle-component-sequence} contains no repeated | ||
| components, the swizzle expression is an lvalue; otherwise it is a prvalue. | ||
| number of elements equal to the number of components in the \textit{vector-swizzle-component-sequence}. | ||
|
|
||
| \p Swizzle components map to elements of the vector in the following way: | ||
| \p Vector swizzle components map to elements of the vector in the following way: | ||
|
|
||
| \begin{center} | ||
| \begin{tabular}{|| c | c | c ||} | ||
|
|
@@ -230,6 +234,46 @@ | |
| refers to an element index that is out of range of the vector type of the | ||
| postfix expression before the dot. | ||
|
|
||
| \Sec{Matrix Swizzle}{Expr.Post.Swizzle.Matrix} | ||
farzonl marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| \begin{grammar} | ||
| \define{matrix-swizzle-component-sequence}\br | ||
| matrix-zero-indexed-swizzle-sequence\br | ||
| matrix-one-indexed-swizzle-sequence\br | ||
|
Comment on lines
+239
to
+241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @llvm-beanz One unique thing I was thinking about indicating is that a matrix swizzle can not be more than 4 elements. That seems to be implied later when we indicate that a swizzle expression is a vector. However, with long vectors coming in SM 6.9 does this 4 element limitation on matrix swizzles go away? https://hlsl.godbolt.org/z/r9o5PKPWr because I am still seeing it in godbolt: https://hlsl.godbolt.org/z/fdnWqq7cK. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also don't allow vector swizzles to be more than 4 elements. I think we should keep the 4 element restriction. |
||
|
|
||
| \define{matrix-zero-indexed-swizzle-sequence}\br | ||
| matrix-zero-indexed-swizzle\br | ||
| matrix-zero-indexed-swizzle-sequence matrix-zero-indexed-swizzle\br | ||
|
|
||
| \define{matrix-zero-indexed-swizzle}\br | ||
| \terminal{\_m} zero-index-value\br | ||
|
|
||
| \define{zero-index-value} \textnormal{one of}\br | ||
| \terminal{0 1 2 3 }\br | ||
|
|
||
| \define{matrix-one-indexed-swizzle-sequence}\br | ||
| matrix-one-indexed-swizzle\br | ||
| matrix-one-indexed-swizzle-sequence matrix-one-indexed-swizzle\br | ||
|
|
||
| \define{matrix-one-indexed-swizzle}\br | ||
| \terminal{\_m} one-index-value\br | ||
|
|
||
| \define{one-index-value} \textnormal{one of}\br | ||
| \terminal{1 2 3 4 }\br | ||
| \end{grammar} | ||
| \begin{itemize} | ||
| \item \textbf{.\_} (math-style): subsequent subscripts use \textbf{1-based} | ||
| indexing for both row and column. | ||
| \item \textbf{.\_m} (memory-style): subsequent subscripts use \textbf{0-based} | ||
| indexing for both row and column. | ||
| \end{itemize} | ||
farzonl marked this conversation as resolved.
Show resolved
Hide resolved
farzonl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| \p A \textit{matrix-swizzle-component-sequence} is a sequence of one or more swizzle | ||
| components of either the \textit{matrix-zero-indexed-swizzle} or | ||
| \textit{matrix-one-indexed-swizzle} forms; the two forms may not be mixed in the | ||
| same \textit{matrix-swizzle-component-sequence}. The type of a swizzle expression is a | ||
| vector of the same element type as the postfix expression before the dot, with a | ||
| number of elements equal to the number of components in the \textit{matrix-swizzle-component-sequence}. | ||
|
|
||
| \Sec{Function Calls}{Expr.Post.Call} | ||
|
|
||
| \p A function call may be an \textit{ordinary function}, or a \textit{member | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.