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-in] Support const operations in const variables #733

Closed
ashpil opened this issue Apr 19, 2021 · 2 comments · Fixed by #2309
Closed

[wgsl-in] Support const operations in const variables #733

ashpil opened this issue Apr 19, 2021 · 2 comments · Fixed by #2309
Labels
area: front-end Input formats for conversion kind: feature New feature or request lang: WGSL WebGPU shading language

Comments

@ashpil
Copy link

ashpil commented Apr 19, 2021

I'm not sure whether the official WGSL spec specifies anything about this, but I'm running into a pattern in my code where I'd like to do something like this:

const phi_sun: f32 = PI * 2.0;

However, the compiler doesn't like this:

error: expected separator, found '*'
   ┌─ wgsl:84:2584const phi_sun: f32 = PI * 2.0;
   │                         ^ expected separator

error: aborting due to previous error
@ashpil ashpil changed the title [wgsl-in] Support const operations in const variables [wgsl-in] Support const operations in const variables Apr 19, 2021
@kvark
Copy link
Member

kvark commented Apr 20, 2021

Unfortunately, the constant initializers in WGSL today can't do this - see const_expr grammar in the spec. We definitely do want to have this soon, just struggling with a good constexpr semantic.

@kvark kvark added area: front-end Input formats for conversion kind: feature New feature or request lang: WGSL WebGPU shading language labels Apr 20, 2021
@jimblandy
Copy link
Member

jimblandy commented Feb 24, 2022

WGSL issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: front-end Input formats for conversion kind: feature New feature or request lang: WGSL WebGPU shading language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants