Commit Graph

70 Commits

Author SHA1 Message Date
Dzmitry Malyshau
20c4d2c3d1 Add MSAA depth texture type 2021-07-22 10:39:24 -04:00
initial-algebra
602368d9f0 Support builtin(primitive_index) (#1097)
* Hack in support for PrimitiveID on Vulkan

* Rename to PrimitiveIndex and add preliminary support for GLSL, HLSL and MSL

* Implement as an extra WGSL built-in

* Update extra.wgsl outputs

* Run rustfmt; fix WGSL writer

* Add rustfmt changes I forgot

* Update extra.wgsl test output for WGSL fix

* Bump macOS version to 10.15 in validate-msl to support primitive_index
2021-07-16 22:18:20 -04:00
Jim Blandy
bdf792387a Document ImageLoad, ImageStore, and a few other bits. 2021-07-13 15:32:35 -04:00
Joshua Groves
9192f7b882 wgsl-in: add more error tests 2021-07-05 02:24:18 -04:00
Jasper St. Pierre
78e1304d42 [glsl-in] Convert bool -> scalar cast to Select 2021-07-02 01:34:34 -04:00
João Capucho
8880faf360 Address more comments 2021-07-01 11:19:28 -04:00
João Capucho
4da665d3ba Address comments 2021-07-01 11:19:28 -04:00
João Capucho
7df4a52af9 [valid] Handle texture/sampler function argument 2021-07-01 11:19:28 -04:00
Dzmitry Malyshau
064263272c Refactor control flow validation, allow break in switches 2021-06-22 00:24:50 -04:00
Jim Blandy
548cde4701 Clear Validator::valid_expression_list before validating each function.
If validation fails, `Validator` may be left with entries in
`valid_expression_list` and `valid_expression_set`. The validator does clear the
set before examining a function's body, but not the list, which means a
long-lived `Validator` could accumulate an unbounded amount of garbage in the
list.

(Minor cleanup: use structural update syntax where appropriate.)
2021-06-21 14:53:20 -04:00
Jim Blandy
696ca340e0 Improve docs for TypeInner, valid::TypeFlags, and some internal types. 2021-06-20 12:18:50 -04:00
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