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

Naga wgsl-in allows for mixing '+' and '^' without parenthesis, dawn doesn't #6857

Open
expenses opened this issue Jan 5, 2025 · 3 comments
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working

Comments

@expenses
Copy link
Contributor

expenses commented Jan 5, 2025

Similar to #6856.

I got this error in Chromium with a shader that works fine in desktop wgpu:

Compilation log for [Invalid ShaderModule (unlabeled)]:
6 error(s) generated while compiling the shader:
:67:54 error: mixing '+' and '^' requires parenthesis
        var _S4 : u32 = _S3 + (((((_S2 << (u32(4)))) + u32(2738958700) ^ (_S2 + sum_1)) ^ (((_S2 >> (u32(5)))) + u32(3355524772))));

This issue is originally caused by slang generating invalid wgpu shaders, but naga doesn't catch it.

@expenses
Copy link
Contributor Author

expenses commented Jan 5, 2025

@expenses expenses changed the title Naga allows for mixing '+' and '^' without parenthesis, dawn doesn't Naga wgsl-in allows for mixing '+' and '^' without parenthesis, dawn doesn't Jan 5, 2025
@sagudev
Copy link
Contributor

sagudev commented Jan 5, 2025

Indeed, per spec https://www.w3.org/TR/WGSL/#operator-precedence-associativity + and ^ are in different associativity groups, hence one needs parenthesis.

@teoxoy
Copy link
Member

teoxoy commented Jan 6, 2025

Related: #4536

@teoxoy teoxoy added type: bug Something isn't working naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language labels Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants