Add a new Naga feature, `"compact"`, which adds a new function
`naga::compact::compact`, which removes unused expressions, types, and
constants from a `Module`.
Re-implement `naga` development workflows using [`cargo xtask`]. Convert
`make` logic and shader test configuration as file with Bash variables
into an `xtask` crate and YAML files, respectively.
Pros:
* We now have a _portable_ workflow everywhere, which means Windows
folks and people who don't install `make` don't have to suffer.
😮💨
* Workflow logic is now relatively easy to inspect and change. Whew!
💁🏻♂️💦
* Contributors can use their existing Rust knowledge to contribute to
developer experience. 🎉
* `cargo xtask` is a relatively well-known convention for workflows in
the ecosystem.
* We can do fancy things like allow folks to run at different log levels
for workflows, depending on their tastes.
Cons:
* There's now a non-trivial compile step to project workflow.
Incremental rebuilds seem to be pretty short, though!
* Code is much more verbose than the (very) terse `make` implementation.
[`cargo xtask`]: https://github.com/matklad/cargo-xtask
* fix(glsl-out,hlsl-out,msl-out): parenthesize unary negations a la `wgsl` everywhere
Unify parenthesization of unary negations across all backends with what the `wgsl` backend does,
which is `<op>(<expr>)`. This avoids ambiguity with output languages for which `--` is a different
operation; in this case, we've been accidentally emitting prefix decrements.
* build: update `rspirv` 0.11 -> 0.12 (FIXME: use upstream release)
* test: add `operators::negation_avoids_prefix_decrement` test
Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
* build: move to the Rust 2021 edition
Since the MSRV of `naga` [is currently 1.56][msrv], I don't think there's a strong reason to stay
with the 2018 edition, and there _are_ a [few good reasons][edition-guide] to move to the 2021
edition.
I did this migration mostly automatically, per [official Rust guidelines]:
```sh
$ cargo fix --edition --all-targets
$ sed -i Cargo.toml 's/2018/2021'
$ cargo fix --edition-idioms --allow-dirty # doesn't change anything
```
The only manual edit needed to stymie a new warning introduced was the removal of the `TryFrom`
import in several modules, since it's now in the 2021 prelude.
[msrv]: a7193d652e/.github/workflows/pipeline.yml (L14)
[edition-guide]: https://doc.rust-lang.org/edition-guide/rust-2021/index.html
[official Rust guidelines]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html#edition-migration
* refactor(wgsl-in): use `pat` instead of `pat_param` again
How we were using `pat` in the Rust 2018 edition is actually the use case that
Rust 2021's `pat` fragment specifier is intended to satisfy. So, let's just use
that!
When it was introduced it was supposed to allow for fast compiles by
skipping glsl specific validation, but as it turns the subset of glsl that's
compilable code is already pretty close to the subset of valid glsl code.
So the current code gated behind glsl-validate amounts to a single branch that
isn't even performance sensitive, and most of the validation is not specific to
glsl and is made by naga's validator which can be turned off, so the original
goal of fast compile times by disabling validation can still be accomplished.
Require at least version 0.7.1 of ron, this version changed how floating points are
serialized by forcing them to always have the decimal part, this makes it backwards
incompatible with our tests because we do a syntatic diff and not a semantic one.
Ensure that each distinct type occurs only once in `Module::types`, so that we
can use `Eq` on `Type` or `TypeInner` for type equivalence, without being
confused by differing `Handle<Type>` values that point to identical types.
This removes a number of duplicate types from the ir snapshots.
Fixes#1385.
* [spv-in] New two pass parser based
* [spv-in] Allow expressions defined in dominant block in different scopes
* Make the patch non breaking
* [spv-in] Allow scope transfers in phi instructions
* [spv-in] Remove unused stuff
* [spv-in] Handle switch merges as breaks
* Remove no longer needed stuff
* Revert some changes to prepare to merge
* Remove dead code
* Don't spill into local if in scope
* [spv-in] Documentation, comments, some renaming for clarity.
* Address comments
Co-authored-by: Jim Blandy <jimb@red-bean.com>
* Implement lexing for all WGSL number literal types
* Move number literal test cases
* Adjust tests to match WGSL spec on number literals
Suffixes are not type names and currently only a plain `u` is supported
for uints. More specifically, `i` and `f` suffixes or suffixes with
widths in bits like `u32` are not supported at the moment.
* Add more tests for invalid number literal suffixes
* Replace code too new for Rust 1.43
* Implement parsing for hexadecimal integers
* Switch to enum number types, and Bytes for width
* Check for negative and leading zeros in int literals
* Implement parsing of hex floats with hexf-parse
* Update error message tests
* Update snapshot test output files
* Clean up lexer state machine code
* Clean up unexpected token error code
* Move number literal parsing to own submodule