Commit Graph

2127 Commits

Author SHA1 Message Date
teoxoy
8f1d82f0d2 [wgsl] update reserved keywords 2022-12-12 16:54:21 -08:00
Teodor Tanasoaia
9a00937b50 fix-fmt 2022-12-12 09:46:38 -08:00
Teodor Tanasoaia
300ffcafbf update error note 2022-12-12 09:46:38 -08:00
Teodor Tanasoaia
ee5c343038 fix tests 2022-12-12 09:46:38 -08:00
Teodor Tanasoaia
36bae0760d remove non-32bit integers 2022-12-12 09:46:38 -08:00
Teodor Tanasoaia
4748721857 remove comment 2022-12-12 09:33:24 -08:00
Teodor Tanasoaia
bf71b015a1 [wgsl-out] remove workgroup_size builtin 2022-12-12 09:33:24 -08:00
Teodor Tanasoaia
e671d6b49c [wgsl-in] remove workgroup_size builtin 2022-12-12 09:33:24 -08:00
robtfm
2dcb6963fa add Range::new_from_bounds 2022-12-12 11:57:23 +01:00
Jim Blandy
0197246365 Ignore unused_imports in tests/snapshots.rs.
This is for the same reason that we ignore `dead_code`:

    // A lot of the code can be unused based on configuration flags,
    // the corresponding warnings aren't helpful.
