Commit Graph

132 Commits

Author SHA1 Message Date
Jim Blandy
07f9cf670c Give Expression::ImageLoad separate sample and level operands. 2022-02-18 17:11:40 -05:00
Dzmitry Malyshau
14b4a686c6 bench: validation 2022-02-17 09:49:33 -05:00
Jim Blandy
763b0bcc90 FunctionInfo doc fixes, more specific variable names. 2022-02-15 22:45:25 -05:00
francesco-cattoglio
b235973d2e Add support for vecN<i32> and vecN<u32> to dot() function (#1689)
* Allow vecN<i32> and vecN<u32> in `dot()`, first changes

* Added a test case

* Fix the test

* Changes to baking of expressions, incl args of integer dot product

* Implemented requested changes for glsl backend

* Added support for integer dot product on MSL backend

* Removed outdated code for hlsl and wgls writers

* Implement in spv backend

* Commit modified outputs from running the tests

* cargo fmt

* Applied requested changes for both MSL and GLSL back

* Changes to spv back

* Committed all test output changes

* Cargo fmt

* Added a comment w.r.t. VK_KHR_shader_integer_dot_product

* Implemented requested svp change

* Minor change to test case

This is because I wanted to highlight the fact that the correct
id is used in the last sum of the integer dot product expression

* Changed function signature

since it could not fail, changed it to simply return `void`
2022-02-03 14:03:43 -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
Dzmitry Malyshau
9b89c5fa89 Improve error messages about address space 2022-02-02 12:42:29 -05:00
Dzmitry Malyshau
75692d3795 Allow non-structure buffer types 2022-02-02 10:08:20 -05:00
Dzmitry Malyshau
2ddc8d1929 Rename StorageClass to AddressSpace 2022-01-31 16:25:06 -05:00
Dzmitry Malyshau
4c91abe5b3 wgsl: remove stride 2022-01-24 16:44:12 -05:00
Dzmitry Malyshau
a89e248d68 layouter: let size() panic 2022-01-14 12:52:30 -05:00
Dzmitry Malyshau
d468e1512f Introduce BadHandle error 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
68b1ae1499 typifier: handle forward expression dependencies 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
be7df0d212 analyzer: skip invalid expressions 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
ab02ec7904 layouter: rich and careful errors 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
a069361bf4 validate: check local var type to be in range 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
fee69774a3 validate: check function argument type to be in range 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
c9f52bd651 validate: check global var type to be in range 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
a4ea9ce68d typifier: check local vars, global vars, and function arguments to exist 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
003ea29a3a validate: check constant composite type 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau
8003e3e30a Validate structure resource types 2022-01-03 12:44:58 -05:00
Luke Street
0d1fc2131f [wgsl-in] Support radians/degrees builtin functions (#1627) 2021-12-27 00:29:33 +00:00
Jonathan Behrens
f9b348557a Add FindLsb / FindMsb (#1473)
* Add FindLsb / FindMsb

* Fixes and tests for FindLsb/FindMsb

* Add findLsb / findMsb as WGSL builtins

* Fix tests

* Fix incompatible type issue with MSL output

* Requested changes

* Test fewer cases of findLsb/findMsb
2021-12-20 14:48:54 -05:00
Dzmitry Malyshau
8caa2bd87e Gather operations 2021-12-18 11:46:49 -05:00
Dzmitry Malyshau
7bb886bf36 Enforce casting width better, fix IEqual/INotEqual in spv 2021-12-16 16:14:56 -05:00
João Capucho
c64d5eff50 Support bitwise Or on booleans 2021-12-15 23:53:23 -05:00
Dzmitry Malyshau
8ffd6ba929 Remove top_level property of structs 2021-12-15 09:33:33 -05:00
Jim Blandy
cc930180d9 Tighten checks on pointers to unsized values, and pointer arguments.
Pointers should not be `DATA`: they can never be stored in anything. (Function
arguments are not storage; they're like `let` bindings.)

Un-`SIZED` values may only live in the `Storage` storage class, so creating
pointers to them in other storage classes is meaningless.

The `ARGUMENT` flag should be set only on pointers in those storage classes that
are permitted to be passed to functions.

See comments in code for details.

Fixes #1513.
2021-11-18 17:39:56 -05:00
Jim Blandy
ce18eba695 Check that stores are permitted by the pointer's storage access.
Fixes #1533.
2021-11-16 23:40:56 -05:00
Jim Blandy
90daa9edfe Forbid specializable constants as array lengths.
Only the SPIR-V front end can produce such array types, and it seems that our
back ends don't support this case well.
2021-11-16 09:12:42 -05:00
Boris-Chengbiao Zhou
1dcde48d09 [valid] Check that switches have a default case (#1529)
From the WGSL spec: "Each switch statement must have exactly one default clause."
2021-11-15 00:07:55 +00:00
Dzmitry Malyshau
323999fcb9 Fix span includes into function validation (#1500) 2021-10-31 23:58:58 -04:00
João Capucho
0458f0a404 [valid] Check that the last switch case isn't falltrough (#1485) 2021-10-26 21:33:49 -04:00
João Capucho
63dbd38edc Make default a switch case (#1477)
* Make default a switch case

Previously the default case of a switch statement was encoded as a block
in the statement but the wgsl spec defines it in such a way that the
default case ordering matters.

* [spv-out] Support for the new switch IR

* [dot-out] Use different labels for default cases
2021-10-26 13:31:54 -04:00
Jim Blandy
5cf11ab734 Make use of AddSpan and MapErrWithSpan conditional.
This avoids warnings in default-feature builds, like `cargo test -p naga`.
2021-10-25 19:35:59 +01: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
Connor Fitzgerald
2f5a41cce9 Add insert/extractBits and pack/unpack functions (#1449) 2021-10-05 20:32:57 -04:00
Igor Shaposhnik
3e1244c5cb Make shader validation under a separate feature (#1437) 2021-10-05 15:11:32 -04:00
Jim Blandy
f30f3a3db6 Properly type-check Expression::Select arguments. (#1442)
Require the `accept` and `reject` arguments to `select` to be scalars or
vectors, per WGSL spec.
2021-10-01 12:47:39 -04:00
Jim Blandy
ea50486b2d Forbid unsized structs as final members of structs. (#1443)
WGSL says:

> - The last member of the structure type defining the store type for a variable
>   ... may be a runtime-sized array.
>
> - A runtime-sized array must not be used as the store type or contained within
>   a store type in any other cases.

Thus, a struct whose final member is a struct whose final member is a
runtime-sized array is verboten.
2021-10-01 09:40:18 -04:00
Dzmitry Malyshau
21324b8fea Update WGSL grammar for pointer access. (#1312)
* Update WGSL grammar for pointer access.

Comes with a small test, which revealed a number of issues in the backends.

* Validate pointer arguments to functions to only have function/private/workgroup classes.

Comes with a small test. Also, "pointer-access.spv" test is temporarily disabled.
2021-09-27 18:49:28 -04:00
Jim Blandy
f3ea2130a4 [wgsl-in]: Correctly compare pointer types.
Treat `TypeInner::ValuePointer` and `TypeInner::Pointer` as equivalent by
converting them to a canonical form before comparison.

Support `ValuePointer` in WGSL type output.

Fixes #1318.
2021-09-27 16:01:43 -04:00
Jim Blandy
6e4401ae96 Rename UniqueArena methods to more closely resemble HashSet.
`UniqueArena::fetch_or_append` becomes `insert`.

`UniqueArena::try_get` becomes `get_handle`, by analogy with `get`, that takes a
type as a key.
2021-09-27 15:17:41 -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
Jim Blandy
d44e2ad207 Simplify interpolation defaulting.
Replace `Module::apply_common_default_interpolation` with a simpler function
that handles a single `Binding` at a time. In exchange for the simplicity, the
function must be called at each point function arguments, function results, and
struct members are prepared. (Any missed spots will be caught by the verifier.)

This approach no longer requires mutating types in the arena, a prerequisite for
properly handling type identity.

Applying defaults to struct members when the struct declaration is parsed does
have a disadvantage, compared to the old whole-module pass: at struct parse
time, we don't yet know which pipeline stages the struct will be used in. The
best we can do is apply defaults to anything with a `Location` binding. This
causes needless qualifiers to appear in some output. However, it seems that our
back end languages all tolerate such qualifiers.
2021-09-27 15:17:41 -04:00
João Capucho
d5fc05e8a4 Allow unsigned integers in switch 2021-09-21 17:16:51 -04:00
João Capucho
98944bb7a6 Track finished across compound statements 2021-09-20 12:00:22 -04:00
João Capucho
60d0bf850b Add support for multi view extensions 2021-09-19 17:38:27 -04:00
Jim Blandy
d4bedafbda Move #[must_use] attr on Capabilities to where it'll take effect.
This was causing warnings in nightly (1.56.0).
2021-09-07 17:30:08 -04:00
João Capucho
bbf3e465f3 Add support for inverse hyperbolic trignometric functions
Hlsl and wgsl don't support them directly so a polyfill is used taken
from the msl spec.

`asinh` = `log(x + sqrt(x * x + 1.0))`
`acosh` = `log(x + sqrt(x * x - 1.0))`
`atanh` = `0.5 * log((1.0 + x) / (1.0 – x))`
2021-08-20 16:57:18 -04:00
sigaloid
9050108a95 Fix some clippy suggestions 2021-08-20 16:42:47 -04:00