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.
* Update WGSL grammar for pointer access.
Comes with a small test, which revealed a number of issues in the backends.
* Validate pointer arguments to functions to only have function/private/workgroup classes.
Comes with a small test. Also, "pointer-access.spv" test is temporarily disabled.
Treat `TypeInner::ValuePointer` and `TypeInner::Pointer` as equivalent by
converting them to a canonical form before comparison.
Support `ValuePointer` in WGSL type output.
Fixes#1318.
Fixes#1356.
Output for the test case in that issue is now:
error: the value indexed by a `[]` subscripting expression must not be a pointer
┌─ wgsl:5:14
│
5 │ let a = *pv[3]; // Problematic line
│ ^^ expression is a pointer
Could not parse WGSL
* Implement lexing for all WGSL number literal types
* Move number literal test cases
* Adjust tests to match WGSL spec on number literals
Suffixes are not type names and currently only a plain `u` is supported
for uints. More specifically, `i` and `f` suffixes or suffixes with
widths in bits like `u32` are not supported at the moment.
* Add more tests for invalid number literal suffixes
* Replace code too new for Rust 1.43
* Implement parsing for hexadecimal integers
* Switch to enum number types, and Bytes for width
* Check for negative and leading zeros in int literals
* Implement parsing of hex floats with hexf-parse
* Update error message tests
* Update snapshot test output files
* Clean up lexer state machine code
* Clean up unexpected token error code
* Move number literal parsing to own submodule
* 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>
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.
Better errors for Unexpected, BadInteger, BadFloat, BadTexture, BadTypeCast, UnknownScalarType, UnknownStorageClass, UnknownAttribute, UnknownBuiltin, UnknownShaderStage, UnknownStorageFormat and UnknownConservativeDepth, ZeroStride, ZeroSizeOrAlign and UnknownType.
Also adds lexer::capture_span.
Also fixes some validation for texture sample types and and issue that cauld cause e.g. the type `f33` to be parsed as `f32`.
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.
This lets us reduce noise by removing a bunch of `#[cfg]` attributes. In the
future, if we have tests for other front ends, we can create an `errors`
subdirectory, but for now, we only have the WGSL tests, so we should keep things
flat.