Commit Graph

102 Commits

Author SHA1 Message Date
teoxoy
a2b39e45bf [hlsl-out] clear named_expressions inserted by duplicated blocks
changed the type of `named_expressions` from `HashMap` to `IndexMap` so that insertion order is preserved
2023-01-31 10:43:02 -08:00
Connor Fitzgerald
f0edae8ce9
Update to 0.11 (#2222) 2023-01-25 21:27:09 +00:00
Teodor Tanasoaia
5b79cca384
bump MSRV to 1.63 (#2129) 2022-11-18 16:29:49 +00:00
Erich Gubler
aa22301b4b
Parenthesize unary negations to avoid -- (#2087)
* 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>
2022-11-17 11:43:56 +01:00
Erich Gubler
b37dda8854
build: move to the Rust 2021 edition (#2085)
* 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!
2022-10-25 08:44:17 -07:00
Sludge
a7193d652e
Fix repository link pointing to the 0.9 branch (#2078) 2022-10-06 19:39:41 -04:00
Connor Fitzgerald
c52d91023d
Add changelog and bump version to 0.10 (#2077) 2022-10-05 17:04:49 -04:00
Max Ammann
abc4e1572a
Explicitely enable std, and don't rely on environment (#2062) 2022-09-17 12:39:34 -07:00
João Capucho
7d0e9847b0 Remove the glsl-validate feature
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.
2022-09-05 19:37:39 -07:00
daxpedda
48e79388b5
Implement Clone for Module (#2013)
This is hidden behind the `clone` feature flag
2022-08-16 11:45:19 +01:00
Jeron Aldaron Lau
a0058217d6
Make termcolor dependency optional (#2014) 2022-07-23 00:46:28 -04:00
Connor Fitzgerald
06ae90527d
Release 0.9 (#1998)
* Release 0.9

* Further update changelog

* Apply suggestions from code review

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2022-06-30 19:51:46 +00:00
João Capucho
357da63076
Patch ron version (#1986)
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.
2022-06-15 15:17:59 -04:00
Mehmet Oguz Derin
9c8a51830c Use Unicode 14 for WGSL
The unicode-xid crate just had a release with Unicode 14 data, which the WGSL spec requires.
2022-05-02 15:34:13 +02:00
teoxoy
850565243d replace unicode-id with unicode-xid 2022-04-18 13:03:37 -07:00
teoxoy
94467c770f fix bitflags min version 2022-04-18 08:08:22 -07:00
teoxoy
743c8aa387 update lexer to match more unicode characters 2022-04-17 21:01:01 -07:00
teoxoy
bddfc34299 fix minimal-versions of dependencies 2022-04-17 20:59:59 -07:00
teoxoy
33085863b7 update msrv to 1.56 2022-04-16 08:32:31 -07:00
Dzmitry Malyshau
91990298b3 Don't test on MSRV, just check 2022-02-17 09:49:33 -05:00
Dzmitry Malyshau
5879f9ea73 bench: glsl, spirv, and bincode inputs 2022-02-17 09:49:33 -05:00
Dzmitry Malyshau
b05f648842 bench: WGSL parsing 2022-02-17 09:49:33 -05:00
Dzmitry Malyshau
b12ed2cc9e Fix arbitrary for MSRV 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
58b4fd0f57 IR fuzz target with Arbitrary implementations 2022-01-14 12:44:27 -05:00
Benoît du Garreau
9f37624592 Don't pin indexmap version 2022-01-12 13:31:40 -05:00
João Capucho
70b5ddaaad spv-out: use OpFRem instead of OpFMod 2022-01-07 20:19:15 -05:00
Jeff Muizelaar
848ae3dc6e
Turn on panic = "abort" by default (#1597)
This reduces the size of a release naga binary on macOS
from 3.5MB to 3.2MB. It's also the configuration we use
for naga in Firefox.
2021-12-26 20:01:49 -05:00
Dzmitry Malyshau
c2328fea75 Release v0.8 2021-12-18 12:05:12 -05:00
bjorn3
38366e382f Switch to rustc-hash
See gfx-rs/rspirv#221 for the rationale behind this change
2021-11-16 23:51:19 -05:00
Igor Shaposhnik
30a0a37af0 Update dependencies 2021-11-16 23:46:54 -05:00
Dzmitry Malyshau
3b49981111 Bump version to 0.7.1 2021-10-12 11:44:13 -04:00
Dzmitry Malyshau
3a2f7e611e
Release 0.7 (#1455) 2021-10-07 18:04:30 -04:00
Igor Shaposhnik
3e1244c5cb
Make shader validation under a separate feature (#1437) 2021-10-05 15:11:32 -04:00
Igor Shaposhnik
a4bf25a0d5
Emit std430 layout qualifiers for storage buffers (#1435)
* Remove unused petgraph dependency from glsl-out

* Emit std430 layout qualifiers for storage buffers
2021-09-29 12:24:34 -04:00
Jim Blandy
944a693ae5 Use UniqueArena for types.
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.
2021-09-27 15:17:41 -04:00
João Capucho
3049f63cad
[spv-in] new block parser (#1294)
* [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>
2021-09-10 08:51:05 -07:00
aentity
a35de06f33 Update deps petgraph and rose-tree 2021-08-24 01:51:52 -04:00
Hans Christian Schmitz
58a5b7d2b9
Implement lexing and parsing for all WGSL number literal types (#1184)
* 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
2021-08-24 01:50:53 -04:00
Connor Fitzgerald
800f910103 Allow newer bitflags 2021-08-22 22:19:27 -04:00
Dzmitry Malyshau
7a45d73465 Release v0.6 version, changelog, and spirv update 2021-08-18 00:39:25 -04:00
Dzmitry Malyshau
d55645ac1e
Fix bitflags at 1.2 (#1190) 2021-08-12 00:57:13 -04:00
Alex Es
fd70116668
Proof of concept for "span" feature, with WGSL & GLSL parsing augmented. (#1092)
* 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.
2021-08-11 16:04:32 -04:00
Jasper St. Pierre
0b69aa8b8a Init env_logger in snapshots tests
For debugging. Maybe there's a way to do it for all tests,
not sure...
2021-07-14 17:48:54 -04:00
Dzmitry Malyshau
8376bab562 Bump version to 0.5 2021-06-18 20:18:52 -04:00
Jim Blandy
fd83816945 Add . to the workspace's default members. Test with no features.
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.
2021-06-16 13:53:00 -04:00
Jakob Hellermann
4224d14a08
move bin/naga.rs to a separate crate in workspace (#938)
* move bin/naga.rs to a separate crate

* enable all shader languages for naga binary

* [naga-cli] add env logger

* [naga-cli] remove unneccessary code

* [naga-cli]enable glsl-validate feature

* move naga-cli to cli, add trailing newline

* remove commented env_logger dependency
2021-06-12 19:24:01 -04:00
Igor Shaposhnik
ce88c9d537 Exclude bin and tests from publishing 2021-06-03 13:06:45 -04:00
João Capucho
39ccec5e7d [glsl-in] Update pp-rs for location info 2021-05-19 16:24:26 -04:00
João Capucho
ff8f15e034 [glsl-in] Start writting a parser without pomelo 2021-05-19 16:24:26 -04:00
Matúš Talčík
0960d1162f [spv-in] multiple improvements
- added constructs
- added loop detection
- some logic from Tint borrowed for selection constructs
2021-05-06 10:49:09 -04:00