Commit Graph

8959 Commits

Author SHA1 Message Date
SupaMaggie70Incorporated
20bad46d40 Add multiview mesh shaders to wgpu-hal (#7278) 2025-03-06 12:25:55 -05:00
Jamie Nicol
7df6e477cf [naga wgsl-in] Do not eagerly concretize local const declarations of abstract types
Instead allow the const to be converted each time it is const
evaluated as part of another expression. This allows an abstract const
to be used as a different type depending on the context.

As a result, abstract types may now find their way in to the IR, which
we don't want. This occurs because the compact pass treats named
expressions as used, mostly so that our snapshot tests are more
useful, and therefore does not remove them. To prevent this, we avoid
adding abstract-typed local consts to the named expressions list. This
will have no functional effect on any shaders produced by the
backends, but some unused local const declarations will no longer be
present.
2025-03-05 20:39:48 -08:00
SupaMaggie70Incorporated
cc1e26a799 Fixed DRM(hopefully) (#7277) 2025-03-06 03:36:21 +00:00
Andreas Reich
f884a4148a docs(CHANGELOG): move Features split entry to Major Features
This entry is backwards-compatible, so it can be "promoted" from
`Changes` to "just" a highlight. 🙂
2025-03-05 22:31:02 -05:00
Andreas Reich
3b84750413 docs(CHANGELOG): remove no_std trace path entry
This isn't user-facing, so there doesn't seem to be a real reason to
keep this here.
2025-03-05 22:31:02 -05:00
Erich Gubler
b9328673c6 refactor: impl From<ImplementedEnableExtension> for EnableExtension (#7275)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2025-03-05 22:29:35 -05:00
Erich Gubler
f4fbc4b4bc docs(wgsl): use correct links to standard enable extensions (#7276) 2025-03-05 22:29:13 -05:00
Jamie Nicol
9853f5988d [naga wgsl-in] Concretize LHS of bitshift operations if RHS is not a const-expression (#7270)
Naga currently trips up on shaders containing a bitshift where the
left operand is an AbstractInt and the right operand is *not* a const
expression. This is due to the fact that resulting type of
`AbstractInt << u32` is abstract, and we are unable to evaluate it
away during const evaluation. This results in abstract-typed
expressions in our IR, which causes various issues.

For other binary operations, the type of the left and right operands
would be related, therefore the presence of a concrete right operand
would tell us which type to convert the left operand to. But for shift
operations the right operand's scalar type is always a u32, and does
not influence the left operand's type.

Luckily the WGSL spec[1] tells us how to avoid this problem:

  6.1.3. Overload Resolution

  2. Eliminate any candidate where one of its subexpressions resolves
     to an abstract type after feasible automatic conversions, but
     another of the candidate’s subexpressions is not a
     const-expression.

This, for example, specifies we eliminate the `AbstractInt << u32:
AbstractInt` overload candidate, leaving `i32 << u32: i32` as the
remaining candidate with the lowest conversion rank. The equivalent
also applies for right-bitshifts, and for `vecN<AbstractInt>`
operands.

[1] https://www.w3.org/TR/WGSL/#overload-resolution-section
2025-03-05 20:30:12 -05:00
Jim Blandy
fc83073905 [naga] Move back::wgsl::address_space_str to common::wgsl.
Move `back::wgsl::address_space_str` to `common::wgsl`, so that the
front end can use it too. This commit is code motion and `use`
adjustment only; there should be no change in behavior.
2025-03-05 11:22:05 -08:00
Jim Blandy
567a2c027f [naga] Implement ToWgsl for ImageDimension, and use as needed.
Replace `naga::back::wgsl::writer::image_dimension_str` with a
`ToWgsl` implementation for `ImageDimension` in `common::wgsl`. Use
this where needed in the WGSL backend.
2025-03-05 11:22:05 -08:00
Jim Blandy
8ec2e751b4 [naga] Implement TryToWgsl for Scalar, and use as appropriate.
Replace `naga::back::wgsl::writer::scalar_kind_str` with a `TryToWgsl`
implementation for `Scalar` in `common::wgsl`. Use this where needed
in the WGSL backend.
2025-03-05 11:22:05 -08:00
Jim Blandy
d923efa56b [naga] Move back::vector_size_str to common.
Move `back::vector_size_str` to `common`, so that front ends can use
it too. This commit is code motion and `use` adjustment only, there
should be no change in behavior.
2025-03-05 11:22:05 -08:00
Jim Blandy
34ffbee1b7 [naga wgsl] Define ToWgsl and TryToWgsl traits.
Define new traits in `common::wgsl`, `ToWgsl` and `TryToWgsl`, for
getting the WGSL representation of some Naga IR types as `&'static
str` values:

- `MathFunction`
- `BuiltIn`
- `Interpolation`
- `Sampling`
- `StorageFormat`

Use these functions in the WGSL backend, taking advantage of
`TryToWgsl` to consolidate error reporting.
2025-03-05 11:22:05 -08:00
Jim Blandy
2a364d2bfa [naga wgsl-out] Consolidate unsupported Naga IR feature errors.
Introduce a new variant of `naga::back::wgsl::Error`, `Unsupported`,
and let it subsume `UnsupportedMathFunction` and various uses of
`Custom`.

Introduce a helper function, `Error::unsupported`, for building these
errors.
2025-03-05 11:22:05 -08:00
Kevin Reid
289d0e5c5a Allow the "gles" backend to (theoretically) compile on no_std targets.
This entirely consists of conditionally replacing `Mutex` with `RefCell`,
then making sure that this doesn’t accidentally happen if we are also
exposing `Send + Sync`.
2025-03-05 11:48:42 +01:00
Kevin Reid
67f1554e77 Fix build of wgpu-hal on macOS with features = ["gles"]. (#7266)
Without this change, `cargo build -p wgpu-hal --features=gles` will fail
if `target_os = "macos"`.
2025-03-05 00:12:43 -05:00
Jim Blandy
f59b034153 [naga] Centralize naming of anonymous entry point return types.
When an entry point's return type is anonymous, have
`naga::proc::Namer` assign it a name based on its shader stage.

Remove bespoke logic for this from the WGSL backend.

Fixes #7263.
2025-03-04 17:46:30 -08:00
Marc Pabst
38f3c47a46 Add as_hal for Queue (#7182)
* add as_hal for Queue

* add as_raw for dx12 queue

* return Mutex + add as_raw for Vulkan

* return reference

* restore Cargo.lock

* fix  Cargo.lock

---------

Co-authored-by: Marc Pabst <“marcpabst@users.noreply.github.com”>
2025-03-04 21:24:06 +00:00
Samson
7e66495049 Support extern context impl (#6658)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-03-04 16:07:03 -05:00
Matilde Morrone
7eb69f43b6 Add DRM support to Vulkan backend (#7212)
* Add basic drm support to vulkan backend

* Move vulkan drm implementation to its own module

* Properly feature gate drm support and add safety docs

* Disable drm on wasm targets

* Remove old fixme comment from vulkan drm backend

* Move cfg check inside drm module

* Use expect instead of allow for create_surface_from_drm

* Document that drm is not available on apple platforms
2025-03-04 20:53:38 +00:00
Vecvec
5b3266db23 Support getting hit vertex positions (#7183) 2025-03-04 20:06:44 +01:00
SupaMaggie70Incorporated
a6109bf69b Mesh shaders - initial wgpu hal changes (#7089)
* Initial(untested commit), vulkan and gles only supported

* Maybe fixed compiles for metal and dx12

* Hopefully fixed compiles for other backends and updated to functional(?) vulkan thing

* Fixed the clippy warning

* Fixed silly documentation mistake

* Fixed issue with multiview feature

* Dummy commit for dummy CI

The CI pooped itself, hopefully this fixes that. Will probably be undone either way.

* Re trigger CI checks, to avoid #7126

* Changes based on code review

* Fixed clippy warning, broken cargo.lock

* Unfucked cargo.lock for real this time

* Switched match to if-let in accordance with review

* Updated changelog

* Fix CI error

Done from web out of impatience

* CI is very angry 😡

Made CI less angry by fixing formatting(hopefully). This commit was also done from GitHub web.

* Removed comment in following request

* Update wgpu-hal/src/vulkan/adapter.rs

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-03-04 00:12:38 +00:00
dependabot[bot]
8394b10e6b chore(deps): bump crate-ci/typos from 1.29.9 to 1.30.0 (#7259)
* chore(deps): bump crate-ci/typos from 1.29.9 to 1.30.0

Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.29.9 to 1.30.0.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.29.9...v1.30.0)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix small typo

Signed-off-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-03-03 23:09:41 +00:00
Zachary Harrold
e4cc5cb9ad Use core and alloc instead of std in naga (#7256)
* Use `core` and `alloc` instead of `std` in `naga`

* Update CHANGELOG.md

* `taplo fmt`

* Fix documentation links to refer to `hashbrown::HashMap`
2025-03-03 16:44:53 -05:00
Jamie Nicol
7b54f9dfd2 [naga wgsl-in] Concretize base type prior to non-constant indexed access (#7260)
Parsing currently fails for shaders that attempt to dynamically index
an abstract-typed array (or vector, etc), like so:

    var x = array(1, 2, 3)[i];

This is caused by attempting to concretize the Expression::Access
expression, which the ConstantEvaluator fails to do so due to the
presence of a non-constant expression.

To solve this, this patch concretizes the base type *prior* to
indexing it (for non-constant indices), meaning the constant evaluator
never sees any non-constant expressions. This matches the WGSL
specification:

    When an abstract array value e is indexed by an expression that is
    not a const-expression, then the array is concretized before the
    index is applied.

(Similar applies for both vectors and matrices, too.)

This may be somewhat non-optimal in that if there are multiple
accesses of the same abstract expression, we will produce duplicated
concretized versions of that expression. This seems unlikely to be a
major issue in practice, and we can always improve this if and when we
encounter a real issue caused by it.
2025-03-03 09:33:08 -05:00
Kent Slaney
3acac093fd msl bitmask fix (#7255) 2025-03-03 15:16:57 +01:00
dependabot[bot]
6bf1ec34b5 chore(deps): bump the patch-updates group with 10 updates (#7258)
Bumps the patch-updates group with 10 updates:

| Package | From | To |
| --- | --- | --- |
| [bitflags](https://github.com/bitflags/bitflags) | `2.8.0` | `2.9.0` |
| [cargo_metadata](https://github.com/oli-obk/cargo_metadata) | `0.19.1` | `0.19.2` |
| [portable-atomic](https://github.com/taiki-e/portable-atomic) | `1.10.0` | `1.11.0` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.15` | `1.2.16` |
| [clap](https://github.com/clap-rs/clap) | `4.5.30` | `4.5.31` |
| [clap_builder](https://github.com/clap-rs/clap) | `4.5.30` | `4.5.31` |
| [litemap](https://github.com/unicode-org/icu4x) | `0.7.4` | `0.7.5` |
| [uuid](https://github.com/uuid-rs/uuid) | `1.14.0` | `1.15.1` |
| [zerofrom](https://github.com/unicode-org/icu4x) | `0.1.5` | `0.1.6` |
| [zerofrom-derive](https://github.com/unicode-org/icu4x) | `0.1.5` | `0.1.6` |


Updates `bitflags` from 2.8.0 to 2.9.0
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/2.8.0...2.9.0)

Updates `cargo_metadata` from 0.19.1 to 0.19.2
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.19.1...0.19.2)

Updates `portable-atomic` from 1.10.0 to 1.11.0
- [Release notes](https://github.com/taiki-e/portable-atomic/releases)
- [Changelog](https://github.com/taiki-e/portable-atomic/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/portable-atomic/compare/v1.10.0...v1.11.0)

Updates `cc` from 1.2.15 to 1.2.16
- [Release notes](https://github.com/rust-lang/cc-rs/releases)
- [Changelog](https://github.com/rust-lang/cc-rs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.15...cc-v1.2.16)

Updates `clap` from 4.5.30 to 4.5.31
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.30...v4.5.31)

Updates `clap_builder` from 4.5.30 to 4.5.31
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/v4.5.30...v4.5.31)

Updates `litemap` from 0.7.4 to 0.7.5
- [Release notes](https://github.com/unicode-org/icu4x/releases)
- [Changelog](https://github.com/unicode-org/icu4x/blob/main/CHANGELOG.md)
- [Commits](https://github.com/unicode-org/icu4x/commits)

Updates `uuid` from 1.14.0 to 1.15.1
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/v1.14.0...v1.15.1)

Updates `zerofrom` from 0.1.5 to 0.1.6
- [Release notes](https://github.com/unicode-org/icu4x/releases)
- [Changelog](https://github.com/unicode-org/icu4x/blob/main/CHANGELOG.md)
- [Commits](https://github.com/unicode-org/icu4x/commits)

Updates `zerofrom-derive` from 0.1.5 to 0.1.6
- [Release notes](https://github.com/unicode-org/icu4x/releases)
- [Changelog](https://github.com/unicode-org/icu4x/blob/main/CHANGELOG.md)
- [Commits](https://github.com/unicode-org/icu4x/commits)

---
updated-dependencies:
- dependency-name: bitflags
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: cargo_metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: portable-atomic
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: cc
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: clap
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: clap_builder
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: litemap
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: uuid
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: zerofrom
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: zerofrom-derive
  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>
2025-03-02 22:26:13 -05:00
Jim Blandy
1ae7395a6d Update MSRV advertised in Naga's README.md. (#7257) 2025-03-01 17:53:37 -05:00
JMS55
2764e7a399 Add wgpu_hal::vulkan::Adapter::texture_format_as_raw (#7228)
* Add wgpu_hal::vulkan::Adapter::texture_format_as_raw

* Add changelog entry
2025-02-28 20:44:09 -05:00
Erich Gubler
0b5197d8d0 refactor: sync. wgpu-core's allow(clippy::arc_with_non_send_sync) to wgpu (#6771) 2025-02-28 12:37:30 -05:00
Erich Gubler
ba501631e0 docs(pull_request_template): note CHANGELOG entries are for user-facing changes (#7247) 2025-02-28 09:17:31 -05:00
Ali Shirazi
f421dd8b07 Refactor Wrapped (#7248)
Co-Authored-By: Erich Gubler <erichdongubler@gmail.com>
2025-02-28 09:08:56 -05:00
Jim Blandy
3297e9f108 Review checklist: suggest checking insertions expected to be new. (#7245)
Suggest checking that PRs assert that insertions into sets or maps
expected to be adding new values didn't actually just replace some
existing value.

Bug #7048 and its several duplicates would have been caught sooner if
the insertion of the new spill temporary into the `spilled_composites`
table had asserted that there was no existing spill variable for that
expression.
2025-02-27 19:30:18 -05:00
Devon
d6ca412732 Add textureBarrier (#7173) 2025-02-27 20:27:15 +01:00
Erich Gubler
41693bc8bd docs(CONTRIBUTING): streamline Rust toolchain dep. description
Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-02-27 13:57:12 -05:00
Connor Fitzgerald
7f87994c3f Mention Vulkan SDK requirement in CONTRIBUTING.md 2025-02-27 13:57:12 -05:00
Melody Madeline Nosurname
da0b68dde3 Change skybox cybertruck model to ferris (#7237)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-02-27 18:25:57 +00:00
Jim Blandy
a285ad13f0 [naga spv-out] Don't generate multiple temporaries for spill values. (#7239)
When spilling arrays and matrices so that we can access them with an
index computed at runtime, if we need to spill the same expression again,
don't wipe out our record of the temporary variable we used the first
time. Just re-use it.

Fixes #7048.
2025-02-27 18:34:52 +01:00
Connor Fitzgerald
99437e7343 Turn dependency tests from xtask subcommand into #[test]s (#7220) 2025-02-27 05:22:08 +00:00
Erich Gubler
6f0c2434a7 chore(hal,core): use core::{error::Error,format} instead of std
This allows `wgpu-hal` to be used in `no_std` environments, except that
currently, only the `noop` backend supports `no_std`.
In the future, `cfg(all(gles, webgl))` should also be `no_std`, but that
requires further work.

Co-Authored_by: Kevin Reid <kpreid@switchb.org>
2025-02-26 22:58:50 -05:00
Erich Gubler
f234ff27ab chore: satisfy clippy::unnecessary_map_or in Rust 1.85 2025-02-26 22:58:50 -05:00
Erich Gubler
4200136e2c refactor(naga): invert coordinate operand typeck to is_none_or 2025-02-26 22:58:50 -05:00
Erich Gubler
c626d4f819 build: update CORE_MSRV 1.80.1 → 1.82.0 2025-02-26 22:58:50 -05:00
Erich Gubler
1bd3c7b4ee refactor(hal): s/once_cell::Lazy/std::sync::LazyLock
Weaken our dependence on the `once_cell` crate by using functionality
from `std` instead that was upstreamed from `once_cell`, this time with
what's available in Rust 1.80+.

It's not yet possible to eliminate this dependency entirely, but do what
we can for now.
2025-02-26 22:58:50 -05:00
Erich Gubler
8774ab53d5 chore: remove std::mem::* imports now unnecessary with CORE_MSRV
`std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust
1.80; see
[`rust`#123168](https://github.com/rust-lang/rust/pull/123168/).
2025-02-26 22:58:50 -05:00
Erich Gubler
68803e3b9b refactor: use more c string literals 2025-02-26 22:58:50 -05:00
Erich Gubler
567fdbc2db chore: satisfy clippy::manual_c_str_literals
This was previously an `allow`-by-default warning in Clippy's `pedantic`
group, but with Rust 1.83 it was promoted to a `warn`-by-default member
of its `complexity` group.

Co-Authored-By: Kevin Reid <kpreid@switchb.org>
2025-02-26 22:58:50 -05:00
Erich Gubler
18951ea3d2 build: update CORE_MSRV 1.76.0 → 1.80.1 2025-02-26 22:58:50 -05:00
Kevin Reid
177205b3be Make lack of spirv-as non-fatal for testing. 2025-02-26 19:19:46 -05:00
Junjun Dong
93f64dc847 perf: wgsl::…::Lowerer::lower: don't clone diagnostic_filters arena (#7176)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2025-02-25 20:52:03 +00:00