Commit Graph

2127 Commits

Author SHA1 Message Date
SparkyPotato
dcfd5c6f4a improve invalid assignment diagnostic 2023-02-01 12:28:31 +01:00
SparkyPotato
231af68386 expect semicolons wherever required 2023-02-01 12:28:31 +01:00
SparkyPotato
e6bd2e9071 fix panic on invalid zero array size 2023-02-01 12:28:31 +01:00
SparkyPotato
bb20ae8e79 check for leading { while parsing a block 2023-02-01 12:28:31 +01:00
Dzmitry Malyshau
16be1a9237 spv-out: support version 1.4 (#2230)
* spv-out: support version 1.4

* Extract SPV version numner from the comment
2023-02-01 12:24:05 +01:00
Evan Mark Hopkins
6be394dac3 Add countLeadingZeros (#2226)
* Add countLeadingZeros

* [glsl-out] Bake countLeadingZeros

* [hlsl-out] Bake countLeadingZeros

* [hlsl-out] Update Baked expressions

* Remove unnecessary bake for sints

* [glsl-out] CountLeadingZeros without findMSB

* Don't check negatives when uint

* Perform the type conv after mix

* use log2

* fix clippy lints

---------

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-01-31 21:31:05 +01:00
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
João Capucho
0074c68ec4 valid: Check dependencies between functions calls
This commit enforces the forward dependency rules on the IR across
functions and their calls, this fixes a crash in a later stage of the
validator.
2023-01-31 07:35:31 -08:00
João Capucho
bebaac93b6 valid: Fix handle dependency validation
The handle dependency validation code was using the handle's index
directly while trying to erase the handle type. This would cause the
validator to crash while processing the first handle of the arena since
it would be trying to construct a `NonZeroU32` with a zero.

This commit fixes the issue by adding 1 to the index which not only
fixes this panic but also makes so that the created Handle is equal to
the passed handle (minus the type that was erased)

It also fixes the error message not including the subject's kind
2023-01-31 07:35:31 -08: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
João Capucho
ae049edc49 glsl-in: Add not vector relational builtin 2023-01-31 13:29:37 +00:00
João Capucho
191d71c107 glsl-in: Add test for relational vector builtins 2023-01-31 13:29:37 +00:00
João Capucho
372a715434 glsl-in: Add double overloads for relational vector builtins
All relational vector builtins that operate on floats can also operate
on doubles but these overloads were not present. This commit fixes that.
2023-01-31 13:29:37 +00:00
João Capucho
08366c8fd0 glsl-in: Add bool overloads for relational vector builtins
The `equal` and `notEqual` builtins also operate on boolean vectors but
the overloads accepting them were not added. This commit fixes that.
2023-01-31 13:29:37 +00: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
Jim Blandy
26dca556a9 Allow clippy::needless_borrowed_reference.
In Clippy 1.67, the `needless_borrowed_reference` lint [was enhanced]
to look into struct and tuple patterns, so that a line like this:

    for &(ref module, ref info) in inputs.iter()

where `inputs.iter()` is yielding `&(Module, ModuleInfo)` pairs,
elicits a warning. Clippy suggests, instead:

    for (module, info) in inputs.iter()

but this is at odds with Naga's preference that `match` patterns
should have the same type as the expression being matched, for which
we have enabled the `pattern_type_mismatch` lint since
9e5cc4c9 (2021-3-12).

[was enhanced]: https://github.com/rust-lang/rust-clippy/pull/9855
2023-01-31 11:27:51 +01:00
Connor Fitzgerald
f0edae8ce9 Update to 0.11 (#2222) naga-cli-v0.11.0 naga-v0.11.0 2023-01-25 21:27:09 +00:00
Teodor Tanasoaia
13944c0ae5 Update CHANGELOG.md 2023-01-25 15:11:16 -05:00
Teodor Tanasoaia
fe9db5dd8d install cargo-tarpaulin via cargo-binstall (#2220) 2023-01-25 18:21:24 +00:00
teoxoy
c7d02151f0 add support for zero-initializing workgroup memory 2023-01-25 18:07:48 +01:00
teoxoy
3ace8b81cb fix array being flagged as constructible when its base isn't 2023-01-25 18:07:48 +01:00
teoxoy
85e3b0844f add type_flags to ModuleInfo 2023-01-25 18:07:48 +01:00
teoxoy
a42857d291 [hlsl-out] simplify write_default_init 2023-01-25 18:07:48 +01:00
teoxoy
e5121ca012 factor out write_barrier functions 2023-01-25 18:07:48 +01:00
Patryk Wychowaniec
954cbaaff3 [spv-in] Support binding arrays (#2199) 2023-01-25 17:49:52 +01:00
Teodor Tanasoaia
f70d8ec51f update test snapshots (#2219) 2023-01-23 11:09:15 +00:00
robtfm
4142971cb1 glsl: include unused items (#2205)
* include_unused_items

* clippy

* tests

* rename original const if possible
2023-01-23 11:58:05 +01:00
Evan Mark Hopkins
a638da9edb [wgsl] Removes isFinite and isNormal 2023-01-23 11:50:50 +01:00
Evan Mark Hopkins
74e5b4a07e [wgsl] Update inverse hyperbolic built-ins 2023-01-23 11:50:50 +01:00
Evan Mark Hopkins
9f182ade30 [wgsl] Add refract built-in 2023-01-23 11:50:50 +01:00
Jonathan Behrens
1be8024bda Support 16-bit unorm/snorm formats (#2210)
* Support 16-bit unorm/snorm formats

* Add Capabilities::STORAGE_TEXTURE_16BIT_NORM_FORMATS

* Add 16-bit normalized formats to spv frontend
2023-01-18 19:03:24 +01:00
Jonathan Behrens
1cffd236a7 Remove overly restrictive array stride check (#2215) 2023-01-18 16:28:38 +01:00
Jim Blandy
cdcfad277a Let the uniformity analysis trust the handle validation pass.
Undo some changes from #1668, now that #2090 has been merged.
2023-01-14 19:25:31 -08:00
Jim Blandy
f0a8ff6b3a Fix docs for Emit statements. (#2208) 2023-01-15 00:00:15 +01:00
SparkyPotato
6035b07b78 [wgsl-in] Implement module-level scoping.
Fixes #1745: Support out-of-order module scope declarations in WGSL
Fixes #1044: Forbid local variable shadowing in WGSL
Fixes #2076: [wgsl-in] no error for duplicated type definition
Fixes #2071: Global item does not support 'const'
Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes #1775: Referencing a function without a return type yields an unknown identifier error.
Fixes #2089: Error span reported on the declaration of a variable instead of its use
Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"

Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2023-01-12 09:37:08 -08:00
Timo de Kort
7effd12596 Update setup-dxc to v1.1.0 (#2204) 2023-01-11 18:23:42 +01:00
Jim Blandy
86a88de396 Revert "Error if the uniformity requirements for a barrier aren't met" (#2203)
This reverts commit e6e94d65ab.
2023-01-11 16:35:03 +01:00
Daniel McNab
e6e94d65ab Error if the uniformity requirements for a barrier aren't met 2023-01-09 16:39:33 -08:00
teoxoy
5b4e94630b [glsl-out] use fma polyfill for versions below gles 320 2023-01-06 17:20:27 -08:00
Rainb0w :3
e98bd9264c [glsl-out] emit reflection info for non-struct uniforms (#2189) 2023-01-04 20:26:52 +01:00
Erich Gubler
224ff3897d build(cli): use conventional bin path for naga-cli 2022-12-27 10:38:37 -08:00
PENGUINLIONG
24316fd4bc Allow u32 coordinates for textureStore/textureLoad (#2172) 2022-12-22 18:59:22 +01:00
Dzmitry Malyshau
02280a7357 msl: handle the case of missing binding (#2175) 2022-12-22 11:21:21 +01:00
Zhixing Zhang
8e1b0529e6 Supporting gl_PointCoord (#2180) 2022-12-21 13:05:15 +01:00
Jim Blandy
37be4df2b8 Fix warnings when building tests without validation. 2022-12-20 22:24:24 -08:00
Erich Gubler
461fdda425 Add handle validation pass to Validator (#2090)
Before proceeding with any other validation, check that all Handles are valid for their arenas, and refer only to older handles than themselves. This allows subsequent stages to simply use indexing without panics, assuming validation has passed.
2022-12-17 00:26:43 +00:00
Erich Gubler
420c9845f8 refactor: resolve clippy::manual_clamp 2022-12-15 11:20:47 -08:00
Erich Gubler
3c26ffb07a fix(docs): fix invalid <...> URLs with code spans 2022-12-15 11:20:47 -08:00
Dzmitry Malyshau
76d30e5055 Add ValidationFlags::BINDINGS 2022-12-13 12:59:28 -05:00
Avi Weinstock
5d8fc3fdcf [wgsl-in/spv-out] Add support for WGSL's atomicCompareExchangeWeak (#2165)
* Add support for WGSL's `atomicCompareExchangeWeak` with the `__atomic_compare_exchange_result` struct, and add SPIR-V codegen for it.

Partially addresses https://github.com/gpuweb/gpuweb/pull/2113, #1755.

* Add tests for `atomicCompareExchangeWeak`, and support both u32 and i32 atomics with it.

* More thorough typechecking of the struct returned by `atomicCompareExchangeWeak`.
2022-12-13 10:47:28 +01:00