Skip to content

Commit

Permalink
WIP: docs(CHANGELOG): add entry for diagnostic(…) directives
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Nov 5, 2024
1 parent a7a3ade commit a1fe152
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,45 @@ Bottom level categories:

## Unreleased

## Major changes

### The `diagnostic(…);` directive is now supported in WGSL

Naga now parses `diagnostic(…);` directives according to the WGSL spec. This
allows users to control certain lints, similar to Rust's `allow`, `warn`, and
`deny` attributes. For example, this snippet would emit a uniformity error:

```wgsl
@compute
fn vs_main() {
TODO // Emits a derivative uniformity error during validation.
}
```

…but we can now silence it with the `off` severity level, like so:

```wgsl
diagnostic(off, derivative_uniformity);
@compute
fn vs_main() {
TODO // Look ma, no error!
}
```

There are some limitations to keep in mind with this new functionality:

- We do not yet support `diagnostic(…)` rules in attribute position (i.e., `@diagnostic(…) fn my_func { … }`). This is being tracked in <https://github.com/gfx-rs/wgpu/issues/5320>. We expect that rules in `fn` attribute position will be relaxed shortly (see <https://github.com/gfx-rs/wgpu/pull/6353>), but the prioritization for statement positions is unclear. If you are blocked by not being able to parse `diagnostic(…)` rules in statement positions, please let us know in that issue, so we can determine how to prioritize it!
- Standard WGSL specifies `error`, `warning`, `info`, and `off` severity levels. These are all technically usable now! A caveat, though: warning- and info-level are only emitted to `stderr` via the `log` façade, rather than being reported through a `Result::Err` in Naga or the `CompilationInfo` interface in `wgpu{,-core}`. This will require breaking changes in Naga to fix, and is being tracked by <https://github.com/gfx-rs/wgpu/issues/6458>.
- Not all lints can be controlled with `diagnostic(…)` rules. In fact, only the `derivative_uniformity` triggering rule exists in the WGSL standard. That said, Naga contributors are excited to see how this level of control unlocks a new ecosystem of configurable diagnostics.
- Finally, `diagnostic(…)` rules are not yet emitted in WGSL output. This means that `wgsl-in``wgsl-out` is currently a lossy process. We felt that it was important to unblock users who needed `diagnostic(…)` rules (i.e., <https://github.com/gfx-rs/wgpu/issues/3135>) before we took significant effort to fix this (tracked in <https://github.com/gfx-rs/wgpu/issues/6496>).

By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456).

### New Features

#### Naga

- Parse `diagnostic(…)` directives, but don't implement any triggering rules yet. By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456).
- Fix an issue where `naga` CLI would incorrectly skip the first positional argument when `--stdin-file-path` was specified. By @ErichDonGubler in [#6480](https://github.com/gfx-rs/wgpu/pull/6480).
- Fix textureNumLevels in the GLSL backend. By @magcius in [#6483](https://github.com/gfx-rs/wgpu/pull/6483).

Expand Down

0 comments on commit a1fe152

Please sign in to comment.