Commit Graph
9338 Commits
Author SHA1 Message Date
Dmitry ZamkovandAndreas Reich 44957709ff Vulkan support for SHADER_EARLY_DEPTH_TEST and fix to conservative depth optimizations (#7676)
Co-authored-by: Andreas Reich <r_andreas2@web.de>
2025-05-24 09:52:39 +00:00
Robert Bamler ff291654b3 [wgpu-hal] Add PrivateCapabilities::shader_int8 on Vulkan
This allows declaring the SPIR-V capability "Int8", which allows us to
generate faster code for `[un]pack4x{I, U}8[Clamp]`.
2025-05-23 16:08:26 +02:00
Robert Bamler e636696e16 [wgpu-hal] separate 2 float16-related vk features
Separates the Vulkan feature sets
`VkPhysicalDeviceShaderFloat16Int8Features` and
`VkPhysicalDevice16BitStorageFeatures`, which previously were used
"together, or not at all".

This commit should not change any behavior yet, but I'd like to run full
CI tests on it for now. If the CI tests pass, I'll use this separation
to enable the `shader_int8` feature separately from the rest of the
features to enable optimizations of `[un]pack4x{I,U}8[Clamp]` on SPIR-V.
2025-05-23 16:08:26 +02:00
Robert Bamler 1be38fa2e2 Add changelog entry for #7664 2025-05-23 16:08:26 +02:00
Robert Bamler 8969965978 [naga] Vectorize [un]pack4x{I, U}8[Clamp] on msl
Implements more direct conversions between 32-bit integers and 4x8-bit
integer vectors using bit casting to/from `packed_[u]char4` when on
MSL 2.1+ (older versions of MSL don't seem to support these bit casts).

- `unpack4x{I, U}8(x)` becomes `[u]int4(as_type<packed_[u]char4>(x))`;
- `pack4x{I, U}8(x)` becomes `as_type<uint>(packed_[u]char4(x))`; and
- `pack4x{I, U}8Clamp(x)` becomes
  `as_type<uint>(packed_uchar4(metal::clamp(x, 0, 255)))`.

These bit casts match the WGSL spec for these functions because Metal
runs on little-endian machines.
2025-05-23 16:08:26 +02:00
Robert Bamler b32eb4a120 [naga] Vectorize [un]pack4x{I, U}8[Clamp] on spv
Emits vectorized SPIR-V code for the WGSL functions `unpack4xI8`,
`unpack4xU8`, `pack4xI8`, `pack4xU8`, `pack4xI8Clamp`, and
`pack4xU8Clamp` if `Capability::Int8` is available.

Exploits the following facts about SPIR-V ops:
- `SClamp`, `UClamp`, and `OpUConvert` accept vector arguments, in which
  case results are computed per component; and
- `OpBitcast` can cast between vectors and scalars, with a well-defined
  bit order that matches that required by the WGSL spec, see below.

WGSL spec for `pack4xI8` [1]:

> Component e[i] of the input is mapped to bits 8 x i through 8 x i + 7
> of the result.

SPIR-V spec for `OpBitcast` [2]:

> Within this mapping, any single component of `S` [remark: the type
> with fewer but wider components] (mapping to multiple components of
> `L` [remark: the type with more but narrower components]) maps its
> lower-ordered bits to the lower-numbered components of `L`.

[1] https://www.w3.org/TR/WGSL/#pack4xI8-builtin
[2] https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpBitcast
2025-05-23 16:08:26 +02:00
Andy Leiserson 0997b99429 [naga] Make additional test code reachable from entrypoints 2025-05-22 13:01:15 -07:00
Andy Leiserson 25636e274b [naga] Ensure globals in wgsl snapshot tests are reachable from an entry point
Convert tabs to spaces in access.wgsl
2025-05-22 13:01:15 -07:00
Andy Leiserson fd6f16f598 Revive the CTS job (#7675)
Includes the following minor functional fixes to deno_webgpu:

* Don't throw an error immediately when `create_buffer` is called with invalid usage flags.
* Implement `on_submitted_work_done`.
* Correct validation of GPUExtent3D element count.
* Run without tracing (instead of panic) if the DENO_WEBGPU_TRACE env var is not set.

Fixes #6838
2025-05-21 09:52:03 -07:00
Robert Bamler d7e6a0e1fa Potentially optimize dot4{I,U}8Packed on Metal (#7653)
* Potentially optimize `dot4{I,U}8Packed` on Metal

This might allow the Metal compiler to emit faster code (but that's not
confirmed). See
<https://github.com/gpuweb/gpuweb/issues/2677#issuecomment-1713292226>
for the optimization. The limitation to Metal 2.1+ is discussed here:
<https://github.com/gfx-rs/wgpu/pull/7574#issuecomment-2835464472>.

* [naga] Factor out new part of `put_block` on msl

CI on test failed because the latest changes to `put_block` made its
stack too big. Factoring out the new code into a separate method fixes
this issue.
2025-05-21 18:47:59 +02:00
Andy Leiserson bc0a023cd1 [naga] Ensure wgsl snapshot code is reachable from an entry point (#7674) 2025-05-21 11:32:10 -04:00
Lucien Greathouse a95c69eb91 Fix error message for sampler arrays (#7704) 2025-05-20 10:43:36 -04:00
Amogh Shivaram 55725d6483 Destroy texture views in clear_mode when destroying texture (#7705) 2025-05-19 22:44:25 -04:00
Lucien Greathouse 45b3d66301 Fix error message for sampler arrays (#7704) 2025-05-19 19:25:36 -07:00
Andy Leiserson 26bab56fd5 [deno] Rework error and device loss handling (#7693) 2025-05-17 19:38:22 +02:00
Vecvec 85001b2436 Use new struct AnimationTimer instead of Instant to prevent random test failures. (#7685) 2025-05-13 22:52:49 -04:00
renovate[bot] 4c66478a94 chore(deps): update cargo.lock (#7684)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-13 15:31:08 -04:00
Andy Leiserson 0dc6bfdd67 Don't raise AlreadyDestroyed error on repeated destroy() calls (#7686)
* Don't raise `AlreadyDestroyed` error on repeated `destroy()` calls

* Add changelog entry
2025-05-13 09:10:48 +02:00
Zachary HarroldandConnor Fitzgerald f04391d916 [naga]: Add no_std polyfill for round_ties_even for f32 and f64 (#7585)
* Rely on `libm` for a `no_std` alternative to `round_ties_even`

Update comments around `no_std` CI task

* Update Cargo.toml

* Feedback

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-05-08 09:59:19 -04:00
Andy Leiserson 2a924a330a [naga] Ensure test functions in glsl snapshots are reachable from the entry point (#7672) 2025-05-07 15:39:10 -04:00
renovate[bot] 2694b323c8 chore(deps): update crate-ci/typos action to v1.32.0 (#7667)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-05 15:06:23 -04:00
renovate[bot] c505eb5ec7 chore(deps): update cargo.lock (#7668)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-05-05 15:05:35 -04:00
Mehmet Oguz Derin 2a62299a84 Support Sliced 3D for ASTC (#7577)
Enables "texture-compression-astc-sliced-3d" for backends that support ASTC (such as excluding D3D12).
2025-05-04 12:48:16 +02:00
David Lenaerts 50eb207a77 fix(webgpu): Insert fragment constants into fragment descriptor instead of vertex (#7621) 2025-04-30 11:14:17 -04:00
Zachary HarroldandConnor Fitzgerald 285fa48cec [naga]: Switch off of LazyLock to once_cell::racy::OnceBox (#7587)
* Switch off of `LazyLock` to a custom `RacyLock`

* Formatting

* Switch to `OnceBox` internally

* Clippy

* Simplify `trunc` usage

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Switch to `expect`

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Fix expectation conditions

Co-Authored-By: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

* Update documentation

---------

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-04-30 11:12:04 -04:00
Robert Bamler 0d06284d96 Allow wgpu-core to use new naga optimizations for dot4{I, U}8Packed (#7595)
* [wgpu-hal] Use highest available SPIR-V version

* [wgpu-hal] Expose capabilities `DotProductInput*`

* Introduce `{PhysicalDeviceFeatures, PrivateCapabilities}::shader_integer_dot_product`
2025-04-30 11:07:20 +00:00
Andy Leiserson 850c3d4310 [naga] Write only the current entrypoint (#7626)
Changes the MSL and HLSL backends to support writing only a single entry
point, and uses them that way in wgpu-hal.

This is working towards a fix for #5885.

* Increase the limit in test_stack_size
2025-04-30 09:59:41 +02:00
Connor Fitzgerald 9fccdf5cf3 Extract texture <-> buffer copy logic to wgpu-types (#7553) 2025-04-28 21:15:59 +00:00
Robert Bamler bb83976ddb Optimize dot4{I, U}8Packed for all spv versions
Emit optimized code for `dot4{I, U}8Packed` regardless of SPIR-V version
as long as the required capabilities are available. On SPIR-V < 1.6,
require the extension "SPV_KHR_integer_dot_product" for this. On
SPIR-V >= 1.6, don't require the extension because the corresponding
capabilities are part of SPIR-V >= 1.6 proper.
2025-04-28 16:37:45 +02:00
Robert Bamler 065d6546c4 Check for spv language version
When checking for capabilities in SPIR-V,
`capabilities_available == None` indicates that all capabilities are
available. However, some capabilities are not even defined for all
language versions, so we still need to check if the requested
capabilities even exist in the language version we're using.
2025-04-28 16:37:45 +02:00
Robert Bamler 2271480f17 Add intrinsics for dot4{I,U}8Packed to changelog 2025-04-28 16:37:45 +02:00
Robert Bamler 5b20979e9b Use intrinsics for dot4{I, U}8Packed on spv 2025-04-28 16:37:45 +02:00
Robert Bamler fe05765602 Use intrinsics for dot4{I, U}8Packed in HLSL 2025-04-28 16:37:45 +02:00
renovate[bot] 892f629025 chore(deps): update cargo.lock (#7644)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-28 00:41:56 -04:00
Kevin Reid 640e031919 Make BufferSlice's size non-optional. (#7640)
It used to be that `wgpu::Buffer` did not know its own size, and so slices had to potentially not know their endpoints. Now, buffers do, so slices can. This makes the code simpler, without modifying the API.
2025-04-27 16:38:23 +00:00
Connor Fitzgerald 65eb10ed5a Switch cts_runner to clearer no_main style of wasm compat 2025-04-27 18:34:52 +02:00
Connor Fitzgerald 267f14632f Reduce versions to minimum required 2025-04-27 18:34:52 +02:00
Connor Fitzgerald 9c32742dbe Move xtask dependencies into Cargo.toml 2025-04-27 18:34:52 +02:00
Connor Fitzgerald eb4a2b77d7 Bring xtasks back into workspace 2025-04-27 18:34:52 +02:00
Connor Fitzgerald 8235cd2932 Use no_main to allow xtasks to compile on wasm 2025-04-27 18:34:52 +02:00
Connor Fitzgerald fa702f9141 Move everything to workspace dependencies 2025-04-27 18:34:52 +02:00
Wouter de Bruijnandteoxoy 30b247a8d1 [naga glsl-out] Differentiate between support for std140 and std430 (#7579)
* [naga glsl-out] Differentiate between support for `std140` and `std430` layout, and emit `std140` in Uniforms when possible

* [naga glsl-out] Remove storage buffer std140 layout fallback, and error when we are unable to assign an explicit memory layout for uniform and storage globals

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>

---------

Co-authored-by: teoxoy <28601907+teoxoy@users.noreply.github.com>
2025-04-26 13:55:02 +02:00
renovate[bot] 273072d82c chore(config): migrate config renovate.json (#7636)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-26 01:45:07 +00:00
Kevin Reid b93b55920a Expand minimal-versions CI job to cover all packages, use -Zdirect-minimal-versions, but not deny warnings. 2025-04-25 14:40:12 -04:00
Kevin Reid 9727e75ad7 Update Cargo.toml to direct-minimal-versions consistency. 2025-04-25 14:40:12 -04:00
renovate[bot] 82821ae5d1 chore(deps): update rust crate encase to 0.11.0 (#7637) 2025-04-25 17:33:52 +00:00
renovate[bot] 5f3f7028fc chore(deps): update cargo.lock (#7635)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-04-25 14:53:30 +00:00
Mads Marquart 949c5af934 [metal] Do not glob-import enum variants
The `metal` crate is currently unsound regarding unknown/future enum
variants, see https://github.com/gfx-rs/metal-rs/issues/209 and
https://github.com/rust-lang/rfcs/pull/3803.

`objc2-metal` fixes this by emitting C enums as a newtype + constants
for each variant, but that prevents us from importing the
variants/constants. So this commit converts to a pattern that works with
that in preparation for the migration.
2025-04-25 10:26:42 -04:00
Mads Marquart 78a5b22458 [metal] Import prefixed metal items
A lot of Metal types are prefixed with MTL, which makes it quite clear
where they're coming from. This means that we don't loose any clarity if
we import them instead of having them prefixed with `metal::`.

This will make it easier to migrate to `objc2-metal` since that crate is
named differently from the `metal` crate.
2025-04-25 10:26:42 -04:00
Jasper St. Pierre 38b6663f3c validation: Fix type compatibility for streams vs. vertex inputs (#7600)
The old is_compatible_with handled scalar/scalar, scalar/vector, vector/vector, but was missing vector/scalar.

Since is_compatible_with is only used by vertex shader inputs, and vertex shader inputs can't be matrices (only scalars and vectors), we can actually simplify this by removing the other match and just only checking the kind.

Fixes #7568
2025-04-25 15:08:27 +02:00