-
Notifications
You must be signed in to change notification settings - Fork 52
[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 all commits
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 Expressions}{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 | ||||||
| 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. | ||||||
|
|
||||||
| \Sub{Vector Swizzle}{Expr.Post.Swizzle.Vector} | ||||||
|
|
||||||
| \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,75 @@ | |||||
| refers to an element index that is out of range of the vector type of the | ||||||
| postfix expression before the dot. | ||||||
|
|
||||||
| \Sub{Matrix Swizzle}{Expr.Post.Swizzle.Matrix} | ||||||
| \begin{grammar} | ||||||
| \define{matrix-swizzle-component-sequence}\br | ||||||
| matrix-zero-indexed-swizzle-sequence\br | ||||||
| matrix-one-indexed-swizzle-sequence\br | ||||||
|
|
||||||
| \define{matrix-zero-indexed-swizzle-sequence}\br | ||||||
| matrix-zero-indexed-swizzle\br | ||||||
| matrix-zero-indexed-swizzle-sequence matrix-zero-indexed-swizzle\br | ||||||
|
Collaborator
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. I'm not exactly sure the best way to rewrite this, but as written this would require |
||||||
|
|
||||||
| \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 | ||||||
|
Collaborator
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. I'm not exactly sure the best way to rewrite this, but as written this would require |
||||||
|
|
||||||
| \define{matrix-one-indexed-swizzle}\br | ||||||
| \terminal{\_m} one-index-value\br | ||||||
|
Collaborator
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.
Suggested change
Should be just |
||||||
|
|
||||||
| \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 but less | ||||||
| than or equal to four swizzle components of either the | ||||||
|
Collaborator
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. imo it would be better to encode this into the grammar its not too crazy to write which also solves 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}. | ||||||
|
|
||||||
| \p Matrix swizzle components map to elements of the matrix in the following way: | ||||||
|
|
||||||
| \begin{center} | ||||||
| \begin{tabular}{|| c | c | c ||} | ||||||
| \hline | ||||||
| Element Index & 0 indexed component & 1 indexed component \\ | ||||||
| \hline | ||||||
| 0,0 & \_m00 & \_11 \\ | ||||||
| 0,1 & \_m01 & \_12 \\ | ||||||
| 0,2 & \_m02 & \_13 \\ | ||||||
| 0,3 & \_m03 & \_14 \\ | ||||||
| 1,0 & \_m10 & \_21 \\ | ||||||
| 1,1 & \_m11 & \_22 \\ | ||||||
| 1,2 & \_m12 & \_23 \\ | ||||||
| 1,3 & \_m13 & \_24 \\ | ||||||
| 2,0 & \_m20 & \_31 \\ | ||||||
| 2,1 & \_m21 & \_32 \\ | ||||||
| 2,2 & \_m22 & \_33 \\ | ||||||
| 2,3 & \_m23 & \_34 \\ | ||||||
| 3,0 & \_m30 & \_41 \\ | ||||||
| 3,1 & \_m31 & \_42 \\ | ||||||
| 3,2 & \_m32 & \_43 \\ | ||||||
| 3,3 & \_m33 & \_44 \\ | ||||||
| \hline | ||||||
| \end{tabular} | ||||||
| \end{center} | ||||||
|
|
||||||
| \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.