Commit Graph

38 Commits

Author SHA1 Message Date
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
João Capucho
af44603e47 [glsl-in] Use Span instead of SourceMetadata 2021-09-21 11:00:33 -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
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
Jim Blandy
de114e479b Rename IndexBoundsCheckPolicy to BoundsCheckPolicy. 2021-08-22 23:41:27 -04:00
João Capucho
1aaf77489b [glsl-in] Improve error api and make more errors deferred 2021-08-09 10:51:15 -04:00
João Capucho
f6e35f5b66 [glsl-in] Improved preprocessor and error handling 2021-08-09 10:51:15 -04:00
João Capucho
a8a316da15 [glsl-in] API revamp
The new api allows for reuse while keeping some allocations and to
please the borrow checker in future work, it also splits the parser into
logical modules to make it easier to work on.
2021-08-09 10:51:15 -04:00
João Capucho
057dc3100d [glsl-in] Remove support for multiple entry points 2021-08-04 11:06:57 -04:00
Zicklag
140a9bfa8f Fix Regression With CLI Not Working for Validation
Allows output file to be left empty to perform validation only.
2021-07-20 16:13:16 -04:00
Zicklag
a0e50e3eac Improve CLI Argument Doc and Error Handling
- Use argh for parsing commandline arguments and generating help message
- Remove almost all panics and handle errors by printing them and
exiting 1
2021-07-20 13:54:30 -04:00
Jasper St. Pierre
0995c7161e [glsl-in] Keep around extra linkage variables
WGSL will require this. Note that this still might
cause some issues with multi-entry-point GLSL
that I didn't know how to handle. That is, we will
handle unused builtin inputs but not unused
builtin outputs correctly right now. This is an existing
issue though, not a regression.

This is also provided as an option, but I feel like
the more correct approach is to never strip linkage
variables. We'll see though.
2021-07-14 17:48:54 -04:00
Dzmitry Malyshau
57b3256020 [glsl-out] binding location mapping 2021-06-27 01:09:53 -04:00
Gordon-F
e28344edbb [hlsl-out] Return entry points name to users 2021-06-24 10:47:17 -04:00
Gordon-F
391983459a [hlsl-out] Add enum with supported shader models 2021-06-24 10:47:17 -04:00
Jim Blandy
c16f2097ad [spv-out]: Ensure array subscripts are in bounds. 2021-06-18 20:44:07 -04:00
Jakob Hellermann
9d7e5cf0b5 [cli] add codespan_reporting to glsl error 2021-06-18 16:23:13 +01:00
Gordon-F
92a11d0978 [hlsl-out] More improvements. Enable quad snapshot testing 2021-06-15 21:08:05 -04:00
Gordon-F
54d7d7d2a3 Improve hlsl-out 2021-06-13 11:15:42 -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