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] allow functions to be declared literally after entry point #2072

Closed
vicary opened this issue Sep 30, 2022 · 2 comments
Closed

[wgsl-in] allow functions to be declared literally after entry point #2072

vicary opened this issue Sep 30, 2022 · 2 comments
Labels
area: front-end Input formats for conversion kind: bug Something isn't working lang: WGSL WebGPU shading language

Comments

@vicary
Copy link

vicary commented Sep 30, 2022

This is discovered in Deno when using tensorflow.js with its WebGPU backend, when tfjs declares a function fn main after the entry point fn _start. The generated WGSL works in Chrome Canary 108.0.5329.0 (V8 10.8.79) but fails in Deno, error details at tensorflow/tfjs#6842 (comment).

Experiments in tensorflow/tfjs#6842 (comment) showed that in naga, invoked functions have to be declared literally before the entry point and the @compute directive.

The current WGSL specification (20220922) seems to have function scoping, replacing the lexical scoping back in 2020.

A function declaration must only occur at module scope. A function name is in scope for the entire program.

Given the generated script shader.wgsl, should the function main be available in scope when _start is invoked?

@SparkyPotato
Copy link
Contributor

This is a limitation of the current WGSL front end.
It will be fixed with #2065.

@JCapucho JCapucho added kind: bug Something isn't working lang: WGSL WebGPU shading language area: front-end Input formats for conversion labels Oct 21, 2022
@teoxoy
Copy link
Member

teoxoy commented Nov 15, 2022

Closing as duplicate of #1745.

@teoxoy teoxoy closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2022
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: bug Something isn't working lang: WGSL WebGPU shading language
Projects
None yet
Development

No branches or pull requests

4 participants