brendan-duncan / wgsl_reflect

A WebGPU Shading Language parser and reflection library for Javascript.
MIT License
183 stars 20 forks source link

Add overrides to entries's function info #60

Open alienself opened 1 week ago

alienself commented 1 week ago

Hi again,

I have been using WGSL overrides quite a bit lately and realize that there is no way to currently determine in which entry function the overrides (OverrideInfo) are used. This is problematic for my use case since I don't know if I should assign the overrides to vertex and fragment or simply one of them. WebGPU will raise an error if pipeline constants are declared in pipelines descriptors but not used in the actual entry function.

brendan-duncan commented 1 week ago

Yeah I can add that. I haven't used overrides much, so thanks for the testing. It might be a couple days before I can get to it, ping me if I forget.

brendan-duncan commented 1 week ago

I added overrides to FunctionInfo. It will walk the function AST graphs to find usage of override variables, so you can get the list for each entry function.

What I still need to take into account is shadowing of override variables, where a local variable with the same name shadows an override variable. In the current code, the override would still be considered in use.