Commit Graph

463 Commits

Author SHA1 Message Date
Jamie Nicol
00a6032eb7 [naga spv-out] Handle nested arrays when adding matrix decorations
Previously we only checked whether the outermost array's subtype was a
Matrix when determining whether to add ColMajor and MatrixStride
decorations, meaning arrays of arrays of matrices would not be
decorated.
2024-11-20 06:38:39 -08:00
Jim Blandy
0b82776947 [naga msl-out] Avoid UB by making all loops bounded.
In MSL output, avoid undefined behavior due to unbounded loops by
adding an unpredictable, never-actually-taken `break` to the bottom of
each loop body, rather than adding an unpredictable,
never-actually-taken branch over each loop.

This will probably have more of a performance impact, because it
affects each iteration of the loop, but unlike branching over the
loop, which leaves infinite loops (and thus undefined behavior) in the
output, this actually ensures that no loop presented to Metal is
unbounded, so that there is no undefined behavior present that the
optimizer could use to make unwelcome inferences.

Fixes #6528.
2024-11-18 14:10:50 -08:00
Erich Gubler
e59f00399e fix(wgsl-in): include user and unknown rules in diagnostic(…) tracking 2024-11-18 17:10:07 -05:00
Erich Gubler
1fc5e4027a refactor: remove ConflictingDiagnosticRuleError::triggering_rule
Did this to decrease size of `ConflictingDiagnosticRuleError`, which
would have gotten even bigger in a subsequent commit.
2024-11-18 17:10:07 -05:00
Erich Gubler
ffc2a1e9a0 diag(wgsl-in): fix plurality agreement for conflicting diagnostic rules 2024-11-18 17:10:07 -05:00
Erich Gubler
f6f0e5dbc2 refactor(naga): unimpl. Copy for FilterableTriggeringRule 2024-11-18 17:10:07 -05:00
Jamie Nicol
6f528e2ebc
[wgsl-in] Reject invalid texture types for textureSampleBias (#6566)
Non-sampled textures are not allowed, and neither are 1 dimensional
textures.
2024-11-18 17:37:52 +01:00
Jamie Nicol
baecb5fbf1
[wgsl-in] Ensure textureSampleLevel's level argument is an integer for depth textures (#6529)
Until now we accepted a float, as is the case for non-depth textures.
This makes us compliant with the spec.

The validator is updated to expect an Sint or Uint when the ImageClass
is ImageClass::Depth. The SPIR-V frontend converts the LOD argument
from float to Sint (assuming that it is representable), likewise The
SPIR-V backend now converts the LOD from either Sint or Uint to
Float. HLSL and MSL backends require no changes as they implicitly do
that conversion. GLSL does not support non-compare LOD samples,
therefore no changes are required.
2024-11-18 12:05:04 +00:00
Jim Blandy
c110bf22d8 docs(diagnostic_filter): add more words to DiagnosticFilterMap
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-11-15 16:11:07 -08:00
Erich Gubler
92ca5a3850 feat(wgsl-in): parse diagnostic attrs. on fns 2024-11-15 07:44:14 -05:00
Erich Gubler
ed29b2b758 fix(wgsl-in): yield conflict errors for full diagnostic(…) rule dupes in attr. pos. 2024-11-15 07:44:14 -05:00
David Peicho
3018912897
naga: Add support for GLSL signed/unsigned samplers (#6513) 2024-11-15 11:49:56 +01:00
Erich Gubler
d0fd6a231c chore: satisfy unused_qualifications (again) 2024-11-14 07:56:22 -05:00
Erich Gubler
435514176e feat(wgsl-in): add unimpl. diag. for compound stmt. @diagnostic(…)s 2024-11-13 08:59:25 -05:00
Erich Gubler
c259f3b5a0 feat(wgsl-in): add @diagnostic(…) checks on global decls.
Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
2024-11-13 08:59:25 -05:00
Erich Gubler
82e7aa3d5b refactor(naga): hoist Attribute's name{,_span} bindings 2024-11-13 08:59:25 -05:00
Erich Gubler
e6f52bf46d move(naga)!: move WGSL-specific diagnostic_filter stuff to naga::front::wgsl 2024-11-13 08:59:25 -05:00
Erich Gubler
66d2ac6f5d refactor(naga)!: diagnostic_filter: s/{from,to}_ident/{from,to}_wgsl_ident 2024-11-13 08:59:25 -05:00
Erich Gubler
efc15ba03b
chore: revert removal of DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE (#6534) 2024-11-13 07:03:16 -05:00
Erich Gubler
e8a8281203 diag(naga): add type info to InvalidBinaryOperandTypes 2024-11-12 09:20:56 -05:00
Erich Gubler
2a2655def8 refactor(naga): use named fields for ExpressionError::InvalidBinaryOperandTypes 2024-11-12 09:20:56 -05:00
Erich Gubler
ea75a8ced4 feat(wgsl-in): filter unif. analysis errors with derivative_uniformity
- Remove `DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE`.
- Add `CHANGELOG` entry.
- Add coverage to `naga`'s `valid::analyzer::uniform_control_flow` test.
2024-11-12 08:49:02 -05:00
Erich Gubler
b81fcb4134 refactor(wgsl-in): track diagnostic directives in func. analysis 2024-11-12 08:49:02 -05:00
Erich Gubler
290ea1553b chore: remove unimpl. diag. filt. err. check 2024-11-12 08:49:02 -05:00
Erich Gubler
7a5d505896 feat(wgsl-in): detect conflicting diag. filters 2024-11-12 08:49:02 -05:00
Erich Gubler
44b8e38fd8 refactor(wgsl-in): specify more closure ret. types in parsing
This resolves ambiguity that will be introduced in the subsequent commit
that adds `impl From<ConflictingDiagnosticRuleError> for naga::Error`.
2024-11-12 08:49:02 -05:00
Erich Gubler
5e68a63151
fix(const_eval): don't panic when a vecN constructor's arg. count is less than N (#6508) 2024-11-12 12:44:02 +00:00
Jamie Nicol
cffc7933fd
[naga] Implement quantizeToF16 (#6519)
Implement WGSL frontend and WGSL, SPIR-V, HLSL, MSL, and GLSL
backends. WGSL and SPIR-V backends natively support the instruction.
MSL and HLSL emulate it by casting to f16 and back to f32. GLSL does
similar but must (mis)use (un)pack2x16 to do so.
2024-11-12 12:05:19 +01:00
Gábor Gyebnár
47d20d913d
Fixes crash when there's a missing texture argument (#6486) 2024-11-07 16:35:36 +01:00
Jasper St. Pierre
9ccea8179d naga: Fix textureNumLevels in the GLSL backend
... and reactivate the GLSL test for it.

Fixes issue #6435.
2024-11-04 08:07:23 -08:00
dependabot[bot]
d039b4d7c3
build(deps): bump the patch-updates group with 10 updates (#6492)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-03 22:38:33 -05:00
Jim Blandy
6b85e65f51 [naga spv-out] Rename write_expression_pointer to write_access_chain.
This function's sole purpose is to generate `OpAccessChain`
instructions, so there's no point in being coy about it.
2024-10-30 21:45:39 -07:00
Erich Gubler
82f9ca6da8 chore(wgsl-in): remove unimplemented directive kinds 2024-10-30 21:40:05 -07:00
Erich Gubler
8c13d8ff56 feat(wgsl-in): parse diagnostic(…) directives (with unimpl. err.) 2024-10-30 15:39:16 -07:00
Erich Gubler
6934f5ae91 test(naga): add missing variants to DirectiveKind::iter 2024-10-30 15:39:16 -07:00
Erich Gubler
08c9d8c397 chore: bump WGPU workspace crates to 23 2024-10-30 07:14:10 -07:00
dependabot[bot]
1616c24561
build(deps): bump the patch-updates group with 24 updates (#6470)
Bumps the patch-updates group with 24 updates:

| Package | From | To |
| --- | --- | --- |
| [anyhow](https://github.com/dtolnay/anyhow) | `1.0.90` | `1.0.91` |
| [serde](https://github.com/serde-rs/serde) | `1.0.210` | `1.0.213` |
| [thiserror](https://github.com/dtolnay/thiserror) | `1.0.64` | `1.0.65` |
| [tokio](https://github.com/tokio-rs/tokio) | `1.40.0` | `1.41.0` |
| [syn](https://github.com/dtolnay/syn) | `2.0.82` | `2.0.85` |
| [anstream](https://github.com/rust-cli/anstyle) | `0.6.15` | `0.6.17` |
| [anstyle](https://github.com/rust-cli/anstyle) | `1.0.8` | `1.0.9` |
| [anstyle-parse](https://github.com/rust-cli/anstyle) | `0.2.5` | `0.2.6` |
| [anstyle-query](https://github.com/rust-cli/anstyle) | `1.1.1` | `1.1.2` |
| [anstyle-wincon](https://github.com/rust-cli/anstyle) | `3.0.4` | `3.0.6` |
| [bytes](https://github.com/tokio-rs/bytes) | `1.7.2` | `1.8.0` |
| [colorchoice](https://github.com/rust-cli/anstyle) | `1.0.2` | `1.0.3` |
| [fdeflate](https://github.com/image-rs/fdeflate) | `0.3.5` | `0.3.6` |
| [minicov](https://github.com/Amanieu/minicov) | `0.3.5` | `0.3.6` |
| [pin-project](https://github.com/taiki-e/pin-project) | `1.1.6` | `1.1.7` |
| [pin-project-internal](https://github.com/taiki-e/pin-project) | `1.1.6` | `1.1.7` |
| [pin-project-lite](https://github.com/taiki-e/pin-project-lite) | `0.2.14` | `0.2.15` |
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | `1.0.88` | `1.0.89` |
| [regex](https://github.com/rust-lang/regex) | `1.11.0` | `1.11.1` |
| [rustix](https://github.com/bytecodealliance/rustix) | `0.38.37` | `0.38.38` |
| [serde_derive](https://github.com/serde-rs/serde) | `1.0.210` | `1.0.213` |
| [thiserror-impl](https://github.com/dtolnay/thiserror) | `1.0.64` | `1.0.65` |
| [wayland-client](https://github.com/smithay/wayland-rs) | `0.31.6` | `0.31.7` |
| [wayland-cursor](https://github.com/smithay/wayland-rs) | `0.31.6` | `0.31.7` |


Updates `anyhow` from 1.0.90 to 1.0.91
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.90...1.0.91)

Updates `serde` from 1.0.210 to 1.0.213
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.210...v1.0.213)

Updates `thiserror` from 1.0.64 to 1.0.65
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.64...1.0.65)

Updates `tokio` from 1.40.0 to 1.41.0
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.40.0...tokio-1.41.0)

Updates `syn` from 2.0.82 to 2.0.85
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.82...2.0.85)

Updates `anstream` from 0.6.15 to 0.6.17
- [Commits](https://github.com/rust-cli/anstyle/compare/anstream-v0.6.15...anstream-v0.6.17)

Updates `anstyle` from 1.0.8 to 1.0.9
- [Commits](https://github.com/rust-cli/anstyle/compare/v1.0.8...v1.0.9)

Updates `anstyle-parse` from 0.2.5 to 0.2.6
- [Commits](https://github.com/rust-cli/anstyle/compare/anstyle-parse-v0.2.5...anstyle-parse-v0.2.6)

Updates `anstyle-query` from 1.1.1 to 1.1.2
- [Commits](https://github.com/rust-cli/anstyle/compare/anstyle-query-v1.1.1...anstyle-query-v1.1.2)

Updates `anstyle-wincon` from 3.0.4 to 3.0.6
- [Commits](https://github.com/rust-cli/anstyle/compare/anstyle-wincon-v3.0.4...anstyle-wincon-v3.0.6)

Updates `bytes` from 1.7.2 to 1.8.0
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/compare/v1.7.2...v1.8.0)

Updates `colorchoice` from 1.0.2 to 1.0.3
- [Commits](https://github.com/rust-cli/anstyle/compare/colorchoice-v1.0.2...colorchoice-v1.0.3)

Updates `fdeflate` from 0.3.5 to 0.3.6
- [Changelog](https://github.com/image-rs/fdeflate/blob/main/CHANGES.md)
- [Commits](https://github.com/image-rs/fdeflate/compare/v0.3.5...v0.3.6)

Updates `minicov` from 0.3.5 to 0.3.6
- [Changelog](https://github.com/Amanieu/minicov/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Amanieu/minicov/compare/v0.3.5...v0.3.6)

Updates `pin-project` from 1.1.6 to 1.1.7
- [Release notes](https://github.com/taiki-e/pin-project/releases)
- [Changelog](https://github.com/taiki-e/pin-project/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/pin-project/compare/v1.1.6...v1.1.7)

Updates `pin-project-internal` from 1.1.6 to 1.1.7
- [Release notes](https://github.com/taiki-e/pin-project/releases)
- [Changelog](https://github.com/taiki-e/pin-project/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/pin-project/compare/v1.1.6...v1.1.7)

Updates `pin-project-lite` from 0.2.14 to 0.2.15
- [Release notes](https://github.com/taiki-e/pin-project-lite/releases)
- [Changelog](https://github.com/taiki-e/pin-project-lite/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/pin-project-lite/compare/v0.2.14...v0.2.15)

Updates `proc-macro2` from 1.0.88 to 1.0.89
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.88...1.0.89)

Updates `regex` from 1.11.0 to 1.11.1
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.11.0...1.11.1)

Updates `rustix` from 0.38.37 to 0.38.38
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Changelog](https://github.com/bytecodealliance/rustix/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.37...v0.38.38)

Updates `serde_derive` from 1.0.210 to 1.0.213
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.210...v1.0.213)

Updates `thiserror-impl` from 1.0.64 to 1.0.65
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.64...1.0.65)

Updates `wayland-client` from 0.31.6 to 0.31.7
- [Release notes](https://github.com/smithay/wayland-rs/releases)
- [Changelog](https://github.com/Smithay/wayland-rs/blob/master/historical_changelog.md)
- [Commits](https://github.com/smithay/wayland-rs/commits)

Updates `wayland-cursor` from 0.31.6 to 0.31.7
- [Release notes](https://github.com/smithay/wayland-rs/releases)
- [Changelog](https://github.com/Smithay/wayland-rs/blob/master/historical_changelog.md)
- [Commits](https://github.com/smithay/wayland-rs/commits)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: anstream
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: anstyle
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: anstyle-parse
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: anstyle-query
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: anstyle-wincon
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: bytes
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: colorchoice
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: fdeflate
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: minicov
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: pin-project
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: pin-project-internal
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: pin-project-lite
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: proc-macro2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: regex
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: rustix
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: serde_derive
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: thiserror-impl
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: wayland-client
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: wayland-cursor
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-29 08:25:41 +01:00
atlv
64a61ee5c6
refactor texture format to scalar conversion (#6451)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2024-10-23 20:06:40 +00:00
Erich Gubler
a8c9356023 docs(naga): docs. link for language_extension mod. 2024-10-23 11:20:17 -04:00
Erich Gubler
77a757ba9e diag(naga): add def. article and noun qual. to DirectiveNotYetImplemented 2024-10-23 11:20:17 -04:00
Erich Gubler
fc0a488246 docs(naga): use hyphenated "enable-extension" noun like spec. 2024-10-23 11:20:17 -04:00
Erich Gubler
64884d1eba diag(naga): add def. article to EnableExtensionNotYetImplemented 2024-10-23 11:20:17 -04:00
Erich Gubler
18f33b0474 feat: implement requires directives 2024-10-23 11:01:46 -04:00
Erich Gubler
bdd923d3a7 refactor: narrow {,Unimplemented}DirectiveKind to pub(crate) 2024-10-23 10:59:29 -04:00
teoxoy
207747cab5 [hlsl-out] add support for restricting indexing to avoid OOB accesses 2024-10-23 16:51:44 +02:00
teoxoy
3199a3a6b0 refactor access_needs_check to take a reference to the expression arena 2024-10-23 16:51:44 +02:00
Erich Gubler
d539466997 feat(wgsl-in): use more general enable-not-set diag. w/ unimpl. hint 2024-10-22 16:31:07 -04:00
Erich Gubler
bf4cd9cd31 feat(wgsl-in): create skeleton for enable directives
Co-Authored-By: FL33TW00D <chris@fleetwood.dev>
2024-10-22 16:31:07 -04:00
Erich Gubler
54861b712c refactor: add Parser::directive_ident_list helper 2024-10-22 16:31:07 -04:00
Erich Gubler
6f43ee9f17 fix(naga): use Diagnostic from inner in valid. err. presentation
For some reason, the implementation of `Display` for
`ShaderError<WithSpan<ValidationError>>>` is building its own
`Diagnostic` with _only_ the labels populated: no messages or notes.
I don't know why this is, but it seems to have a strict subset of the
information already present in the private implementation of
`WithSpan::diagnostic`.

Fix this by exposing `WithSpan::diagnostic` as `pub(crate)`, and
re-using its output in `impl Display for
ShaderError<WithSpan<ValidationError>>>`.
2024-10-22 14:42:27 -04:00