Commit Graph

1940 Commits

Author SHA1 Message Date
teoxoy
df567a94eb add Capabilities::MULTIVIEW 2023-02-16 18:16:49 -05:00
Josh Groves
568d7c4c13 Require LF for snapshots (#2253) 2023-02-16 01:54:49 +01:00
Evan Mark Hopkins
1ad47f732d Fix texture built-ins where u32 was expected (#2245)
- 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.
2023-02-13 14:13:58 +01:00
Teodor Tanasoaia
40b8f66146 Fix setup-dxc not found and make sure workflows run if their file was changed (#2247)
* fix setup-dxc not found

* run validation-windows if its workflow file was changed

* run validation-macos if its workflow file was changed

* run validation-linux if its workflow file was changed

* run lazy if its workflow file was changed
2023-02-10 13:44:57 +01:00
João Capucho
f038537e61 glsl-in: Add tests for output parameters casts 2023-02-08 11:39:09 +00:00
João Capucho
0a2e93c098 glsl-in: Perform output parameters implicit casts
Glsl defines under `Function Definitions` (Paragraph 6.1 in glsl 4.60),
the following:

> When function calls are resolved, an exact type match for all
> the arguments is sought.
> (...)
> If no exact match is found, then the implicit conversions in
> section “Implicit Conversions” will be applied to find a match.
> (...)
> Mismatched types on output parameters (out or inout) must have a
> conversion from the formal parameter type to the calling argument type.

The glsl frontend wasn't performing this implicit cast for output parameters.

This commit fixes that by using a proxy write, this
creates a spill variable with the correct type and in the call
prologue a conversion is made back to the original type and the
value is stored in the original variable.
2023-02-08 11:39:09 +00:00
Teodor Tanasoaia
64f8691e52 Improve CI (#2241)
* update to actions/checkout@v3

* update to actions/upload-artifact@v3

* remove minor version

* remove unmaintained actions-rs actions

* update to codecov/codecov-action@v3

* use ubuntu-latest

* use extra cargo/rust env vars

* use cargo-nextest

* check naga-fuzz

* only check on MSRV and minimal-versions

* add whitespace between steps

* rename to CI

* use cargo-llvm-cov to generate code coverage
2023-02-06 17:47:18 +01:00
manunio
2d0aab875a fuzz: fix build failure (#2240) 2023-02-03 15:11:48 +01:00
João Capucho
fc81a20f53 spv-in: Don't apply interpolation to fragment shaders outputs (#2239)
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.
2023-02-03 11:48:23 +01:00
Evan Mark Hopkins
4b796b157c [glsl-out] Version check countLeadingZeros (#2238) 2023-02-02 22:11:09 +01:00
Evan Mark Hopkins
fb2d438dbd [msl-out] Update firstLeadingBit for signed integers (#2235)
The prior code only supported unsigned integers.

Also fixes #2236.

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2023-02-02 09:47:17 -08:00
Artavazd Balaian
fe851fb008 [glsl] Inject default gl_PointSize = 1.0 in vertex shaders if FORCE_POINT_SIZE option was set (#2223)
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>
2023-02-02 13:08:18 +01:00
SparkyPotato
a5c2cf94b8 update tests 2023-02-01 12:28:31 +01:00
SparkyPotato
dcfd5c6f4a improve invalid assignment diagnostic 2023-02-01 12:28:31 +01:00
SparkyPotato
231af68386 expect semicolons wherever required 2023-02-01 12:28:31 +01:00
SparkyPotato
e6bd2e9071 fix panic on invalid zero array size 2023-02-01 12:28:31 +01:00
SparkyPotato
bb20ae8e79 check for leading { while parsing a block 2023-02-01 12:28:31 +01:00
Dzmitry Malyshau
16be1a9237 spv-out: support version 1.4 (#2230)
* spv-out: support version 1.4

* Extract SPV version numner from the comment
2023-02-01 12:24:05 +01:00
Evan Mark Hopkins
6be394dac3 Add countLeadingZeros (#2226)
* Add countLeadingZeros

* [glsl-out] Bake countLeadingZeros

* [hlsl-out] Bake countLeadingZeros

* [hlsl-out] Update Baked expressions

* Remove unnecessary bake for sints

* [glsl-out] CountLeadingZeros without findMSB

* Don't check negatives when uint

* Perform the type conv after mix

* use log2

* fix clippy lints

---------

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2023-01-31 21:31:05 +01:00
teoxoy
a2b39e45bf [hlsl-out] clear named_expressions inserted by duplicated blocks
changed the type of `named_expressions` from `HashMap` to `IndexMap` so that insertion order is preserved
2023-01-31 10:43:02 -08:00
João Capucho
0074c68ec4 valid: Check dependencies between functions calls
This commit enforces the forward dependency rules on the IR across
functions and their calls, this fixes a crash in a later stage of the
validator.
2023-01-31 07:35:31 -08:00
João Capucho
bebaac93b6 valid: Fix handle dependency validation
The handle dependency validation code was using the handle's index
directly while trying to erase the handle type. This would cause the
validator to crash while processing the first handle of the arena since
it would be trying to construct a `NonZeroU32` with a zero.

This commit fixes the issue by adding 1 to the index which not only
fixes this panic but also makes so that the created Handle is equal to
the passed handle (minus the type that was erased)

It also fixes the error message not including the subject's kind
2023-01-31 07:35:31 -08:00
Shaye Garg
67ea8f0c06 [wgsl-in] Split into multiple files (#2207)
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`.
2023-01-31 07:17:58 -08:00
João Capucho
ae049edc49 glsl-in: Add not vector relational builtin 2023-01-31 13:29:37 +00:00
João Capucho
191d71c107 glsl-in: Add test for relational vector builtins 2023-01-31 13:29:37 +00:00
João Capucho
372a715434 glsl-in: Add double overloads for relational vector builtins
All relational vector builtins that operate on floats can also operate
on doubles but these overloads were not present. This commit fixes that.
2023-01-31 13:29:37 +00:00
João Capucho
08366c8fd0 glsl-in: Add bool overloads for relational vector builtins
The `equal` and `notEqual` builtins also operate on boolean vectors but
the overloads accepting them were not added. This commit fixes that.
2023-01-31 13:29:37 +00:00
Jim Blandy
ca99d8bcbc Inline identifiers into format strings.
[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
2023-01-31 11:27:51 +01:00
Jim Blandy
26dca556a9 Allow clippy::needless_borrowed_reference.
In Clippy 1.67, the `needless_borrowed_reference` lint [was enhanced]
to look into struct and tuple patterns, so that a line like this:

    for &(ref module, ref info) in inputs.iter()

where `inputs.iter()` is yielding `&(Module, ModuleInfo)` pairs,
elicits a warning. Clippy suggests, instead:

    for (module, info) in inputs.iter()

but this is at odds with Naga's preference that `match` patterns
should have the same type as the expression being matched, for which
we have enabled the `pattern_type_mismatch` lint since
9e5cc4c9 (2021-3-12).

[was enhanced]: https://github.com/rust-lang/rust-clippy/pull/9855
2023-01-31 11:27:51 +01:00
Connor Fitzgerald
f0edae8ce9 Update to 0.11 (#2222) naga-cli-v0.11.0 naga-v0.11.0 2023-01-25 21:27:09 +00:00
Teodor Tanasoaia
13944c0ae5 Update CHANGELOG.md 2023-01-25 15:11:16 -05:00
Teodor Tanasoaia
fe9db5dd8d install cargo-tarpaulin via cargo-binstall (#2220) 2023-01-25 18:21:24 +00:00
teoxoy
c7d02151f0 add support for zero-initializing workgroup memory 2023-01-25 18:07:48 +01: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
teoxoy
a42857d291 [hlsl-out] simplify write_default_init 2023-01-25 18:07:48 +01:00
teoxoy
e5121ca012 factor out write_barrier functions 2023-01-25 18:07:48 +01:00
Patryk Wychowaniec
954cbaaff3 [spv-in] Support binding arrays (#2199) 2023-01-25 17:49:52 +01:00
Teodor Tanasoaia
f70d8ec51f update test snapshots (#2219) 2023-01-23 11:09:15 +00:00
robtfm
4142971cb1 glsl: include unused items (#2205)
* include_unused_items

* clippy

* tests

* rename original const if possible
2023-01-23 11:58:05 +01:00
Evan Mark Hopkins
a638da9edb [wgsl] Removes isFinite and isNormal 2023-01-23 11:50:50 +01:00
Evan Mark Hopkins
74e5b4a07e [wgsl] Update inverse hyperbolic built-ins 2023-01-23 11:50:50 +01:00
Evan Mark Hopkins
9f182ade30 [wgsl] Add refract built-in 2023-01-23 11:50:50 +01:00
Jonathan Behrens
1be8024bda Support 16-bit unorm/snorm formats (#2210)
* Support 16-bit unorm/snorm formats

* Add Capabilities::STORAGE_TEXTURE_16BIT_NORM_FORMATS

* Add 16-bit normalized formats to spv frontend
2023-01-18 19:03:24 +01:00
Jonathan Behrens
1cffd236a7 Remove overly restrictive array stride check (#2215) 2023-01-18 16:28:38 +01:00
Jim Blandy
cdcfad277a Let the uniformity analysis trust the handle validation pass.
Undo some changes from #1668, now that #2090 has been merged.
2023-01-14 19:25:31 -08:00
Jim Blandy
f0a8ff6b3a Fix docs for Emit statements. (#2208) 2023-01-15 00:00:15 +01:00
SparkyPotato
6035b07b78 [wgsl-in] Implement module-level scoping.
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>
2023-01-12 09:37:08 -08:00
Timo de Kort
7effd12596 Update setup-dxc to v1.1.0 (#2204) 2023-01-11 18:23:42 +01:00
Jim Blandy
86a88de396 Revert "Error if the uniformity requirements for a barrier aren't met" (#2203)
This reverts commit e6e94d65ab.
2023-01-11 16:35:03 +01:00