Commit Graph
59 Commits
Author SHA1 Message Date
Jim Blandy c16f2097ad [spv-out]: Ensure array subscripts are in bounds. 2021-06-18 20:44:07 -04:00
Jim Blandy 1d0b3f3a75 Functions can take pointers to unsized structs, but no other unsized types. 2021-06-18 20:44:07 -04:00
Dzmitry Malyshau e3827f8e08 Improve the MemberOutOfBounds error 2021-06-18 00:10:39 -04:00
Frizi 3d5e6d51a0 [glsl-in] make sure swizzles never operate on a pointer value 2021-06-17 15:21:47 -04:00
Frizi bff8b18a01 [glsl-in] lower swizzle store to per-component stores 2021-06-17 15:21:47 -04:00
Jim Blandy b79d4c5d85 Validator::validate: Remove bogus comment.
This comment claims that the following work is being done after global
validation, but it actually appears before global validation.
2021-06-17 11:05:27 -04:00
Igor Shaposhnik 54af830855 Fix nightly clippy suggestions 2021-06-09 10:17:20 -04:00
Jim Blandy a2a35f2eb3 Permit dynamic indexing of arrays and matrices only behind a pointer. (#949)
This makes Naga IR validation impose the restrictions added to WGSL in
gpuweb/gpuweb#1801.

Remove code in the SPIR-V writer to spill arrays to temporary variables in order
to index them dynamically. If such IR is encountered, treat it as a failure of
validation.
2021-06-04 12:57:20 -04:00
Dzmitry Malyshau 61bfb29963 Don't consider discard and return inside uniform control flow 2021-05-31 00:49:25 -04:00
Fredrik Norén 58e5b2565d Validate matrix component-wise ops correctly 2021-05-30 11:03:54 -04:00
Jim Blandy 48363fcef1 Don't accept unsized types as function arguments. 2021-05-26 12:27:29 -04:00
Jim Blandy 398d3545b3 Include the type arena in ResolveContext, since it's always needed. 2021-05-26 10:35:59 -04:00
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