Commit Graph
46 Commits
Author SHA1 Message Date
Dzmitry Malyshau a0d53597fb Support array bindings of buffers (#2282)
* Support buffer resource arrays in IR, wgsl-in, and spv-out

* spv-out: refactor non-uniform indexing semantics to support buffers

* Update the doc comment on BindingArray type

* Improve TypeInfo restrictions on binding arrays

* Strip DATA out of binding arrays

* Include suggested documentation, more binding array tests, enforce structs
2023-05-29 20:53:54 -07:00
Dzmitry Malyshau 13ee4369cc clippy fixes 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau b856625821 Ray query expressions and special types 2023-03-22 17:23:07 -07:00
Dzmitry Malyshau 432b4990a7 Add ray query types to the IR 2023-03-22 17:23:07 -07:00
teoxoy 3ace8b81cb fix array being flagged as constructible when its base isn't 2023-01-25 18:07:48 +01:00
teoxoy 85e3b0844f add type_flags to ModuleInfo 2023-01-25 18:07:48 +01:00
Jonathan Behrens 1cffd236a7 Remove overly restrictive array stride check (#2215) 2023-01-18 16:28:38 +01: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
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 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
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 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
Jim Blandy f11d27af6f Reject empty struct types. (#1826) 2022-04-14 09:36:53 -07:00
Teodor Tanasoaia 2db49b6998 validate uniform address space layout constraints (#1812) 2022-04-09 22:35:28 -07: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 ab02ec7904 layouter: rich and careful errors 2022-01-14 12:44:27 -05:00
Dzmitry Malyshau 8ffd6ba929 Remove top_level property of structs 2021-12-15 09:33:33 -05:00
Jim Blandy cc930180d9 Tighten checks on pointers to unsized values, and pointer arguments.
Pointers should not be `DATA`: they can never be stored in anything. (Function
arguments are not storage; they're like `let` bindings.)

Un-`SIZED` values may only live in the `Storage` storage class, so creating
pointers to them in other storage classes is meaningless.

The `ARGUMENT` flag should be set only on pointers in those storage classes that
are permitted to be passed to functions.

See comments in code for details.

Fixes #1513.
2021-11-18 17:39:56 -05:00
Jim Blandy 90daa9edfe Forbid specializable constants as array lengths.
Only the SPIR-V front end can produce such array types, and it seems that our
back ends don't support this case well.
2021-11-16 09:12:42 -05:00
Jim Blandy ea50486b2d Forbid unsized structs as final members of structs. (#1443)
WGSL says:

> - The last member of the structure type defining the store type for a variable
>   ... may be a runtime-sized array.
>
> - A runtime-sized array must not be used as the store type or contained within
>   a store type in any other cases.

Thus, a struct whose final member is a struct whose final member is a
runtime-sized array is verboten.
2021-10-01 09:40:18 -04:00
Jim Blandy 944a693ae5 Use UniqueArena for types.
Ensure that each distinct type occurs only once in `Module::types`, so that we
can use `Eq` on `Type` or `TypeInner` for type equivalence, without being
confused by differing `Handle<Type>` values that point to identical types.

This removes a number of duplicate types from the ir snapshots.

Fixes #1385.
2021-09-27 15:17:41 -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 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
Joshua Groves 9192f7b882 wgsl-in: add more error tests 2021-07-05 02:24:18 -04:00
João Capucho 7df4a52af9 [valid] Handle texture/sampler function argument 2021-07-01 11:19:28 -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
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 b191c982ec Remove alignment from struct IR 2021-05-17 09:32:52 -04:00
Dzmitry Malyshau 63afb9a215 Add Capabilities bitset for validation 2021-05-05 21:39:41 -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 7d042337e2 Align the block decoration with SPIR-V, require storage buffers 2021-03-25 12:34:25 -04:00
Dzmitry Malyshau 06d777b609 Make layout validation optional, disable the struct size check 2021-03-24 21:03:00 -04:00
Dzmitry Malyshau 970b77abaf Make type a part of ExpressionInfo 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