Commit Graph

66 Commits

Author SHA1 Message Date
Connor Fitzgerald
95d216bb57
Bump Versions 2023-10-25 13:16:06 -04:00
Jim Blandy
0c69735f59 Change naga:🔙:spv::DebugInfo::file_name to a &Path.
This makes it a bit easier to use in the CLI and snapshot tests.
2023-09-25 07:59:41 -07:00
Jim Blandy
8b267218a4 Implement module compaction.
Add a new Naga feature, `"compact"`, which adds a new function
`naga::compact::compact`, which removes unused expressions, types, and
constants from a `Module`.
2023-09-20 18:46:33 +02:00
Jim Blandy
0b7afb3943 cli: Move file output into its own function. 2023-09-20 18:46:33 +02:00
Jim Blandy
55a2ee445c cli: Gather up SPIR-V output options settings. 2023-09-20 18:46:33 +02:00
Jim Blandy
187aed8e11 cli: Put a full naga::front::spv::Options in Parameters.
This lets us gather up the code that influences SPV input.
2023-09-20 18:46:33 +02:00
Jim Blandy
23860c0e29 cli: Change --generate-debug-symbols from option to switch.
Change `--generate-debug-symbols` from an option that requires a
value, "true" or "false", to a switch, whose mere presence enables the
feature.
2023-09-20 18:46:33 +02:00
Jim Blandy
2a47a15f03 cli: Populate dot backend options in Parameters early.
This is a step towards having the output loop depend only on `params`,
rather than both `params` and `args`.
2023-09-20 18:46:33 +02:00
Elie Michel
0ae0446f3a
[cli] Add support for .{vert,frag,comp}.glsl files (#2462) 2023-09-13 15:23:58 +02:00
Connor Fitzgerald
bac2d82a43 Bump naga versions 2023-07-20 22:20:46 -04:00
Teodor Tanasoaia
a550b0b499
Split image bounds check policy (#2265) 2023-06-29 14:59:37 +00:00
wicast
3ca8b4997d
fix(spv-out-debug): fix debug options (#2394) 2023-06-29 13:31:26 +02:00
wicast
25e4f17a69
add debug info for spv-out (#2379) 2023-06-28 14:30:25 +02:00
Connor Fitzgerald
b99d58ea43 Update to version 0.12 2023-04-19 17:04:49 -04:00
Shaye Garg
67ea8f0c06
[wgsl-in] Split into multiple files (#2207)
Make changes suggested in #2075, but put off to a separate PR because they would interfere with reviewing the change:

- Split the new WGSL front end into modules in a logical way.
- Rename `Parser` to `Frontend`.
2023-01-31 07:17:58 -08:00
Jim Blandy
ca99d8bcbc Inline identifiers into format strings.
[Since Rust 1.58], Rust format strings have been able to "capture
arguments simply by writing {ident} in the string." Clippy 1.67 made
the corresponding warning, `uninlined_format_args`, warn-by-default.
Inlined arguments seem more readable, so Naga should adopt them.

[Since Rust 1.58]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1580-2022-01-13
2023-01-31 11:27:51 +01:00
Connor Fitzgerald
f0edae8ce9
Update to 0.11 (#2222) 2023-01-25 21:27:09 +00:00
Erich Gubler
224ff3897d build(cli): use conventional bin path for naga-cli 2022-12-27 10:38:37 -08:00
Erich Gubler
1650581fe7
refactor(cli): simplify output_paths w/ <&[T]>::get and Option::unwrap (#2114) 2022-11-04 16:20:47 +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
Connor Fitzgerald
c52d91023d
Add changelog and bump version to 0.10 (#2077) 2022-10-05 17:04:49 -04: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
João Capucho
c6f34fa4d8 dot-out: Improvements
Improves the dot backend output by:
- Linking new nodes to the end of other blocks, instead of the beginning
- Generating merge nodes for conditional statements
- Generating connections from break/continue nodes to their target
- Introducing a "cfg only" mode that only generates statements
2022-08-03 15:01:26 -07:00
Connor Fitzgerald
350171ed2f
Prepare naga-cli 0.9 for release (#1999) 2022-07-02 04:00:51 +00:00
Ashley
e2d688088a
Support for the OVR_multiview2 WebGL extension (#1933)
* Make some (currently hacky) changes to enable multiview in webgl

* Fix ViewIndex built in for this extension

* Run cargo fmt, fix tests

* Allow specifying if we're targetting webgl in the glsl version

* Document multiview2 extension

* fn embedded -> const fn embedded

* Fix tests

* Fix benches

* Add snapshot tests

* Revamp so that the glsl options have some multiview options. Also add tests

* Make clippy happier

* Go back to having is_webgl be part of Version

* Use wgsl as input for tests

* Rename Version::new_embedded to Version::new_gles, fix glsl validation

* Run cargo fmt

* Fix brand new clippy warnings
2022-06-30 17:58:47 +01:00
Jim Blandy
1c21fc02fe Let validation check for more unsupported builtins.
Add `valid::Capabilities` flags for the `ClipDistance` and
`CullDistance` builtins, which are not supported by all back ends.

Have the CLI perform valation with only those capabilities that the
requested back ends support.

Fixes #1961.
2022-06-01 14:20:06 -07:00
João Capucho
0aa7681165
glsl-out: Implement bounds checks for ImageLoad (#1889)
* glsl-out: Implement bounds checks for `ImageLoad`

* Enable image bounds check snapshot tests for GLSL.

In addition to the snapshot.rs changes, this entails adding an entry
point function to `bounds-check-image-restrict.wgsl` and
`bounds-check-image-rzsw.wgsl`, including appropriate data in the
param.ron files.

* Apply comments

Snapshot test changes:
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2022-05-30 12:13:58 -07:00
Noel Tautges
a99fc27dc1 Change !0 to <type>::MAX or -1, depending on signedness 2022-04-30 10:36:00 -07:00
Teodor Tanasoaia
7ce98dcc7d
Make use of new language features (#1841)
* use strip_prefix

* make fn const (resolving TODO)

* make use of nested OR patterns in match arms

* warn on clippy::missing_const_for_fn

* constify functions

* ignore clippy::missing_const_for_fn for into_inner functions
2022-04-17 03:39:54 -04:00
teoxoy
dd75579d7c fix typos 2022-04-14 13:47:18 -07:00
Dzmitry Malyshau
231da54cd7 Bincode support for naga-cli 2022-02-17 09:49:33 -05:00
Noel Tautges
42bf3545c9
Standardize some docs (#1660)
* Rewrite front/back doc summaries

- Use line comments instead of block comments
- Standardize language for each front/backend
- Add reference link for each format
- Minor punctuation changes

* Add documentation for keywords module

* Clarify contents of keywords module in summary

* Refer to modules by their type name

* Add basic summary for valid module

* Adjust EarlyDepthTest and ConservativeDepth docs

* Remove "in" from list

* Adjust wording

* Standardize format of docstrings

* Adjust module links to be consistent with other links

* Add summary for reserved keywords list

* Remove extraneous doc spaces with `cargo fmt`

* Correct spelling of whether and rewrite some lines

* Fill out GLSL backend docs

* Remove unnecessary link targets

* Fill out DOT backend docs

* Change module line comments to block comments

* Remove unnecessary spaces

* Fix mistake during rebasing
2022-02-03 13:27:21 -05:00
rhysd
f98053aa3c cli: Include file path in WGSL parse error 2022-01-29 08:52:15 -05:00
rhysd
0afa8fcb4f cli: Add --version flag 2022-01-28 12:16:00 -05:00
rhysd
6842db4432 cli: Support reading input from stdin 2022-01-27 12:59:01 -05:00
Jim Blandy
f51f468a47 [msl-out] Implement index bounds check policies for non-texture accesses. 2021-12-06 15:53:41 -05:00
Dzmitry Malyshau
f4ba74544a Refactor snapshot test arguments to avoid checking for deserialize feature too often.
We can safely assume that deserialize is enabled for all output tests.
Supporting other modes of operation has low utility.

This change also adds an option to skip the explicit types for WGSL output.
2021-11-26 11:36:46 -05:00
Jim Blandy
6a5b33fa24
Move BoundsCheckPolicy/Policies into proc, from back. (#1537) 2021-11-17 19:15:59 -08:00
Alex Es
ec001c3ead
Use span information in analyzer errors (proof of concept) (#1470)
* Proof-of-concept for adding spans to validation errors.

Still missing: actually printing the damn stuff.

* Emit errors from analyzer in the CLI.

TODO: tests, I guess!

* Simplification refactoring: avoid avoiding allocations so vehemently.

* Mask helper traits with `as _`.

* Fix block iterator throwing up when span feature is disabled.

* Nest use statements.

* Add basic docs.

* Axe AddSpanResult.
2021-10-24 22:47:03 -04:00
Dzmitry Malyshau
4cb91f2c98
cli: option to keep coordinate space unchanged (#1460) 2021-10-13 08:21:29 -04:00
Igor Shaposhnik
3e1244c5cb
Make shader validation under a separate feature (#1437) 2021-10-05 15:11:32 -04:00
João Capucho
af44603e47 [glsl-in] Use Span instead of SourceMetadata 2021-09-21 11:00:33 -04:00
Jim Blandy
95d3a4e699
Enable span tracking by default in the Naga CLI. (#1364) 2021-09-15 15:32:19 -07: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
Dzmitry Malyshau
7138876625 [spv-out]: ability to separate entry points 2021-09-07 14:22:39 -04:00
Jim Blandy
28547e3d3b Gather index, buffer, and texture bounds check policies into a single struct. 2021-08-26 19:08:06 -04:00
Jim Blandy
496525b7d3 Improve help messages, defaults for CLI bounds checking options. 2021-08-26 19:08:06 -04:00
Jim Blandy
1b95e023e7 [spv-out] Support a separate bounds check policy for buffers. 2021-08-26 19:08:06 -04:00
Jim Blandy
bdf774aa8b Rename BoundsCheckPolicy::UndefinedBehavior to Unchecked.
When we are leaning on robust buffer access to do the job for us, there's no
undefined behavior going on. So `UndefinedBehavior` suggests people are doing
something reckless even if they're not. The policy just says what Naga is doing,
and it shouldn't pretend to say what the rest of the system is doing.
2021-08-26 19:08:06 -04:00
Jim Blandy
901e2c0694 [spv-out] Implement BoundsCheckPolicy for image access 2021-08-22 23:41:27 -04:00