* [spirv-out] Fix adding illegal decorators on fragment outputs.
Furthermore, fix allowing to add `Centroid` and `Sample` decorator to vertex inputs.
Fixes#2270
* Add test for fragment outputs
* Fix fragment-output.wgsl test using more than 8 outputs in a single shader
Breaks HLSL & MSL validation
* formatting
The existing `per_stage_map` field of MSL backend options specifies
resource binding maps that apply to all entry points of each stage type.
It is useful to have the ability to provide a separate binding index map
for each entry point, especially when the same shader module defines
multiple entry points of the same stage kind.
This patch replaces `per_stage_map` with a new `per_entry_point_map`
option where resources are keyed by the entry-point function name.
Use the local (not global) invocation id to decide which invocation should do the initialization, so that every workgroup gets initialized, not just the first.
arrays can be put behind pointers in inout and out parameters in GLSL and HLSL,
whose dimensions must be specified to let array access
compile. so, we specify their dimensions.
fixes#2248
- The Typifier was updated to expect `uint`
- Both `glsl` and `spv` frontends where updated to cast the result to `sint`.
- Both `glsl` and `spv` backends where updated to cast the result to `uint`.
- Remove cast in `msl` backend.
SPIR-V doesn't allow the `Flat`, `NoPerspective`, `Sample` or
`Centroid` decorations on fragment shaders outputs, but the spirv
frontend was applying default interpolation to all outputs
unconditionally.
This wasn't an issue for most shaders since they output floats and the
default values for them don't interfere with SPIR-V semantics, but if
the shader returned a uint or int the interpolation would be set to
`Flat` which as stated above is disallowed.
This commit fixes the issue by only running the default interpolation
code when constructing the entry point and if the stage/IO allow it.
According to https://registry.khronos.org/OpenGL/specs/es/3.2/GLSL_ES_Specification_3.20.html#built-in-language-variables
> The variable gl_PointSize is intended for a shader to write the size of the point to be rasterized. It is measured in pixels. If gl_PointSize is not written to, its value is undefined in subsequent pipe stages.
- Write warn message if `ClipDistance` and `CullDistance` are used on unsupported version
---------
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Make changes suggested in #2075, but put off to a separate PR because they would interfere with reviewing the change:
- Split the new WGSL front end into modules in a logical way.
- Rename `Parser` to `Frontend`.
[Since Rust 1.58], Rust format strings have been able to "capture
arguments simply by writing {ident} in the string." Clippy 1.67 made
the corresponding warning, `uninlined_format_args`, warn-by-default.
Inlined arguments seem more readable, so Naga should adopt them.
[Since Rust 1.58]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1580-2022-01-13
Fixes#1745: Support out-of-order module scope declarations in WGSL
Fixes#1044: Forbid local variable shadowing in WGSL
Fixes#2076: [wgsl-in] no error for duplicated type definition
Fixes#2071: Global item does not support 'const'
Fixes#2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes#1775: Referencing a function without a return type yields an unknown identifier error.
Fixes#2089: Error span reported on the declaration of a variable instead of its use
Fixes#1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"
Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
* Add support for WGSL's `atomicCompareExchangeWeak` with the `__atomic_compare_exchange_result` struct, and add SPIR-V codegen for it.
Partially addresses https://github.com/gpuweb/gpuweb/pull/2113, #1755.
* Add tests for `atomicCompareExchangeWeak`, and support both u32 and i32 atomics with it.
* More thorough typechecking of the struct returned by `atomicCompareExchangeWeak`.