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

Implement WGSL template list discovery #4501

Open
jimblandy opened this issue Sep 15, 2023 · 0 comments
Open

Implement WGSL template list discovery #4501

jimblandy opened this issue Sep 15, 2023 · 0 comments
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator

Comments

@jimblandy
Copy link
Member

jimblandy commented Sep 15, 2023

Or at least, not without parentheses. The following is valid WGSL, but Naga rejects it, even on the const-expressions-2 branch:

$ cat expr-array-length.wgsl 
var<workgroup> buffer: array<u32, 1024 * 1024>;
$ naga expr-array-length.wgsl 
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `/home/jimb/rust/naga/target/debug/naga expr-array-length.wgsl`
error: expected '>', found '*'
  ┌─ expr-array-length.wgsl:1:40
  │
1 │ var<workgroup> buffer: array<u32, 1024 * 1024>;
  │                                        ^ expected '>'

Could not parse WGSL
$ 

If we change it as follows, Naga accepts it:

var<workgroup> buffer: array<u32, (1024 * 1024)>;

The problem here is that Naga doesn't yet implement template list discovery, so it can't tell that the > in array<u32, 1024 * 1024> is the closing bracket of a template list, rather than a > operator in an expression.

@teoxoy teoxoy added lang: WGSL WebGPU Shading Language area: naga front-end labels Sep 18, 2023
@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added the naga Shader Translator label Oct 25, 2023
@teoxoy teoxoy added this to the WebGPU Specification V1 milestone Nov 3, 2023
@jimblandy jimblandy changed the title Full constant expressions aren't permitted everywhere they ought to be Implement WGSL template list discovery Dec 13, 2023
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
Projects
Status: No status
Development

No branches or pull requests

3 participants