-
Notifications
You must be signed in to change notification settings - Fork 35
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
Start specifying standard conversions #58
Conversation
This change adds some basic language to describe values then moves into describing HLSL's standard conversions and standard conversion sequences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some grammar pointers.
specs/language/conversions.tex
Outdated
chapter enumerates the full set of conversions. A \textit{standard conversion | ||
sequence} is a sequence of standard conversions in the following order: | ||
\begin{enumerate} | ||
\item Zero or one conversion of either lvalue-to-rvalue, array-to-pinter or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: array-to-pointer
|
||
\Sec{Floating point-integral conversion}{Conv.fpint} | ||
|
||
\p A glvalue of floating point type can be converted to a cxvalue of integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this sentence should be separated into two.
discarding the fractional value. The behavior is undefined if the truncated | ||
value cannot be represented in the destination type. | ||
|
||
\p A glvalue of integer type can be converted to a cxvalue of floating point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise here.
specs/language/conversions.tex
Outdated
\p A glvalue of type \texttt{matrix<T,x,y>} can be converted to a cxvalue of type | ||
\texttt{matrix<T,z,w>}, or a prvalue of type \texttt{matrix<T,x,y>} can be | ||
converted to a prvalue of type \texttt{matrix<T,z,w>} only if \texttt{x} is less | ||
than or equal to \texttt{z} and \texttt{y} is less than or equal to \texttt{w}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, why not use the latex /leq operator?
specs/language/conversions.tex
Outdated
\Sec{Qualification conversion}{Conv.qual} | ||
|
||
A prvalue of type "\textit{cv1} \texttt{T}" can be converted to a prvalue of type | ||
"\textit{cv2} \texttt{T}" type "\textit{cv2} \texttt{T}" is more cv-qualified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a sentence break here?
\p A glvalue of floating point type can be converted to a cxvalue of integer | ||
type. A prvalue of floating point type can be converted to a prvalue of | ||
integer type. Conversion of floating point values to integer values truncates by | ||
discarding the fractional value. The behavior is undefined if the truncated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is "undefined" here different to "implementation defined" on line 53?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, "undefined" and "implementation defined" are defined terms earlier in the full document:
https://github.com/microsoft/hlsl-specs/blob/main/specs/language/introduction.tex#L148
Basically "implementation defined" behavior needs to be documented by the relevant part of the implementation (compiler, runtime, ISA, DXIL, SPIR-V, etc).
point type. If the destination type can exactly represent the source value, the | ||
result is the exact value. If the destination type cannot exactly represent the | ||
source value, the conversion to a best-approximation of the source value is | ||
implementation defined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to talk about rounding modes here? I worry that "best-approximation" is very ambiguous otherwise. If we're just going to kick the can and worry about those details later I'd just say "approximation".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the rounding modes falls under the "implementation defined" aspect and I would expect us to document the DXIL & SPIR-V behaviors separately since they may be different.
\p A glvalue of type \texttt{matrix<T,x,y>} can be converted to a cxvalue of type | ||
\texttt{matrix<T,z,w>}, or a prvalue of type \texttt{matrix<T,x,y>} can be | ||
converted to a prvalue of type \texttt{matrix<T,z,w>} only if \( x \leq z \) | ||
and \(y \leq w \) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to have a brief code listing with examples for each section of conversions. Is that something that would be practical without it taking up too much space?
This change adds some basic language to describe values then moves into describing HLSL's standard conversions and standard conversion sequences.