Commit Graph
170 Commits
Author SHA1 Message Date
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 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
PENGUINLIONG 24316fd4bc Allow u32 coordinates for textureStore/textureLoad (#2172) 2022-12-22 18:59:22 +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
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
JMS55andTeodor Tanasoaia 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
Erich Gubler 469272c613 refactor(valid): s/error/source member name for ValidationError 2022-10-26 16:31:48 -04:00
Erich Gubler 2a11d830bb refactor: factor out new Validator::global_var_ty for expr. validation (#2086) 2022-10-25 08:38:44 -07:00
Igor Shaposhnik 0f26e5c808 [validate] Fix compiler warning 2022-10-04 15:21:36 +01: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
Jim Blandy eb6124ec94 Document arithmetic binary operation type rules. 2022-09-10 17:12:35 +01:00
Evan Mark Hopkins a80967f860 Add support for the saturate function (#2025)
uses clamp in place of saturate in spv and glsl
2022-08-16 10:43:41 +00:00
Ashley e2d688088a Support for the OVR_multiview2 WebGL extension (#1933)
* Make some (currently hacky) changes to enable multiview in webgl

* Fix ViewIndex built in for this extension

* Run cargo fmt, fix tests

* Allow specifying if we're targetting webgl in the glsl version

* Document multiview2 extension

* fn embedded -> const fn embedded

* Fix tests

* Fix benches

* Add snapshot tests

* Revamp so that the glsl options have some multiview options. Also add tests

* Make clippy happier

* Go back to having is_webgl be part of Version

* Use wgsl as input for tests

* Rename Version::new_embedded to Version::new_gles, fix glsl validation

* Run cargo fmt

* Fix brand new clippy warnings
2022-06-30 17:58:47 +01:00
João Capucho 67ef37ae99 Add support for 'break if' to IR, wgsl-in, and all backends. 2022-06-24 17:47:07 -07:00
teoxoy 46387e90ce unify alignment related functionality 2022-06-16 12:13:08 -07:00
Jim Blandy 89bed99bcc Forbid returning pointers and atomics from functions.
Introduce a new `TypeFlags::CONSTRUCTIBLE` flag, corresponding to
WGSL's "constructible types". Set this on the appropriate types.
Check for this flag on function return types.
2022-06-01 14:20:55 -07:00
Jim Blandy 1c21fc02fe Let validation check for more unsupported builtins.
Add `valid::Capabilities` flags for the `ClipDistance` and
`CullDistance` builtins, which are not supported by all back ends.

Have the CLI perform valation with only those capabilities that the
requested back ends support.

Fixes #1961.
2022-06-01 14:20:06 -07:00
Connor Fitzgerald 95d5d165fb [valid] Fix bitflag assignments (#1915) 2022-05-12 13:10:17 +00:00
Jim Blandy 57e1793143 Properly check that user-defined IO uses IO-shareable types.
Only numeric scalars and vectors, and structs whose members are such
values, are permitted as the types of user-defined IO.
2022-05-02 10:28:16 +02:00
Jim Blandy 2571039af0 Factor out code for deciding which pointers can be arguments. 2022-05-01 12:27:40 -07:00
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