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: Support the enable directive #5476

Closed
Tracked by #4384
armansito opened this issue Apr 2, 2024 · 5 comments · May be fixed by #5701
Closed
Tracked by #4384

WGSL: Support the enable directive #5476

armansito opened this issue Apr 2, 2024 · 5 comments · May be fixed by #5701
Assignees
Labels
area: correctness We're behaving incorrectly area: cts Issues stemming from the WebGPU Conformance Test Suite area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator

Comments

@armansito
Copy link
Contributor

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.

@teoxoy teoxoy added naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language labels Apr 2, 2024
@ErichDonGubler
Copy link
Member

Part of #4384.

@ErichDonGubler ErichDonGubler added area: correctness We're behaving incorrectly area: cts Issues stemming from the WebGPU Conformance Test Suite labels Apr 2, 2024
armansito added a commit to linebender/vello that referenced this issue Apr 19, 2024
The WGSL source currently cannot contain the "enable" directive as naga
doesn't support it (see gfx-rs/wgpu#5476). This patch works around this
limitation by introducing the "#enable" post-process directive.

Lines that start with "#enable" get turned into an inline comment during
the pre-process stage and converted to a standard "enable" directive
following the intermediate module compilation step. This allows us to
pass the WGSL shaders with enable directives on to other WebGPU
implementations.
github-merge-queue bot pushed a commit to linebender/vello that referenced this issue Apr 19, 2024
* [shaders] Support "enable" via post-process directive

The WGSL source currently cannot contain the "enable" directive as naga
doesn't support it (see gfx-rs/wgpu#5476). This patch works around this
limitation by introducing the "#enable" post-process directive.

Lines that start with "#enable" get turned into an inline comment during
the pre-process stage and converted to a standard "enable" directive
following the intermediate module compilation step. This allows us to
pass the WGSL shaders with enable directives on to other WebGPU
implementations.

* Document that r8unorm is available in Dawn native and not web
github-merge-queue bot pushed a commit to linebender/vello that referenced this issue Apr 19, 2024
* [shaders] Support "enable" via post-process directive

The WGSL source currently cannot contain the "enable" directive as naga
doesn't support it (see gfx-rs/wgpu#5476). This patch works around this
limitation by introducing the "#enable" post-process directive.

Lines that start with "#enable" get turned into an inline comment during
the pre-process stage and converted to a standard "enable" directive
following the intermediate module compilation step. This allows us to
pass the WGSL shaders with enable directives on to other WebGPU
implementations.

* Document that r8unorm is available in Dawn native and not web
@FL33TW00D
Copy link
Contributor

#5701

@EriKWDev

This comment was marked as resolved.

@ErichDonGubler ErichDonGubler changed the title naga: Support the enable directive WGSL: Support the enable directive Oct 1, 2024
@ErichDonGubler

This comment was marked as resolved.

@ErichDonGubler ErichDonGubler self-assigned this Oct 24, 2024
@ErichDonGubler
Copy link
Member

Resolved by #6424. 👏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: correctness We're behaving incorrectly area: cts Issues stemming from the WebGPU Conformance Test Suite area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants