Commit Graph

8856 Commits

Author SHA1 Message Date
Teodor Tanasoaia
b5e32cec58 add max_shader_model to Dx12Compiler (#7167) 2025-02-18 13:44:23 +01:00
Connor Fitzgerald
e590555a8c test: use spirv-as instead of pre-assembled SPIR-V (#7157) 2025-02-17 14:48:09 -05:00
Samson
7240c18554 fix(naga): Forbid negative indexing in const expressions (#7155)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-02-17 14:38:00 -05:00
Jamie Nicol
d625d083c3 [naga wgsl-in] Implement any() and all() during const evaluation (#7166) 2025-02-17 14:13:49 -05:00
dependabot[bot]
c03176f3eb chore(deps): bump the patch-updates group across 1 directory with 7 updates (#7168)
Bumps the patch-updates group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [document-features](https://github.com/slint-ui/document-features) | `0.2.10` | `0.2.11` |
| [smallvec](https://github.com/servo/rust-smallvec) | `1.13.2` | `1.14.0` |
| [cc](https://github.com/rust-lang/cc-rs) | `1.2.13` | `1.2.14` |
| [clap](https://github.com/clap-rs/clap) | `4.5.28` | `4.5.29` |
| [equivalent](https://github.com/indexmap-rs/equivalent) | `1.0.1` | `1.0.2` |
| [toml_edit](https://github.com/toml-rs/toml) | `0.22.23` | `0.22.24` |



Updates `document-features` from 0.2.10 to 0.2.11
- [Release notes](https://github.com/slint-ui/document-features/releases)
- [Changelog](https://github.com/slint-ui/document-features/blob/master/CHANGELOG.md)
- [Commits](https://github.com/slint-ui/document-features/commits)

Updates `smallvec` from 1.13.2 to 1.14.0
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.13.2...v1.14.0)

Updates `cc` from 1.2.13 to 1.2.14
- [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.13...cc-v1.2.14)

Updates `clap` from 4.5.28 to 4.5.29
- [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.28...clap_complete-v4.5.29)

Updates `clap_builder` from 4.5.27 to 4.5.29
- [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.27...v4.5.29)

Updates `equivalent` from 1.0.1 to 1.0.2
- [Commits](https://github.com/indexmap-rs/equivalent/compare/v1.0.1...v1.0.2)

Updates `toml_edit` from 0.22.23 to 0.22.24
- [Commits](https://github.com/toml-rs/toml/compare/v0.22.23...v0.22.24)

---
updated-dependencies:
- dependency-name: document-features
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: smallvec
  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: equivalent
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: patch-updates
- dependency-name: toml_edit
  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-02-17 18:20:29 +00:00
Erich Gubler
6a01091397 move(core): s/create_compute_pass/begin_compute_pass/ 2025-02-17 12:42:10 -05:00
Erich Gubler
25a51606d1 move(core): s/create_render_pass/begin_render_pass/ 2025-02-17 12:42:10 -05:00
Connor Fitzgerald
194d4b1f36 New Binding Array Limit (#6952) 2025-02-17 09:22:24 -05:00
Kevin Reid
9da04c2b0b Add getters and From implementations to BufferSlice. (#7148)
* Add getters to `BufferSlice` to obtain its parts.

* Add conversions from `BufferSlice` to `BufferBinding` and `BindingResource`.
2025-02-17 11:06:13 +01:00
dependabot[bot]
16977225d1 chore(deps): bump crate-ci/typos from 1.29.5 to 1.29.7 (#7158)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-17 02:52:31 +00:00
Junjun Dong
98649a79a0 feat: update naga::back::spv::Function::to_words (#7156) 2025-02-16 21:43:24 -05:00
Connor Fitzgerald
d8833d0798 Use Update After Bind Descriptors for Bind Groups With Binding Arrays (#6815)
* Use Update After Bind Descriptors for Bind Groups With Binding Arrays

Update After Bind

x

* Comments

* Fix URL
2025-02-15 12:02:27 -05:00
CrazyboyQCD
a45e2db43a [Naga] replace unicode-xid with unicode-ident (#7135) 2025-02-14 20:58:17 -05:00
Sludge
723abcb1d3 Move changelog entry to the right version (#7145) 2025-02-14 23:38:55 +00:00
Connor Fitzgerald
7e119968ce Properly Deal with Timeouts (#7030) 2025-02-14 23:19:51 +00:00
Jim Blandy
f90f19c7e8 [naga spv-out] Factor out wrapped divide/module generation.
Move the code to generate the definition of an overflow-safe
divide/modulo SPIR-V function into its own Rust function, to reduce
indentation and clarify influences. This commit isn't intended to
cause any change in behavior.
2025-02-14 15:17:40 -08:00
Jamie Nicol
cb9666c6a7 [naga hlsl-out] Document the need for wrapper functions for integer division, modulo, abs(), and unary negation
Explain we need the wrapper functions not just to avoid undefined
behaviour, but also to ensure we adhere to the WGSL spec. Additionally
link to issue #7109 in cases where our workaround needs follow-up work
for non-32-bit integer types.
2025-02-14 15:17:40 -08:00
Jamie Nicol
b3b40c03d4 [naga msl-out] Document the need for wrapper functions for integer division, modulo, abs(), and unary negation
Explain we need the wrapper functions not just to avoid undefined
behaviour (or unspecified in the case of division), but also to ensure
we adhere to the WGSL spec.
2025-02-14 15:17:40 -08:00
Jim Blandy
96de35aac1 [hlsl-out] Clarify comment on HLSL floating-point divide by zero.
Replace the link to the resolved WGSL spec issue about floating-point
division by zero (gpuweb/gpuweb#2798) with links to the Direct3D 11
functional specification (which Direct3D 12 inherits) and the DXIL
specification, explaining that HLSL does what WGSL wants here.
2025-02-14 15:17:40 -08:00
Jim Blandy
bafeee6680 [hlsl-out] Clean up repetition in write_mapped_math_functions.
Since every `match` arm ends up looking up the type of the operation's
first argument, just do that once. This avoids a repetitive lookup for
`Abs`.
2025-02-14 15:17:40 -08:00
Jim Blandy
a25098f5ec [naga hlsl-out] Use Scalar associated constants in patterns. 2025-02-14 15:17:40 -08:00
Jamie Nicol
6cf4b710b8 [naga spv-out] Avoid undefined behaviour for integer division and modulo
Integer division or modulo is undefined behaviour in SPIR-V when the
divisor is zero, or when the dividend is the most negative number
representable by the result type and the divisor is negative one.

This patch makes us avoid this undefined behaviour and instead ensures
we adhere to the WGSL spec in these cases: for divisions the
expression evaluates to the value of the dividend, and for modulos the
expression evaluates to zero.

Similarily to how we handle these cases for the MSL and HLSL backends,
prior to emitting each function we emit code for any helper functions
required by that function's expressions. In this case that is helper
functions for integer division and modulo. Then, when emitting the
actual function's body, if we encounter an expression which needs
wrapped we instead emit a function call to the helper.
2025-02-14 15:17:40 -08:00
Jamie Nicol
b6186ba332 [naga hlsl-out] Avoid undefined behaviour for integer division, modulo, negation, and abs
Emit helper functions for MathFunction::Abs and UnaryOperator::Negate
with a signed integer scalar or vector operand. And for
BinaryOperator::Divide and BinaryOperator::Modulo with signed or
unsigned integer scalar or vector operands.

Abs and Negate are written to avoid signed integer overflow when the
operand equals INT_MIN. This is achieved by bitcasting the value to
unsigned, using the negation operator, then bitcasting the result back
to signed. As HLSL's bitcast functions asint() and asuint() only work
for 32-bit types, we only use this workaround in such cases.

Division and Modulo avoid undefined behaviour for INT_MIN / -1 and
divide-by-zero by using 1 for the divisor instead. Additionally we
avoid undefined behaviour when using the modulo operator on operands
of mixed signedness by using the equation from the WGSL spec, using
division, subtraction and multiplication, rather than HLSL's modulus
operator.
2025-02-14 15:17:40 -08:00
Jamie Nicol
88f6e9b8f8 [naga hlsl-out] Avoid undefined behaviour for signed integer addition, subtraction, and multiplication
Though not explicitly specified one way or the other, we have been
informed by DirectX engineers that signed integer overflow may be
undefined behaviour in some cases. To avoid this, we therefore bitcast
signed operands to unsigned prior to performing addition, subtraction,
or multiplication, then bitcast the result back to signed. As signed
types are represented as two's complement, this gives the correct
result whilst avoid any potential undefined behaviour.

Unfortunately HLSL's bitcast functions asint() and asuint() only work
for the 32-bit int and uint types. We therefore only apply this
workaround for 32-bit signed arithmetic. Support for other bit widths
could be added in the future, but extra care must be taken when
converting from unsigned to signed to avoid undefined or
implemented-defined behaviour.
2025-02-14 15:17:40 -08:00
Jamie Nicol
30363ef493 [naga hlsl-out] Wrap int literals in constructor-style cast
There is no literal suffix in HLSL for the integer type. We can,
however, wrap integer literals in a constructor style cast. This
avoids ambiguity when passing literals to overloaded functions, which
we'll make use of in the subsequent patch in this PR.
2025-02-14 15:17:40 -08:00
Jamie Nicol
8807c83363 [naga msl-out] Avoid undefined behaviour for integer division, modulo, negation, and abs
Adds infrastructure to the MSL backend for emitting helper functions,
based upon the existing HLSL backend equivalent. Emit helper functions
for MathFunction::Abs and UnaryOperator::Negate with a signed integer
scalar or vector operand. And for BinaryOperator::Divide and
BinaryOperator::Modulo with signed or unsigned integer scalar or
vector operands.

Abs and Negate are written to avoid signed integer overflow when the
operand equals INT_MIN. This is achieved by bitcasting the value to
unsigned and using the negation operator, then bitcasting the result
back to signed.

Division and Modulo avoid undefined bevaviour for INT_MIN / -1 and
divide-by-zero by using 1 for the divisor instead. Additionally we
avoid undefined behaviour when using the modulo operator when either
or both operands are negative by using the equation from the WGSL
spec, using division, subtraction and multiplication, rather than
MSL's modulus operator.

Lastly, as the usage of the wrapper function for unary integer
negation makes the negation_avoids_prefix_decrement() testcase less
interesting, we extend it to additionally test negating floats.
2025-02-14 15:17:40 -08:00
Connor Fitzgerald
106b709798 Remove HashMaps from wgpu API (#7133)
* Remove HashMaps from Surface API

* Fix Comments and Errors
2025-02-14 14:36:22 -05:00
Jamie Nicol
4bb09e1d3c [naga wgsl-in] Ensure constant evaluation correctly handles Composes of vector ZeroValues (#7138) 2025-02-14 13:18:12 -05:00
Erich Gubler
eea3dde67e fix: use separate pub consts for FeaturesWebGPU 2025-02-14 12:18:41 -05:00
Erich Gubler
b05e9705bf fix: add cbindgen:ignore on const with the same ident. 2025-02-14 12:18:41 -05:00
Erich Gubler
7510d7b929 fix: add cbindgen:ignore on conflicting monomorphizations 2025-02-14 12:18:41 -05:00
Erich Gubler
a7a5784156 refactor: use match instead of if let for Features::from_bits 2025-02-14 12:18:41 -05:00
Erich Gubler
8ecafe2750 refactor: use match, instead of if, for Features::from_name 2025-02-14 12:18:41 -05:00
Erich Gubler
e8e09d059f fix: use same visibility for Features fields as itself 2025-02-14 12:18:41 -05:00
Erich Gubler
26eded137a fix: allow(missing_docs) on Features fields 2025-02-14 12:18:41 -05:00
Erich Gubler
36ad109d7a style: fmt. bitflags_array! macro a bit
Most important points:

- Make macro repetitions easy to parse as a human.
- Try to follow `rustfmt` a bit more closely.
2025-02-14 12:18:41 -05:00
Bruce Mitchener
3710de8e5b Fix clippy::doc_overindented_list_items lints (#7139) 2025-02-14 16:36:41 +00:00
Teodor Tanasoaia
ef0e6f782a deduplicate vertex buffer size validation (#7124) 2025-02-14 10:33:28 +01:00
Bruce Mitchener
bae0e70e8d Fix clippy::unneeded_struct_pattern lints (#7136) 2025-02-14 01:32:21 -05:00
Connor Fitzgerald
ab38df24ba Improve cargo-nextext Configuration (#7131) 2025-02-13 18:55:23 -05:00
Connor Fitzgerald
03a01df3cb Speed Up Benchmarks in Test (#7129) 2025-02-13 18:48:13 -05:00
Kevin Reid
2f50426b35 Remove unnecessary chunk size field from StagingBelt. 2025-02-13 12:46:29 -05:00
Kevin Reid
ec6c7225da Remove unnecessary Arc from StagingBelt.
`Buffer` now implements `Clone` on its own.
2025-02-13 12:46:29 -05:00
Kevin Reid
fd896695d5 Expose StagingBelt allocation directly.
This allows using `StagingBelt` for copying to textures or any other
operation where copying to an existing buffer is not the desired outcome.

One unfortunate feature of the API is that `allocate()` returns the entire
buffer and an offset, so applications could accidentally touch parts of
the belt buffer outside the intended allocation. It might make more sense
to return `wgpu::BufferSlice`, but that struct cannot be used in
operations like `copy_buffer_to_texture` and does not have getters, so it
is not currently suitable for that purpose.

I also moved `Exclusive` into a module so that its unsafe-to-access field
is properly private, and made various improvements to the `StagingBelt`
documentation, such as acknowledging that `write_buffer_with()` exists.
2025-02-13 12:46:29 -05:00
Bruce Mitchener
7fe8e3818a wgpu-types: Improve formatting of docs (#7125) 2025-02-13 12:25:21 -05:00
Connor Fitzgerald
c39d37fc36 Fix Send/Sync of RequestDeviceErrorKind (#7122) 2025-02-13 08:46:50 -05:00
Kevin Reid
c4b25b8794 Duplicate BufferSlice methods onto Buffer and vice versa. (#7123)
This allows users to skip creation of `BufferSlice` if they have no use
for it, and brings `wgpu` closer to the WebGPU API without removing any
Rust convenience. New functions:

* `BufferSlice::slice()`
* `Buffer::map_async()`
* `Buffer::get_mapped_range()`
* `Buffer::get_mapped_range_mut()`
* `Buffer::get_mapped_range()`
2025-02-13 14:40:09 +01:00
Leo Kettmeir
f0bf789f58 refactor(deno): use object wrap (#7113) 2025-02-13 04:17:00 -08:00
Kevin Reid
0f111cb27c Add a test for the noop backend. 2025-02-12 22:31:47 -05:00
Kevin Reid
118a985ccd Allow creating Noop backend through the normal mechanisms. 2025-02-12 22:31:47 -05:00