-
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
WGSL built in functions are very under specified #4527
Comments
This is very much like #4219 A first step is already in place, relating WGSL's fp edge case behaviours to IEEE 754 exception cases. See https://gpuweb.github.io/gpuweb/wgsl/#floating-point-evaluation That said, access to IEEE 754 is behind a paywall, so we still have work to (hopefully captured by #4219) to spell out the various cases. |
I posted an analysis at gpuweb/cts#3549 (review) The test implements the rule: for pow(a,b):
This is the same rule as GLSL. Also, MSL says for both HLSL doesn't say anything useful for pow. WGSL's accuracy table says IEEE 754-2018 defines
So Taking the intersection of GLSL, MSL, and IEEE powr, we end up using GLSL's rule. |
thanks for the update! but i am not sure i understand what failing the test means. |
This looks like a duplicate of #2765. |
WGSL 2024-04-16 Minutes
|
None of the WGSL built in functions specify their edge case behavior.
For a practical example, consider the pow(x,y) function.
What happens with negative values of x?
D3D does a very good job at this: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow
MSL does not, but has two different functions pow and powr.
T pow(T x, T y) Compute x to the power y.
T powr(T x, T y) Compute x to the power y, where x is >= 0.
via https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
In this case, should a wgsl to msl implementation emit pow or powr?
I don't think WGSL should actually specify behavior, but should specify in which cases behavior is undefined - and conversely in which cases it is.
This applies to pretty much all built in functions. Substitute pow with sqrt. Or sin of inf instead of a negative input to sqrt.
The text was updated successfully, but these errors were encountered: