Commit Graph

9099 Commits

Author SHA1 Message Date
Jim Blandy
6dcccc40a1 [naga] Move predeclared type name generation to common code.
Add a new module, `naga::common::predeclared`, which implements a new
`struct_name` method on `naga::ir::PredeclaredType`, to produce the
name of the struct type corresponding to that `PredeclaredType` value.
Use this new method in `naga::front::type_gen`.
2025-04-02 18:27:19 -04:00
Jim Blandy
f11b3b98e3 [naga] Move TypeInner::automatically_converts_to into proc.
Make the associated function `TypeInner::automatically_converts_to`
available outside the WGSL front end by moving it into the
`proc::type_methods` module.
2025-04-02 18:27:19 -04:00
Andy Leiserson
2c777f79f0 [naga wgsl-in] vecN() constructors and let type conversions (#7367)
* Support `vecN()` constructors (fixes #7356)
* Apply automatic conversions to the initializer for `let` bindings
2025-04-02 15:52:40 +00:00
sagudev
f7f09357a6 Update expectations
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-04-02 07:53:13 -07:00
sagudev
801b29cf01 Do not add local const to named expr
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-04-02 07:53:13 -07:00
sagudev
d937fabcd5 Revert: Workaround for some builtins not implemented as constant expression
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-04-02 07:53:13 -07:00
sagudev
6e6675a73c Revert [wgsl-out] Write const named expr as const declarations
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-04-02 07:53:13 -07:00
Erich Gubler
c4b781bdea chore: there and back again: hashbrown 0.15 (#7461)
This backs out commit 005bde99f9 (#7081).
2025-04-01 17:15:01 -04:00
Josh Groves
ab38e8e430 Avoid overflows for extreme scissor coordinates (#7459) 2025-04-01 09:47:39 -04:00
Connor Fitzgerald
a9279de793 Fix assorted issues with WebGL (#7448)
* Fix validation error when configuring the surface on WebGL

* Remove unneeded `webgl` feature

* Fix compilation of the `noop` backend on `wasm32`

* Prevent `webgpu` examples from incorrectly falling back to WebGL

* Reduce dependency set when building wasm examples

* Fix various warnings
2025-03-31 22:02:21 -04:00
Kevin Reid
02700ab162 Move test and benchmark targets to standard Cargo autodiscovery layout. (#7436)
This will make it easier for contributors to understand the file layout,
at the cost of said layout containing several more nested directories.
I will personally appreciate not having to remember to look for
`root.rs` instead of `main.rs`.

I also renamed the test targets so that they do not *all* share the
superfluous suffix “-test” (test targets live in a different namespace
than other target types and packages, so the name can presume that it
is always known that they are tests).

The Naga snapshot data sets `naga/tests/{in,out}` have been left in
their original positions.
2025-03-31 21:17:05 -04:00
Jim Blandy
65fcacf683 [naga tests] Silence dead code warning. (#7457)
Silence warnings about `DummyInterpolationShader::entry_point` being
unused in test builds with `wgsl-in` feature but without the
`glsl-out` feature.
2025-03-31 20:16:00 -04:00
Marc Pabst
3d7ae9dc92 Allow to get raw swap chain from DX12 surface (#7399)
* allow to get raw swap_chain from dx12 surface

* Update wgpu-hal/src/dx12/mod.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* allow obtaining IDXGISwapChain3 directly

---------

Co-authored-by: Marc Pabst <mail@xxxxxxx>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: Marc Pabst <“marcpabst@users.noreply.github.com”>
2025-03-31 20:15:35 -04:00
Jim Blandy
700a2e8ced [naga] Update naga/xtask/Cargo.lock. 2025-03-31 13:32:11 -07:00
Andy Leiserson
d1b00c5d25 [examples] Fixes for examples on web (#7454)
Fixes #7364
2025-03-31 16:07:52 -04:00
dependabot[bot]
24b72fc994 chore(deps): bump the patch-updates group with 6 updates (#7453)
Bumps the patch-updates group with 6 updates:

| Package | From | To |
| --- | --- | --- |
| [glam](https://github.com/bitshifter/glam-rs) | `0.29.2` | `0.29.3` |
| [once_cell](https://github.com/matklad/once_cell) | `1.21.1` | `1.21.3` |
| [bytemuck_derive](https://github.com/Lokathor/bytemuck) | `1.9.2` | `1.9.3` |
| [clap](https://github.com/clap-rs/clap) | `4.5.33` | `4.5.34` |
| [clap_builder](https://github.com/clap-rs/clap) | `4.5.33` | `4.5.34` |
| [socket2](https://github.com/rust-lang/socket2) | `0.5.8` | `0.5.9` |


Updates `glam` from 0.29.2 to 0.29.3
- [Changelog](https://github.com/bitshifter/glam-rs/blob/0.29.3/CHANGELOG.md)
- [Commits](https://github.com/bitshifter/glam-rs/compare/0.29.2...0.29.3)

Updates `once_cell` from 1.21.1 to 1.21.3
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.21.1...v1.21.3)

Updates `bytemuck_derive` from 1.9.2 to 1.9.3
- [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md)
- [Commits](https://github.com/Lokathor/bytemuck/commits)

Updates `clap` from 4.5.33 to 4.5.34
- [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.33...clap_complete-v4.5.34)

Updates `clap_builder` from 4.5.33 to 4.5.34
- [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.33...v4.5.34)

Updates `socket2` from 0.5.8 to 0.5.9
- [Release notes](https://github.com/rust-lang/socket2/releases)
- [Changelog](https://github.com/rust-lang/socket2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/socket2/commits)

---
updated-dependencies:
- dependency-name: glam
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: bytemuck_derive
  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: socket2
  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-31 09:55:42 -04:00
dependabot[bot]
52f1227374 chore(deps): bump crate-ci/typos from 1.30.2 to 1.31.0 (#7452)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.30.2 to 1.31.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.30.2...v1.31.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>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-30 23:01:42 -04:00
Andy Leiserson
c7c79a0dc9 Disallow taking the address of a vector component (#7284) 2025-03-28 11:32:06 +01:00
Jer
efbfa36ded Dealing with data too large for a single buffer (#6138)
* init files, dir structure

* wip: it's working need to suss out the readme and some of the consts...

* ok that's probably good enough for a first pass...

* chore: spelling

* chore: readme tweaks

* chore: clippy and fmt

* chore: add self and changes to changelog.md

* fix: typo and remove env_logger via cfg flag for wasm builds (which this doesn't supprot anyway)

* refactor: bring inline with newer wgpu

* refactor: bring inline with newer wgpu

* chore: work on the readme a bit...

* refactor: remove a bunch of everything, be simple

* wip: get a test going

* wip: remove unrequired pub(s)...

* refactor: remove a bunch of everything, be simple

wip: get a test going

* wip: remove unrequired pub(s)...

wip: remove unrequired pub(s)...

* chore: cleanups, typos, simplifying

* chore: reconcile changelog diffs

* fix: re-add our change to the changelog

* wip: finess the docs a bit per request...

* chore: trying to get the woring right...

* chore: trying to get the woring right...

* fix: typos

* fix: spelling

* Update mod.rs

swap all loops over to 'for' by request.

Flume's sender is already Send/Sync

chunks will already split for us

.unwraps() unwraps everywhere!

* Update CHANGELOG.md

Co-authored-by: Jim Blandy <jimb@red-bean.com>

* 1GB as the example says we'll do

- 1GB as the example says we'll do
- update readme for windows users.

* init files, dir structure

* wip: it's working need to suss out the readme and some of the consts...

* ok that's probably good enough for a first pass...

* chore: spelling

* chore: readme tweaks

* chore: clippy and fmt

* chore: add self and changes to changelog.md

* fix: typo and remove env_logger via cfg flag for wasm builds (which this doesn't supprot anyway)

* refactor: bring inline with newer wgpu

* refactor: bring inline with newer wgpu

* chore: work on the readme a bit...

* refactor: remove a bunch of everything, be simple

* wip: get a test going

* wip: remove unrequired pub(s)...

* wip: remove unrequired pub(s)...

wip: remove unrequired pub(s)...

* chore: cleanups, typos, simplifying

* fix: re-add our change to the changelog

* wip: finess the docs a bit per request...

* chore: trying to get the woring right...

* chore: trying to get the woring right...

* fix: typos

* fix: spelling

* Update mod.rs

swap all loops over to 'for' by request.

Flume's sender is already Send/Sync

chunks will already split for us

.unwraps() unwraps everywhere!

* Update CHANGELOG.md

Co-authored-by: Jim Blandy <jimb@red-bean.com>

* 1GB as the example says we'll do

- 1GB as the example says we'll do
- update readme for windows users.

* bring up to date with trunk

sync with trunk.
make more of Jim's changes

* some of the consts have changed name.

* small tweaks

* what is the flag called now?

what is the flag called now?

* Update shader.wgsl

naming things betterer

* Update README.md

reword readme

* Update README.md

simplify readme

* Update mod.rs

remove unused

* well at least it compiles again

* BUG: ... it seems to run forever and never complete.

* nicer shader module creation

* ... add logging to track down infinite hangtime...

* use 2 buffers in the test

* test and example pass (now they do the same number of buffers..

* that's better...

* fix: remove duplicate entries

* fix: whitespace

* move changelog entry to #unreleased per request

* fix: target_arch != wasm to satiate pipeline

* fix: target_arch != wasm to satiate pipeline

* pipeline want's us to allow allows...

* savage hacks to make the wasm build ignore our test

* fix: allow the allowing of allows that allow the dead_code.

* Fix: no tests on wasm

---------

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2025-03-28 02:24:29 +00:00
Christian Legnitto
1ef9940114 Reduce repo MSRV from 1.85 to 1.84 (#7425)
* Reduce repo MSRV from 1.85 to 1.84

Fixes https://github.com/gfx-rs/wgpu/issues/7409

* Replace usage of task::Waker::noop()

* Gate waker code to `noop` feature

* Remove unused copied waker function

* Remove doctest from copied code
2025-03-27 14:25:19 -04:00
Daniel McNab
5a583b1fb7 Polyfill unpackUnorm4x8 and friends on unsupported GLSL versions (#7408) 2025-03-27 15:55:14 +00:00
Jamie Nicol
479173197e [naga hlsl-out msl-out spv-out] Avoid undefined behaviour when casting floats to integers
Currently we generate code to convert floating point values to integers
using constructor-style casts in HLSL, static_cast in MSL, and
OpConvertFToS/OpConvertFToU instructions in SPV. Unfortunately the
behaviour of these operations is undefined when the original value is
outside of the range of the target type.

This patch avoids undefined behaviour by first clamping the value to
be inside the target type's range, then performing the cast.
Additionally, we specifically clamp to the minimum and maximum values
that are exactly representable in both the original and the target
type, as per the WGSL spec[1]. Note that these may not be the same as
the minimum and maximum values of the target type.

We additionally must ensure we clamp in the same manner for
conversions during const evaluation. Lastly, although not part of the
WGSL spec, we do the same for casting from F64 and/or to I64 or U64.

[1] https://www.w3.org/TR/WGSL/#floating-point-conversion
2025-03-27 15:41:27 +00:00
dependabot[bot]
e63a51fdaf chore(deps): bump the patch-updates group across 1 directory with 15 updates (#7441)
* chore(deps): bump the patch-updates group across 1 directory with 15 updates

Bumps the patch-updates group with 12 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [log](https://github.com/rust-lang/log) | `0.4.26` | `0.4.27` |
| [nanoserde](https://github.com/not-fl3/nanoserde) | `0.1.37` | `0.2.1` |
| [bytemuck_derive](https://github.com/Lokathor/bytemuck) | `1.8.1` | `1.9.2` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.16` | `1.2.17` |
| [clap](https://github.com/clap-rs/clap) | `4.5.32` | `4.5.33` |
| [icu_locid_transform_data](https://github.com/unicode-org/icu4x) | `1.5.0` | `1.5.1` |
| [icu_normalizer_data](https://github.com/unicode-org/icu4x) | `1.5.0` | `1.5.1` |
| [icu_properties_data](https://github.com/unicode-org/icu4x) | `1.5.0` | `1.5.1` |
| [jiff](https://github.com/BurntSushi/jiff) | `0.2.4` | `0.2.5` |
| [libm](https://github.com/rust-lang/libm) | `0.2.8` | `0.2.11` |
| [quick-xml](https://github.com/tafia/quick-xml) | `0.37.2` | `0.37.3` |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | `0.1.14` | `0.2.0` |



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

Updates `nanoserde` from 0.1.37 to 0.2.1
- [Commits](https://github.com/not-fl3/nanoserde/commits)

Updates `bytemuck_derive` from 1.8.1 to 1.9.2
- [Changelog](https://github.com/Lokathor/bytemuck/blob/main/changelog.md)
- [Commits](https://github.com/Lokathor/bytemuck/compare/bytemuck_derive-v1.8.1...bytemuck_derive-v1.9.2)

Updates `cc` from 1.2.16 to 1.2.17
- [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.16...cc-v1.2.17)

Updates `clap` from 4.5.32 to 4.5.33
- [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.32...clap_complete-v4.5.33)

Updates `clap_builder` from 4.5.32 to 4.5.33
- [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.32...v4.5.33)

Updates `icu_locid_transform_data` from 1.5.0 to 1.5.1
- [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/compare/icu@1.5.0...ind/icu_capi@1.5.1)

Updates `icu_normalizer_data` from 1.5.0 to 1.5.1
- [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/compare/icu@1.5.0...ind/icu_capi@1.5.1)

Updates `icu_properties_data` from 1.5.0 to 1.5.1
- [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/compare/icu@1.5.0...ind/icu_capi@1.5.1)

Updates `jiff` from 0.2.4 to 0.2.5
- [Release notes](https://github.com/BurntSushi/jiff/releases)
- [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.4...jiff-static-0.2.5)

Updates `jiff-static` from 0.2.4 to 0.2.5
- [Release notes](https://github.com/BurntSushi/jiff/releases)
- [Changelog](https://github.com/BurntSushi/jiff/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/jiff/compare/jiff-static-0.2.4...jiff-static-0.2.5)

Updates `libm` from 0.2.8 to 0.2.11
- [Release notes](https://github.com/rust-lang/libm/releases)
- [Changelog](https://github.com/rust-lang/libm/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/libm/compare/0.2.8...libm-v0.2.11)

Updates `nanoserde-derive` from 0.1.22 to 0.2.1

Updates `quick-xml` from 0.37.2 to 0.37.3
- [Release notes](https://github.com/tafia/quick-xml/releases)
- [Changelog](https://github.com/tafia/quick-xml/blob/master/Changelog.md)
- [Commits](https://github.com/tafia/quick-xml/compare/v0.37.2...v0.37.3)

Updates `unicode-width` from 0.1.14 to 0.2.0
- [Commits](https://github.com/unicode-rs/unicode-width/compare/v0.1.14...v0.2.0)

---
updated-dependencies:
- dependency-name: log
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: nanoserde
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: bytemuck_derive
  dependency-type: indirect
  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: icu_locid_transform_data
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: icu_normalizer_data
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: icu_properties_data
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: jiff
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: jiff-static
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: libm
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: nanoserde-derive
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: patch-updates
- dependency-name: quick-xml
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: unicode-width
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: patch-updates
...

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

* Add step to downgrade MSRV of dependencies

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-03-26 21:28:22 +00:00
Erich Gubler
1d4740e89d build: upgrade ron 0.8.1 → 0.9.0 2025-03-26 16:03:03 -04:00
Erich Gubler
b3da513d51 chore(naga): remove unnecessary comment on version selection for ron 2025-03-26 16:03:03 -04:00
Erich Gubler
ded2e7f9f1 refactor(naga): use workspace version of ron 2025-03-26 16:03:03 -04:00
teoxoy
9a2b5fdb70 abstract away usage of scratch space for buffer barriers and unique index iterators 2025-03-26 18:26:31 +00:00
teoxoy
3705928273 [validate_draw] refactor out an is_bit_set function 2025-03-26 18:26:31 +00:00
teoxoy
7d15c511de move indirect validation code to its own folder
rename items appropriately
internalize indirect buffer bind groups
2025-03-26 18:26:31 +00:00
teoxoy
ef622c1061 validate multi draw indirect calls 2025-03-26 18:26:31 +00:00
teoxoy
2ab3b6da8d guarantee DownlevelFlags::COMPUTE_SHADERS when DownlevelFlags::INDIRECT_EXECUTION is enabled 2025-03-26 18:26:31 +00:00
teoxoy
a2878db5f2 add indirect_buffer_offsets test 2025-03-26 18:26:31 +00:00
teoxoy
0285e60984 Replace the indirect-validation feature with InstanceFlags::VALIDATION_INDIRECT_CALL.
With the only caveat that device creation will now panic if the `wgsl` feature is not enabled, `InstanceFlags::VALIDATION_INDIRECT_CALL` is set and the device supports `DownlevelFlags::INDIRECT_EXECUTION`.
2025-03-26 18:26:31 +00:00
teoxoy
53c2d15e0b implement indirect draw validation 2025-03-26 18:26:31 +00:00
Andy Leiserson
90afc88e76 [naga] Gracefully handle span lookup with no module source (#7390)
Fixes #7165
2025-03-26 11:19:11 -04:00
Jamie Nicol
e037f4bc48 [naga wgsl-in] Implement unary negation during const evaluation for Literal::F64 (#7431)
This not being implemented made it impossible to express negative f64
literals. This is now fixed, and we've added a test.
2025-03-26 08:18:52 -04:00
Jamie Nicol
7e0e1e2803 [naga wgsl-in] Clamp negative f16 values to 0 when converting to unsigned integers during const evaluation (#7421)
This avoids a panic due to f16::to_u32()/f16::to_u64() returning None
when the value of the f16 is <= -1.0. The correct behaviour when
converting from a floating point to an integer when the value is out
of range is to clamp to the nearest value that is representable in
both the source and destination type. ie zero for negative numbers.
2025-03-26 09:04:56 +00:00
Jim Blandy
61b70cfdb1 [naga] Check the type of ImageQuery::Size's level parameter. (#7426)
Require that the `level` operand of an `ImageQuery::Size` expression
is `i32` or `u32`, per spec.

Without this fix, the following WGSL:

    @group(0) @binding(0)
    var t: texture_1d<f32>;
    fn f() -> u32 {
      return textureDimensions(t, false);
    }

produces the following invalid HLSL:

    Texture1D<float4> t : register(t0);

    uint NagaMipDimensions1D(Texture1D<float4> tex, uint mip_level)
    {
        uint4 ret;
        tex.GetDimensions(mip_level, ret.x, ret.y);
        return ret.x;
    }

    uint f()
    {
        return NagaMipDimensions1D(t, false);
    }
2025-03-26 03:38:38 +00:00
Zachary Harrold
175b66c796 Update codespan-reporting to 0.12 (#7398)
* Update `codespan-reporting` to 0.12

* Use explicit path for `term::termcolor`

* Revert changes to `Cargo.lock`
2025-03-26 02:10:30 +00:00
Jamie Nicol
7b6ff5f554 [naga wgsl-out] Represent min value i64 literals as -9223372036854775807li - 1li (#7424)
ie the second-most negative value minus 1.

The most negative value of an integer type is not directly expressible
in WGSL, as it relies on applying the unary negation operator to a
value which is one larger than the largest value representable by the
type.

To avoid this issue for i32, we negate the required value as an
AbstractInt before converting to i32. AbstractInt, being 64 bits, is
capable of representing the maximum i32 value + 1.

However, for i64 this is not the case. Instead this patch makes us
express the mimimum i64 value as the second most negative i64 value,
minus 1, ie `-9223372036854775807li - 1li`, thereby avoiding the
issue.
2025-03-25 14:36:14 -04:00
sagudev
94dd3a7dc7 Fix some cfg guards (#7418)
All guards should actually refer to `wgpu_core` instead of `native`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-03-25 08:25:59 -04:00
Erich Gubler
299079fb69 chore: remove unnecessarily allow'd unused_braces (#7416) 2025-03-24 22:23:24 +00:00
Erich Gubler
958528fb14 fix(wgsl-in): increase brace limit to 127 (#7412) 2025-03-24 21:43:21 +00:00
Erich Gubler
97dbdc7d75 fix(wgsl-in): allow f16s in overrides (#7411) 2025-03-24 16:06:27 -04:00
Jim Blandy
f0ff173f82 [naga] Implement constant evaluation for the cross builtin. (#7404)
Add support for `naga::ir::MathFunction::Cross` to
`naga::proc::constant_evaluator`.

In the tests:

- Change `naga/tests/in/wgsl/cross.wgsl` to use more interesting
  argument values. Rather than passing the same vector twice, which
  yields a cross product of zero, pass in the x and y unit vectors,
  whose cross product is the z unit vector. Update snapshot output.

- Replace `validation::bad_cross_builtin_args` with a new test,
  `builtin_cross_product_args`, that is written more in the style of
  the other tests in this module, and does not depend on the WGSL
  front end. Because this PR changes the behavior of the constant
  evaluator, this test stopped behaving as expected.

- In `wgsl_errors::check`, move a `panic!` out of a closure so that
  the `#[track_caller]` attribute works properly.
2025-03-24 10:55:22 +01:00
Christian Legnitto
10cd1ccd8c [spv_in] Finish emitter after function arguments (#7397)
Fixes https://github.com/gfx-rs/wgpu/issues/7358.
2025-03-24 10:36:30 +01:00
Bruce Mitchener
ccaf9a84f8 Fix clippy::implicit_saturating_sub lints (#7395) 2025-03-22 13:17:34 -04:00
Bruce Mitchener
edd0ef80af Fix clippy::manual_repeat_n lints (#7394) 2025-03-22 16:18:34 +00:00
Erich Gubler
1e172b2e14 test: repair multi-instance tests (#7388) 2025-03-21 13:25:31 -04:00
Connor Fitzgerald
c37a005f63 Make target defaults align with "butterfly" target set (#7379) 2025-03-21 11:41:06 -04:00