Commit Graph
87 Commits
Author SHA1 Message Date
João Capucho 98944bb7a6 Track finished across compound statements 2021-09-20 12:00:22 -04:00
João Capucho 60d0bf850b Add support for multi view extensions 2021-09-19 17:38:27 -04:00
Jim Blandy d4bedafbda Move #[must_use] attr on Capabilities to where it'll take effect.
This was causing warnings in nightly (1.56.0).
2021-09-07 17:30:08 -04:00
João Capucho bbf3e465f3 Add support for inverse hyperbolic trignometric functions
Hlsl and wgsl don't support them directly so a polyfill is used taken
from the msl spec.

`asinh` = `log(x + sqrt(x * x + 1.0))`
`acosh` = `log(x + sqrt(x * x - 1.0))`
`atanh` = `0.5 * log((1.0 + x) / (1.0 – x))`
2021-08-20 16:57:18 -04:00
sigaloid 9050108a95 Fix some clippy suggestions 2021-08-20 16:42:47 -04:00
Dzmitry Malyshau 79d899fe4c Support num_workgroups builtin 2021-08-17 22:22:22 -04:00
Dzmitry Malyshau 27e4ba59e4 Validate that SampleLevel::Exact isn't used for comparisons 2021-08-13 01:45:43 -04:00
Alex Es fd70116668 Proof of concept for "span" feature, with WGSL & GLSL parsing augmented. (#1092)
* Proof of concept for "span" feature, with WGSL parsing augmented.

* Review:

1) add_span was actually a bad idea, make it set_span and add
set_span_if_unknown too.
2) panics on getting/setting span for invalid handles.
3) only set span for constants with a name
4) don't overwrite spans for types.

* Added spans to blocks & more expressions getting spans in frontends.

Definitely the shotgunny type of commit, but what can you do. The design
I went with made spans mandatory to specify, so I had to go and wire
them through wherever I could.

* Moved Block to a separate module, +clippy

* More spans for types in GLSL.

* Remove pointless body method.

* Make Arena interface require spans.

Another shotgun commit, oh boy...

* Fix tests.

My loathsome habit to "quickly fix things along the way" made a lot of
extra work for me here, having to fix my "fixes" for WGSL parser.

* Rustfmt + clippy.

* Fix compile-errors with span feature enabled.

* Nuked set_span* from orbit. Deleting code feels great!

* Code review - move feature flags inside functions.

* Fix build with "deserialize" feature enabled.
2021-08-11 16:04:32 -04:00
Dzmitry Malyshau 67dd604b0c [wgsl-out] atomic load/stores, [glsl-out] revert the prefix 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 1121a815ac Separate enum for atomic binary operations 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau bc4576c0a2 Make atomic operations to be statements 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 88c1c9037d Add atomic exchange function 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 8c371e8063 Atomic expressions, support in backends except HLSL and the validator. 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 8cb09c24c5 Atomics in the IR 2021-08-10 21:48:02 -04:00
Dzmitry Malyshau 6f21004369 Allow mixing on a scalar selector 2021-08-04 12:09:05 -04:00
pyrotechnickandDzmitry Malyshau 2f516c0932 [wgsl] Storage buffer/texture access (#1142)
* Resurrect texture_storage_* tests
* Test parsing of `var<storage,write>`
* Default storage textures to READ
* Restore default features
* Fix glsl/hlsl/msl/spv front and back ends
* Add missing test outputs
* All-around fixes for the storage access

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-28 01:47:18 -04:00
Gordon-F 7bb28201dd Allow to translate from bool to another type in validator 2021-07-24 17:53:24 -04:00
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