Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[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 subscribe to this conversation on GitHub. Already have an account? Sign in.
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