[wgsl-in] allow functions to be declared literally after entry point #2072
Labels
area: front-end
Input formats for conversion
kind: bug
Something isn't working
lang: WGSL
WebGPU shading language
This is discovered in Deno when using tensorflow.js with its WebGPU backend, when tfjs declares a function
fn main
after the entry pointfn _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.
Given the generated script shader.wgsl, should the function
main
be available in scope when_start
is invoked?The text was updated successfully, but these errors were encountered: