* 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
* Proof of concept for "span" feature, with WGSL parsing augmented.
* Review:
1) add_span was actually a bad idea, make it set_span and add
set_span_if_unknown too.
2) panics on getting/setting span for invalid handles.
3) only set span for constants with a name
4) don't overwrite spans for types.
* Added spans to blocks & more expressions getting spans in frontends.
Definitely the shotgunny type of commit, but what can you do. The design
I went with made spans mandatory to specify, so I had to go and wire
them through wherever I could.
* Moved Block to a separate module, +clippy
* More spans for types in GLSL.
* Remove pointless body method.
* Make Arena interface require spans.
Another shotgun commit, oh boy...
* Fix tests.
My loathsome habit to "quickly fix things along the way" made a lot of
extra work for me here, having to fix my "fixes" for WGSL parser.
* Rustfmt + clippy.
* Fix compile-errors with span feature enabled.
* Nuked set_span* from orbit. Deleting code feels great!
* Code review - move feature flags inside functions.
* Fix build with "deserialize" feature enabled.
Naga is now a workspace with `naga` and `cli` as its two members. The default
package for cargo commands is `cli`, so that `cargo run` will just run the CLI.
However, this has a few unexpected consequences:
- Now `cargo test` will just try to run `cli`'s tests, of which there are none.
Adding `"."` to the `default-members` list in the workspace's `Cargo.toml`
seems to fix this, without breaking `cargo run`.
- Even with `"."` added to `default-members`, `cargo test` will build `naga` by
default with the features requested for it in `cli/Cargo.toml`: all the front
and back ends, but no `serialize` or `deserialize`. This means that our CI job
meant to verify no-feature builds isn't doing that job any more. We need to
pass `--package naga` to `cargo test` to make it test naga directly.