gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
12.6k stars 922 forks source link

WGSL: Support the `enable` directive #5476

Closed armansito closed 2 weeks ago

armansito commented 7 months ago

The WGSL specification has introduced the enable directive for to implementation-specific extensions (see https://www.w3.org/TR/WGSL/#enable-extensions-sec). Currently naga rejects these as an invalid token, for example:

enable f16;
^^^^^^ expected global item ('struct', 'const', 'var', 'alias', ';', 'fn') or the end of the file

Even if naga doesn't support a requested extension, it should recognize the enable directive. In my specific use case, naga is used to parse and preprocess WGSL which may end up getting passed on to a different implementation (i.e. Dawn/Chromium). It would be nice to be able to declare Chromium-specific enable directives for the wgsl-in -> wgsl-out case.

ErichDonGubler commented 7 months ago

Part of #4384.

FL33TW00D commented 5 months ago

5701

EriKWDev commented 2 months ago

just wanna bumb that this is not only f16 support-related but also clip_distances which would be very handy for planar the reflections in our engine, but since we cannot set the clip-distances in wgsl atm we have to resort to fragment-shader discard

ErichDonGubler commented 2 weeks ago

@EriKWDev: Just filed #6236 for that extension specifically. 🙂

ErichDonGubler commented 2 weeks ago

Resolved by https://github.com/gfx-rs/wgpu/pull/6424. 👏🏻