Commit Graph

47 Commits

Author SHA1 Message Date
Jim Blandy
99fbb34bd6 Require dynamically sized arrays to appear in 'storage' memory.
WGSL requires that runtime-sized arrays appear only as the last member of a
structure in in the `storage` storage class. It seems to me that Naga should
enforce this restriction on its own IR as well.
2021-05-25 00:02:08 -04:00
Dzmitry Malyshau
652b65cfa9 Validate built-ins to not repeat 2021-05-21 23:22:05 -04:00
Jim Blandy
50de6ae9ac Improve error messages for missing I/O bindings.
The `apply_common_default_interpolation` helper function would panic if bindings
were missing, but missing bindings should be something that front ends can count
on validation to detect, so the helper should just return silently.

The validator returned `InvalidType` errors for missing bindings, apparently
because variables without bindings must be structs that do have bindings. But
this is unhelpful when you've just forgotten to label an argument. So this patch
adds a new, more specific, `VaryingError` variant.
2021-05-21 23:04:27 -04:00
Dzmitry Malyshau
b191c982ec Remove alignment from struct IR 2021-05-17 09:32:52 -04:00
Dzmitry Malyshau
350ceb383d WGSL support for f64, snapshot test for it 2021-05-08 21:20:23 -04:00
Dzmitry Malyshau
59d1dcab5b Support width changes in As expression 2021-05-08 21:20:23 -04:00
Gordon-F
73b20ffa70 Add CullDistance BuiltIn 2021-05-08 09:51:14 -04:00
Dzmitry Malyshau
01f4922806 Validation parameter for the converter 2021-05-07 00:42:49 -04:00
Dzmitry Malyshau
63afb9a215 Add Capabilities bitset for validation 2021-05-05 21:39:41 -04:00
Dzmitry Malyshau
9fe75ed7f1 Barriers 2021-05-04 22:16:24 -04:00
Lachlan Sneff
960551f952 Add support for arrayLength to the wgsl frontend (#805)
* Add support for arrayLength to the wgsl frontend

* Fix clippy warning
2021-04-30 00:20:09 -04:00
Lachlan Sneff
37a6ff7bfe Add several additional ops to the spirv frontend. (#803)
* Add support for int8, int16, and int64 as well as null constant structs

* Add support for OpArrayLength to the spirv frontend

* Add hacky OpCopyMemory support to spirv frontend

* Add OpInBoundsAccessChain to spirv frontend

* Add OpLogical(Not)Equal to spirv frontend

* Fix several of the issues raised in the pr

* Fix the Op::ArrayLength match

* Validate accessing structs through pointers

* Remove extraneous type check
2021-04-29 19:45:49 -04:00
Dzmitry Malyshau
120fc22e9f Support unary not in WGSL 2021-04-27 01:24:21 -04:00
Ashley Ruglys
33003d8ea2 Add MathFunction::Refract 2021-04-26 14:14:30 -04:00
Dzmitry Malyshau
4a5ff9a053 Validate that used expressions are emitted 2021-04-26 09:59:54 -04:00
Dzmitry Malyshau
ecffe37456 Enforce sampled types to be Float 2021-04-25 02:24:17 -04:00
Dzmitry Malyshau
34b830da17 [spv-in] work around sign differences in OpIAdd and OpISubtract 2021-04-24 01:00:33 -04:00
Dzmitry Malyshau
0725417193 Allow indexing value pointers (#758) 2021-04-23 01:19:48 -04:00
Dzmitry Malyshau
5d1746b0b4 Swizzle expression (#734) 2021-04-20 22:03:54 -04:00
Jim Blandy
4f442ff8cc Require binding interpolation to be resolved by the front end.
When validating IR, verify that all `Binding`s for vertex shader outputs and
fragment shader inputs, whether directly in the argument or result, or applied
to a struct member, has specified an interpolation and sampling, not `None`.
This ensures that front ends explicitly state their policies, rather than
coasting through on back ends' default behavior.

In practice, all our front ends have very similar defaults, so provide a utility
function on `Module` to apply these rules. Use this utility function in the
SPIR-V and WGSL front ends; GLSL seems to already fill in interpolation as
required.
2021-04-19 09:42:00 -04:00
Jim Blandy
0910af2718 [wgsl-in] Implement WGSL interpolate syntax from gpuweb PR #1605.
Fixes: #670
2021-04-19 09:42:00 -04:00
Jim Blandy
99a9e1e78e Change Binding::Location to a struct-style enum variant.
This commit makes no other changes. This is in preparation for adding a third
field, at which point tuple variants start to get obscure.
2021-04-19 09:42:00 -04:00
Dzmitry Malyshau
62c2cf7332 Validate composite constants (#729) 2021-04-18 23:19:09 -04:00
Dzmitry Malyshau
daf4c82376 Allow stepping on floats in the validator (#724) 2021-04-16 16:16:15 -04:00
Jim Blandy
576723960e Permit interpolation qualifiers on both vertex outputs and fragment inputs. 2021-04-15 17:19:20 -04:00
Dzmitry Malyshau
d3b39d9e58 Splat expression in the IR 2021-04-14 19:26:20 -04:00
Simas Toleikis
98252cf5d2 Fix validation for textureDimensions(t) call. 2021-04-10 18:19:42 -04:00
Dzmitry Malyshau
604e10e19b Rewrite IR to have member offsets, full structure span and alignment 2021-04-08 23:15:03 -04:00
Dzmitry Malyshau
7326ba6ddb New struct layout IR 2021-04-08 23:15:03 -04:00
Dzmitry Malyshau
4389a86787 Fix layout roundup 2021-04-03 00:41:32 -04:00
Dzmitry Malyshau
ca6876b7a0 Validate math functions 2021-03-29 11:06:41 -04:00
Dzmitry Malyshau
ba055bfbad Fix validation of constant offset expression 2021-03-27 00:29:48 -04:00
Dzmitry Malyshau
7d042337e2 Align the block decoration with SPIR-V, require storage buffers 2021-03-25 12:34:25 -04:00
Dzmitry Malyshau
e87f57d82c Fix expression validation check 2021-03-25 09:32:55 -04:00
Dzmitry Malyshau
06d777b609 Make layout validation optional, disable the struct size check 2021-03-24 21:03:00 -04:00
Dzmitry Malyshau
a0b5717fed Validate image stores 2021-03-24 12:32:32 -04:00
Dzmitry Malyshau
69a0fbd00e Validate image sampling and value casting 2021-03-24 12:32:32 -04:00
Dzmitry Malyshau
8c73c0c5df Validate derivatives and image loads 2021-03-24 12:32:32 -04:00
Dzmitry Malyshau
7a246f6a14 Validate image queries and valid shader stages for derivatives 2021-03-24 12:32:32 -04:00
Dzmitry Malyshau
8712020115 Move Layouter into ModuleInfo 2021-03-23 10:11:50 -04:00
Dzmitry Malyshau
6086f13bf0 Move the growable typifier into frontend helpers 2021-03-22 15:17:00 -04:00
Dzmitry Malyshau
970b77abaf Make type a part of ExpressionInfo 2021-03-22 15:17:00 -04:00
Dzmitry Malyshau
1d3f2bbdb1 Merge FunctionAnalysisError into FunctionError 2021-03-22 15:17:00 -04:00
Dzmitry Malyshau
1b3e7294fd Move type validation into a sub-module 2021-03-21 22:27:32 -04:00
Dzmitry Malyshau
1ddea0fdbb Validate layouts 2021-03-21 22:27:32 -04:00
Dzmitry Malyshau
e3ae5904ba Move AnalysisFlags into ValidationFlags, add bits for expressions and blocks 2021-03-20 22:25:49 -04:00
Dzmitry Malyshau
c992e638fe Move all the validation into a separate meta-module 2021-03-20 22:25:49 -04:00