Re: [webgpu] Add the `import` keyword or some equivalent

On Fri, Jan 17, 2025 at 8:40 AM Brendan Duncan <brendan.duncan@unity3d.com>
wrote:

> This was discussed at https://github.com/gpuweb/gpuweb/issues/741, and
> https://github.com/gpuweb/gpuweb/issues/568.
>
> Personally, I think it could be done better as third-party code using
> string manipulation, rather than via shader module dependency tracking
> within the api. External tools can be implemented easily enough to provide
> that functionality. Some have already been developed.
>
> On Fri, Jan 17, 2025 at 1:13 AM Rowan Fraser <beanfun1@gmail.com> wrote:
>
>> Hello W3 Consortium,
>> I want to work with WGSL and WebGPU but the inability to have any kind of
>> import or library or modulation mechanism is crippling to any real-world
>> development in the language. It isn't possible currently to have reasonably
>> sized scriptis, instead I'm forced to jump around to different commented
>> sections. I would like to use WGPU as a universal shading language but as
>> it stands the inconvenience of that (along with other tooling issues) makes
>> it an unsuitable replacement for tools such as Vulkan and SPIR-V.
>>
>
You mentioned Vulkan and SPIR-V works better in this regard? But isn't that
path even worse? AFAIK, few people write SPIR-V, instead they use some
external tool to convert something like GLSL into SPIR-V. Maybe you've been
using an external solution for so long you forgot it was just that, an
*external* solution?


> I think that one key functionality would do a great deal to open up
>> development as it would allow passing around of functional libraries while
>> also preventing WGSL scripts from becoming too bloated.
>> Thank you for your time,
>> From Rowan Fraser
>>
>
I agree with Brendan. This is best performed outside of the API. That keeps
the API simple and lets the solution chosen be as complex or as simple as
desired. New features can be added as well without having to wait for every
WebGPU implementation to add them.

Some existing solutions in order of complexity:

* https://github.com/toji/wgsl-preprocessor
* https://github.com/wgsl-tooling-wg/wesl-js
* https://github.com/shader-slang/slang

Received on Friday, 17 January 2025 20:14:33 UTC