-
Notifications
You must be signed in to change notification settings - Fork 303
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
AbstractFloat should not be convertible to infinity or NaN in concrete float type #2953
Comments
Also, this rule mirrors the rule that an AbstractInt value outside the range of a concrete integer type is not convertible to that type. It also produces a shader creation error. See https://gpuweb.github.io/gpuweb/wgsl/#ref-for-abstractint%E2%91%A1 |
Should we also prevent hex floats from constructing a NaN? |
Yes. For hex float literals, the spec says:
A NaN occurs when the mantissa is nonzero and the biased exponent is the all 1's value for that field, or the maximum representable exponent. So putting a NaN bit representation through the ideal value calculation (quoted), the result value is outside the finite range of the concrete float type. So the spec update is basically: It's a shader creation error if an AbstractFloat value is being converted to a concrete float type, but the value is outside the finite range of the target type. |
WGSL meeting minutes 2022-05-31
|
1e100 is a valid AbstractFloat value, but outside the finite range of f32.
When converting a value from one float type to another, values outside the finite range of the target (modulo possible truncation of mantissa bits) are converted to an infinity of the target type.
So f32(1e100) should be the infinity of f32.
This is a bit weird:
So, we're proposing a change to the float conversion rules: When a float to float conversion would produce an infinity, but the source type is AbstractFloat (and hence a creation-time constant value), then that produces a shader creation error.
Credit @ben-clayton for finding this issue and proposing the solution.
The text was updated successfully, but these errors were encountered: