Skip to content
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 float % translates into incorrect spirv op code #1652

Closed
Miha-Rozina opened this issue Jan 7, 2022 · 0 comments · Fixed by #1653
Closed

WGSL float % translates into incorrect spirv op code #1652

Miha-Rozina opened this issue Jan 7, 2022 · 0 comments · Fixed by #1653
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output

Comments

@Miha-Rozina
Copy link

Description
WGSL spec says:

Floating point remainder, where sign of non-zero result matches sign of e1. Component-wise when T is a vector.
Result equal to: e1 - e2 * trunc(e1 / e2)
(OpFRem)

While looking at the shader code in RenderDoc when using Vulkan backend I can see that the modulo operation was translated to:

float _95 = FMod(_92, _94);

Repro steps
Use float % operator in WGSL shader where the first argument is a negative value.

Expected vs observed behavior
The result of the % operation should be a negative value, but it is a positive value, because OpFMod is used instead of OpFRem.

Platform
Using wgpu 0.12.0 on Linux (Arch linux if it matters).

@kvark kvark transferred this issue from gfx-rs/wgpu Jan 7, 2022
@kvark kvark added area: back-end Outputs of shader conversion kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output labels Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: SPIR-V Binary SPIR-V input and output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants