9805 Commits

Author SHA1 Message Date
Jamie Nicol
7087f0c01f [wgpu-core] Allow creation of bind groups containing external textures
Adds a `BindingResource` variant for external textures. In core's
create_bind_group() implementation, allow binding either external
textures or texture views to `BindingType::ExternalTexture` layout
entries.

In either case, provide HAL with a `hal::ExternalTextureBinding`,
consisting of 3 `hal::TextureBinding`s and a `hal::BufferBinding`. In
the texture view case we use the device's default params buffer for
the buffer. When there are fewer than 3 planes we can simply repeat an
existing plane multiple times - the contents of the params buffer will
ensure the shader only accesses the correct number of planes anyway.

Track the view or external texture in `BindGroupStates` to ensure they
remain alive whilst required.

And finally, add the corresponding API to wgpu, with an implementation
for the wgpu-core backend.
2025-07-22 15:38:15 -07:00
Jamie Nicol
d263b1875d [wgpu-core] Create default ExternalTextureParams buffer
In upcoming patches, wgpu will allowing the creation of bind groups
with either `TextureView`s or `ExternalTexture`s bound to a
`BindingType::ExternalTexture` bind group layout entry.

Wgpu-hal and the Naga-generated shaders must be able to handle both of
these cases. For external textures they will be provided a uniform
buffer containing the external texture's `ExternalTextureParams`. For
the texture view case, we must therefore provide the same.

To do this, we create a single buffer per device which can be shared
between all texture views. We initialize it with the required values
in Device::late_init_resources_with_queue(). We know that texture
views must have a single RGBA plane, with no rotation or
crop-rect. The only thing that can vary between them is their size. We
will therefore use the value of [0, 0] in the params buffer to
indicate to the shader that it should query the actual texture's size
rather than using the value provided in the buffer.
2025-07-22 15:38:15 -07:00
Jamie Nicol
acfa8c5776 [wgpu-core] Add ExternalTexture type to wgpu-core
`ExternalTexture` will form the basis of wgpu's implementation of
WebGPU's `GPUExternalTexture`. [1]

The application will be responsible for creating `Texture`(s) and
`TextureView`(s) from the external texture source and managing their
lifecycle. It may have a single RGBA texture, or it may have multiple
textures for separate Y and Cb/Cr planes. It can then create an external
texture by calling `create_external_texture()`, providing the texture
views and a descriptor. The descriptor provides the following required
information:

  * Whether the texture data is RGBA, or multiplanar or interleaved
    YCbCr.
  * The purpoted size of the external texture, which may not match the
    actual size of the underlying textures.
  * A matrix for converting from YCbCr to RGBA, if required.
  * A transform to apply to texture sample coordinates, allowing for
    rotation and crop rects.

The external texture stores a reference to the provided texture views,
and additionally owns a `Buffer`. This buffer holds data of the type
`ExternalTextureParams`, and will be provided as a uniform buffer to
shaders containing external textures. This contains information that
will be required by the shaders to handle external textures correctly.

Note that attempting to create an external texture will fail unless the
`Feature::EXTERNAL_TEXTURE` feature is enabled, which as of yet is not
supported by any HAL backends.

Additionally add the relevant API to wgpu, implemented for the
wgpu-core backend. The web and custom backends are unimplemented.

[1] https://www.w3.org/TR/webgpu/#gpuexternaltexture
2025-07-22 15:38:15 -07:00
Jamie Nicol
43a4d53107
[naga wgsl-in wgsl-out] WGSL support for texture_external texture type (#7822)
* [naga wgsl-in wgsl-out] WGSL support for texture_external texture type

Make wgsl-in correctly parse `texture_external` texture declarations,
and allow such textures to be used in `textureDimensions()`,
`textureSampleBaseClampToEdge()`, and `textureLoad()` function
calls. In IR these are represented by the `ImageClass::External` image
class, which is a 2D, non-multisampled, non-mipmapped, float-sampled
image.

Adds a new Capability `TEXTURE_EXTERNAL` and ensure validation rejects
shaders containing external textures if this capability flag is not
set. This capability is enabled for validation by wgpu devices which
support the `TEXTURE_EXTERNAL` feature (currently only when using the
noop backend), and by the Naga CLI when validating-only or when
outputting WGSL.

The WGSL backend can of course emit `ImageClass::External` images
directly as `texture_external` textures. Other backends are, for now,
unimplemented.

Lastly, we add a snapshot test covering all the valid uses of a
texture_external texture. These are:
  - As a global variable declaration
  - As an argument to the built-in functions `textureDimensions()`,
    `textureSampleBaseClampToEdge()`, and `textureLoad()`
  - As an argument to user-defined function declarations and calls.

We keep these in their own test so that we can control which targets
to run them against (currently WGSL and IR). When external textures
are supported by all Naga backends we can, if so inclined, integrate
these with existing texture tests.

* fixup! [naga wgsl-in wgsl-out] WGSL support for texture_external texture type

* fixup! [naga wgsl-in wgsl-out] WGSL support for texture_external texture type

---------

Co-authored-by: Jim Blandy <jimb@red-bean.com>
2025-07-22 14:38:32 -07:00
Andy Leiserson
4a00b62651
[player] Support specifying a trace file directly (#7982)
Also provide a default initialization if the trace does not contain one.
2025-07-22 11:56:21 -07:00
Andy Leiserson
381932c601 Add CommandEncoderStatus::Consumed 2025-07-22 16:19:18 +02:00
teoxoy
b8c5c4add4 rename cmd_buf to cmd_enc where appropriate 2025-07-22 16:19:18 +02:00
teoxoy
63f3df86c8 [wgpu-core] split command encoders from command buffers 2025-07-22 16:19:18 +02:00
Connor Fitzgerald
83badd52ab hal/vulkan: use different indexes for acquire and present 2025-07-22 09:39:06 -04:00
Connor Fitzgerald
c5efc89b08 hal/vulkan: add debug names to all swapchain semaphores 2025-07-22 09:39:06 -04:00
Andy Leiserson
f5d8a0a06a
Additional validation of texture copies (#7935)
* Additional validation of texture copies

 * Copies must not overlap.
 * Copies of multisampled or depth/stencil formats must span
   the entire texture.
 * Move no-op for zero-size copies after parameter validation.

Closes #2951
Fixes #7844

* Fix issue with combined depth+stencil copy on dx12

* PR feedback
2025-07-22 15:17:47 +02:00
Connor Fitzgerald
601c4238b3
Update CI triggers (#7983) 2025-07-21 22:56:42 +00:00
Andy Leiserson
942e59eabc
[naga] Enforce a maximum size for any type (#7950)
* [naga] Enforce a maximum size for any type

Fixes #4339
Fixes #7383

* Doc fix and changelog entry
2025-07-21 13:52:50 +02:00
Andy Leiserson
2c81896e85
Small changes to facilitate fuzzing (#7970) 2025-07-21 13:51:57 +02:00
Connor Fitzgerald
979487024e
hal/vulkan: generate separate hash identity for Texture/TextureViews (#7972) 2025-07-21 13:48:37 +02:00
renovate[bot]
c95b7feea8 chore(deps): update cargo.lock 2025-07-21 13:34:57 +02:00
renovate[bot]
712ab8dec2
chore(deps): update cts digest to 7bdef02 (#7975)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-20 22:48:01 -04:00
Connor Fitzgerald
96ef5ecaa4
ci: reduce log spam on wasm (#7966) 2025-07-18 16:21:15 -04:00
Teodor Tanasoaia
d2f8c44ac6
[wgpu-core] remove implicit PL & BGL IDs from pipeline creation (#7967) 2025-07-18 13:04:46 -04:00
renovate[bot]
4ef4f5dfbe chore(deps): update dependency ubuntu to v24 2025-07-18 13:02:48 -04:00
renovate[bot]
cf4a74c6b9 chore(deps): update deps and deny file 2025-07-18 13:02:48 -04:00
Connor Fitzgerald
232d46509b
ci: only allow one set of jobs per PR (#7958) 2025-07-17 21:12:30 -04:00
Andy Leiserson
5d14f33259
Test for use of staging buffer in writeTexture (#7963) 2025-07-17 18:52:51 -04:00
Andy Leiserson
9a596fa1dc
Fix warnings from the nightly Rust compiler (#7964) 2025-07-17 16:08:06 -04:00
Connor Fitzgerald
ff0de91ad7
Bump REPO_MSRV to 1.88 (#7960) 2025-07-17 13:00:40 -04:00
Teodor Tanasoaia
33b9f86cc4
Fix detection of local_invocation_id for zero initialization of workgroup memory (#7962) 2025-07-17 12:47:59 -04:00
Erich Gubler
76dba55e8d
style(vulkan): no trailing space after raytrace cap. negotiation (#7954) 2025-07-16 17:16:29 -04:00
Connor Fitzgerald
49b773fde2 Add some documentation to wgpu-hal types 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
1ed61877b5 Remove wgpu_core::hal_api::HalApi 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
0dbe5fb28e Add annotations for the types hal types return 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
81b3e7ce14 Rearrange methods on Instance 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
e5b10e07e8 Adjust InstanceDescriptor docs 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
f7b672f28b Update release checklist 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
f83af61f74 Clarify naga psuedo-feature in wgpu 2025-07-16 15:10:00 -04:00
Connor Fitzgerald
15f7c7e561 Remove unneeded comment 2025-07-16 15:10:00 -04:00
Lucas Abel
13d0cd4d58
[core] fix invalid read in Queue::write_texture (#7893) 2025-07-16 09:49:03 -07:00
Andy Leiserson
1da2177547
Add skip conditions to CTS runner (#7949) 2025-07-15 10:06:11 -07:00
SupaMaggie70Incorporated
dd50e56c59
Update rspirv version (#7945) 2025-07-15 00:51:31 -04:00
Connor Fitzgerald
4572e05bfa
ci: add coverage for cts (#7942) 2025-07-14 12:48:49 -04:00
renovate[bot]
9872df55d7
Update cts digest to 6e9d87b (#7941)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-14 02:50:23 -04:00
Jim Blandy
c51fe577dc
Improve docs for wgpu_types::InstanceFlags::VALIDATION. (#7939) 2025-07-13 01:04:19 -04:00
Andy Leiserson
1b4eca97cf [naga hlsl-out] Factor out some repetitive code 2025-07-11 16:55:46 -07:00
Andy Leiserson
bfa7ee8de5 [naga hlsl-out] Handle additional cases of Cx2 matrices
Fixes #4423
2025-07-11 16:55:46 -07:00
Andy Leiserson
c868142709
Validate vertex and index buffer alignment (#7929) 2025-07-11 14:43:03 -07:00
Andy Leiserson
ae946dbb8c
Use backwards-compatible options to git config (#7934) 2025-07-11 16:20:13 -04:00
renovate[bot]
5b2c8406bf
chore(deps): update cts digest to 18fcd81 (#7923)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-10 18:57:33 -04:00
Connor Fitzgerald
085eaa60e8
Forward port v26.0.1 changelog (#7921) 2025-07-10 18:42:49 -04:00
Vecvec
4844fa6b5e
Merge acceleration structure feature and ray query feature. (#7913)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-07-10 19:53:32 +00:00
Erich Gubler
166c2ea2aa
fix(core): check query set index before other validation (#7908) 2025-07-10 19:04:37 +00:00
Kevin Reid
b83c9cfd57 Fix initialize_adapter_from_env under no_std.
Without this change, `desired_adapter_name` is an undeclared variable.
2025-07-10 14:43:26 -04:00