Commit Graph

146 Commits

Author SHA1 Message Date
Noel Tautges
a99fc27dc1 Change !0 to <type>::MAX or -1, depending on signedness 2022-04-30 10:36:00 -07:00
Jim Blandy
e8723219b7 Validate ValuePointer exactly like a Pointer to a Scalar.
A `ValuePointer` type should always be handled exactly like the
equivalent `Pointer` to `Scalar` type. To this end:

- Adjust the handling of `TypeFlags::ARGUMENT`.

- Neither `Pointer` nor `ValuePointer` types are ever `DATA`.
2022-04-30 10:17:05 -07:00
Jim Blandy
5f4a070504 Simplify type handling in VaryingContext.
When `VaryingContext::validate` discovers that it needs to examine
each member of a struct, pass the type as an argument to `validate`
and `validate_impl`, rather than mutating `self.ty` on each iteration
of the loop. This matches the way we're handling the binding, and
avoids stashing per-iteration state in a surprising place.

This should have no effect on execution.
2022-04-30 10:12:43 -07:00
Jim Blandy
a06b604b80 Rename type flags to better align with the current WGSL spec.
TypeFlags::INTERFACE -> TypeFlags::IO_SHARED
(WGSL §4.4.4's "IO-shareable types")

TypeFLags::HOST_SHARED -> TypeFlags::HOST_SHAREABLE
(WGSL §4.4.5's "Host-shareable types")
2022-04-29 15:25:22 -07:00
Connor Fitzgerald
ad28396851 Implement Binding Arrays (#1845) 2022-04-19 14:23:07 -04: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
e4c017cb7c add more tests for operators 2022-04-15 11:21:51 +02:00
Jim Blandy
ba58ef5176 Document Naga's promises around validation and panics. 2022-04-14 13:47:41 -07:00
teoxoy
dd75579d7c fix typos 2022-04-14 13:47:18 -07:00
Jim Blandy
f11d27af6f Reject empty struct types. (#1826) 2022-04-14 09:36:53 -07:00
Jim Blandy
170faab6db Move invariant bit from Binding::Builtin to Builtin::Position. (#1822)
Use the type system to enforce the rule that the invariant attribute
may only appear on `Position` builtins.
2022-04-13 14:57:05 -07:00
teoxoy
d3957c1186 implement invariant attribute 2022-04-10 21:49:23 -07:00
Teodor Tanasoaia
2db49b6998 validate uniform address space layout constraints (#1812) 2022-04-09 22:35:28 -07:00
Shota Hamada
e6c202dc70 Fix typo 2022-02-27 10:30:54 -08:00
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