2022-12-12 11:14:17 +01:00
Jonathan Behrens
4f77cbafb7 [wgsl-out] Write correct scalar kind when width != 4 (#1514)
* [wgsl-out] Write correct scalar kind when width != 4

* slight refactoring

* Also handle matrix scalar widths

* Fix formatting
2022-12-12 10:56:28 +01:00
teoxoy
5a1f43d12d [doc] add more switch docs 2022-12-09 10:21:58 -08:00
teoxoy
63e85b4b15 [doc] explain how case clauses with multiple selectors are supported 2022-12-09 10:21:58 -08:00
teoxoy
f36adeefaa [glsl-out] introduce a new block for switch cases 2022-12-09 10:21:58 -08:00
teoxoy
eccdc0aeb1 [spv-out] omit extra switch case blocks where possible 2022-12-09 10:21:58 -08:00
teoxoy
be70a2ec03 [spv-out] fix switch cases after default not being output 2022-12-09 10:21:58 -08:00
teoxoy
3455147496 [hlsl-out] omit extra switch case blocks where possible 2022-12-09 10:21:58 -08:00
teoxoy
db63877c8c [msl-out] omit extra switch case blocks where possible 2022-12-09 10:21:58 -08:00
teoxoy
e05706bc48 [wgsl] remove fallthrough statement
also add support for default to be used with other case selectors
2022-12-09 10:21:58 -08:00
teoxoy
8405e387d8 [wgsl-in] use parse_block in more places 2022-12-09 10:21:58 -08:00
JMS55
bf4e62b1ac Fix textureGather on texture_2d<u32/i32> (#2138)
* Fix textureGather on texture_2d<u32/i32>

* Add textureGather u32/i32 tests

* Update src/valid/expression.rs

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

* Fix formatting

* undo analyzer change

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2022-12-05 10:03:11 +00:00
João Capucho
d1c29534c8 glsl-in: Fix position propagation in lowering (#2079)
When lowering `Select` expressions the position could be wrongfully
updated from `AccessBase { constant_index: false }` to
`AccessBase { constant_index: true }` this caused dynamic indexing
in an array behind a structure to fail if it was stored in a constant.

Furthermore the position could also be updated from `Rhs` to
`AccessBase`, this could cause issues because `AccessBase` doesn't
load variables (which `Rhs` does), so accessing a member from a
structure behind a pointer would return the wrong result.
2022-12-02 10:48:20 +01:00
Marco Buono
4976494709 Document EarlyDepthTest and ConservativeDepth syntax in WGSL (#2132) 2022-11-20 10:45:45 +01: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
Teodor Tanasoaia
e056805784 [msl-out] use back::COMPONENTS (#2124) 2022-11-16 11:12:45 -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
Teodor Tanasoaia
01fbdea21f fix 1.65 clippy lints (#2112) 2022-11-03 18:32:20 +01:00
Erich Gubler
21c7092762 Satisfy latest clippy lints (up to Rust 1.64) (#2081)
* refactor: satisfy `clippy::borrow_deref_ref`

* chore: satisfy `clippy::ptr_arg`

* refactor: satisfy `clippy::needless_update`

* chore: `allow(clippy::too_many_arguments)` on `write_output_glsl` test

Since this is test code, I don't think there's a strong impetus to refactor types to consolidate
or otherwise alter arguments here. Let's just `allow` this.

* refactor: satisfy `clippy::single_match`

I think it's sixes whether to keep this code as-is or to `allow(...)` as-is. 🤷🏻‍♂️

* refactor: satisfy `clippy::single_char_pattern`

* refactor: satisfy `clippy::reversed_empty_ranges`

The lint fires because it generally doesn't make sense to use a `Range` built this way; [upstream
`Range` docs]) states:

> It is empty if `start >= end`.

`clippy` wants to help us from naively iterating over a `Range` like this! Thanks, `clippy`!
However, we're not actually using the offending `addresses` variables for iteration. We're using
them as a flat data structure with fields that happen to conceptually match. We can, therefore,
sidestep this lint by "just" inlining into separate variables for start and end instead.

[upstream `Range` docs]: https://doc.rust-lang.org/stable/std/ops/struct.Range.html

* refactor: satisfy `clippy::pattern_type_mismatch`

* chore: `allow(clippy::panic)` for `test`

We definitely should let `panic!(...)` calls exist in `cfg(test)`! It's a very standard way to fail
`#[test]` functions. It seems that previous test authors agree! 😅

* fixup! refactor: satisfy `clippy::pattern_type_mismatch`

* fixup! refactor: satisfy `clippy::single_match`
2022-11-03 09:32:15 -07:00
Xiaopeng Li
e7fc8e64f2 Fix textureGather compatibility on macOS 10.13 (#2104)
* Fix textureGather compatibility on macOS 10.13

* Fix tests

* Update src/back/msl/writer.rs

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

Co-authored-by: Jet Spark <lixiaopeng.jetspark@bytedance.com>
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2022-10-27 09:28:46 +02:00
Erich Gubler
df4e40327c refactor(wgsl-out): use for loop for function arg. writing 2022-10-26 16:31:48 -04:00
Erich Gubler
469272c613 refactor(valid): s/error/source member name for ValidationError 2022-10-26 16:31:48 -04: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
Erich Gubler
2a11d830bb refactor: factor out new Validator::global_var_ty for expr. validation (#2086) 2022-10-25 08:38:44 -07:00
Raph Levien
ddcd5d3121 Fix incorrect atomic bounds check on metal back-end (#2099)
* Fix incorrect atomic bounds check on metal back-end

Generalize put_atomic_fetch to handle `exchange` as well, rather than special-cased code which didn't do the bounds check (the check handling as fixed in #1703 but only for the fetch cases, exchange was skipped).

Fixes #1848

* Add tests for atomic exchange
2022-10-24 09:20:57 -07:00
Connor Fitzgerald
d974f2f832 [hlsl-out] Properly implement bitcast 2022-10-20 11:00:21 -04:00
Connor Fitzgerald
2754a0136e [hlsl-out] Fix storage access chain through a matrix 2022-10-20 11:00:21 -04:00
Connor Fitzgerald
20d5445cb7 Workaround FXC Bug in Matrix Indexing (#2096) 2022-10-20 01:37:35 -04: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) naga-cli-v0.10.0 naga-v0.10.0 2022-10-05 17:04:49 -04:00
João Capucho
e07fd981c2 glsl-in: Update initializer list type when parsing (#2066)
Previously when parsing an initializer list, the type passed to
`parse_initializer` was not updated to reflect the child type, this
caused implicit conversions to not work and nested initializer lists to
not be allowed.
2022-10-05 11:17:25 -07:00
Igor Shaposhnik
0f26e5c808 [validate] Fix compiler warning 2022-10-04 15:21:36 +01:00
Max Ammann
abc4e1572a Explicitely enable std, and don't rely on environment (#2062) 2022-09-17 12:39:34 -07:00
Jim Blandy
7e3750a7f2 [wgsl] Fix line endings on wgsl reserved words list. (#2059) 2022-09-17 00:52:00 +00:00
Jim Blandy
33392382ee [wgsl-in] Break up long string, reformat rest of file. (#2057)
Whitespace and formatting changes only.

It turns out that if `cargo fmt` comes across a single line it can't
make fit within the margins, then it sort of gives up on the
surrounding construct. So breaking up the error message for
`Error::UnknownScalarType` in `Error::as_parse_error` and then
re-running `cargo fmt` cleans up lots of other stuff in the file.

cargo fmt issue:
https://github.com/rust-lang/rustfmt/issues/3863
2022-09-15 19:06:11 +00:00
Shaye Garg
5166c2a1d8 wgsl-in: Improve assignment diagnostics (#2056)
Fixes #2052.

* improved assignment statement errors

* hint immutable binding

* fix clippy

* add diagnostic tests

* cleanup formatting
2022-09-15 09:17:00 -07:00
SparkyPotato
4f8db997b0 remove trailing trivia 2022-09-14 23:16:24 -07:00
SparkyPotato
5d9cdd361f fix inclusion of trivia in spans 2022-09-14 23:16:24 -07:00
João Capucho
1a99c1cf06 wgsl-in: Fix bad span in assignment lhs error
The wgsl frontend was emiting errors for lhs expressions on assignments
that weren't references using a span that didn't skip blankspaces
causing the span to look weird (like starting at the end of the previous
line)

This is fixed by consuming the blankspace before constructing the span
2022-09-12 13:02:36 -07:00
João Capucho
ff69053bf2 valid: Check regular functions don't have bindings
Checks that all arguments and return types have no bindings in regular functions.
2022-09-10 10:31:11 -07:00