9855 Commits

Author SHA1 Message Date
Lisitsa Nikita
b1bf444b7a
Fix error message when render pipeline vertex attribute location is greater or equal to the maximum number of vertex attributes (fixes #8064) (#8065) 2025-08-09 17:48:11 +02:00
Erich Gubler
f6a3af1f1d refactor(deno_webgpu): remove unused allow(dead_code) on GPUError::Internal 2025-08-09 07:50:51 -04:00
Erich Gubler
495df81f14 fix(deno_webgpu): expose GPUUncapturedErrorEvent in bootstrap.js 2025-08-09 07:50:51 -04:00
Erich Gubler
1241bb0384 fix(deno_webgpu): expose GPUInternalError in bootstrap.js 2025-08-09 07:50:51 -04:00
Bot-Kerem
e990388af9
Update README.md (#8069) 2025-08-08 23:58:57 +01:00
Andy Leiserson
605f40d866 Vendor web-sys 2025-08-08 23:58:25 +01:00
Andy Leiserson
7816390566 Make vendor-web-sys xtask accept a SHA
Also, update wasm-bindgen URLs
2025-08-08 23:58:25 +01:00
Erich Gubler
0c30efe857
docs(release-checklist): sync backporting label name with current one (#8062) 2025-08-08 23:50:26 +01:00
Andy Leiserson
24a05fefdf
Update CHANGELOG (#8050) 2025-08-07 18:01:45 -07:00
Jamie Nicol
1bf1671ed8 [test] Add external texture GPU tests
These tests cover the external texture binding resource. They ensure
the WGSL functions `textureDimensions()`, `textureLoad()`, and
`textureSampleBaseClampToEdge()` work as expected for both
`TextureView`s and `ExternalTexture`s bound to external texture
resource bindings.

For external textures, they ensure multiplanar YUV formats work as
expected including handling color space transformation. And that the
provided sample and load transforms correctly handle cropping,
flipping, and rotation.
2025-08-06 17:31:50 +02:00
Jamie Nicol
bd85c9a99a [test] Rename existing external_texture tests to external_image_copy
These existing tests cover `Queue::copy_external_image_to_texture()`
which, despite the similar name, is unrelated to the external texture
binding resource.

The following patch is going to add some tests for the latter, so we
are taking this opportunity to rename the former to help avoid
confusion.
2025-08-06 17:31:50 +02:00
Jamie Nicol
b3a3dc33b6 [dx12] Support external textures on DX12
This implements the DX12 HAL part of external texture support, which is
the final piece of the puzzle for external textures on DirectX 12.

When creating a pipeline layout, HAL is responsible for mapping a
single BindingType::ExternalTexture bind group entry to multiple
descriptor ranges in the root signature it creates: 3 SRVs (one for
each texture plane) and a CBV for the parameters buffer. Additionally
we must expose the additional bindings to the Naga backend via the
`external_texture_binding_map`. Lastly, when creating a bind group we
write the descriptors for each of these bindings to the heap.

And with that, we can finally enable the `EXTERNAL_TEXTURE` feature
for the dx12 backend.
2025-08-06 17:31:50 +02:00
Erich Gubler
b5385225ab
fix(core): validate effective buf. binding size is aligned to 4 (#8041)
The WebGPU spec. `createBindGroup` [states][spec-ref] (emphasis mine):

> Device timeline initialization steps:
>
> …
>
> 2. If any of the following conditions are unsatisfied generate a
>    validation error, invalidate _bindGroup_ and return.
>
>    …
>
>    For each `GPUBindGroupEntry` _bindingDescriptor_ in
>    _descriptor_.`entries`:
>
>    - …
>
>    - If the defined binding member for _layoutBinding_ is:
>
>      - …
>
>      - `buffer`
>
>        - …
>
>        - If _layoutBinding_.`buffer`.`type` is
>
>          - …
>
>          - `"storage"` or `"read-only-storage"`
>
>            - …
>
>            - effective buffer binding size(_bufferBinding_) is a multiple of 4.

[spec-ref]: https://www.w3.org/TR/webgpu/#dom-gpudevice-createbindgroup

We were not implementing this check of effective buffer binding size.
Check that it's a multiple of 4, including
`webgpu:api,validation,createBindGroup:buffer,effective_buffer_binding_size:*`
that this is now implemented as intended.
2025-08-06 16:19:08 +02:00
Jamie Nicol
8cd4bd602f [naga hlsl-out] Handle external texture color space conversion
This adds several fields to `ExternalTextureDescriptor`, specifying
how to handle color space conversion for an external texture. These
fields consist of transfer functions for the source and destination
color spaces, and a matrix for converting between gamuts. This allows
`ImageSample` and `ImageLoad` operations on external textures to
return values in a desired destination color space rather than the
source color space of the underlying planes.

These fields are plumbed through to the `ExternalTextureParams`
uniform buffer from which they are exposed to the shader. Following
conversion from YUV to RGB after sampling/loading from the external
texture planes, the shader uses them to gamma decode to linear RGB in
the source color space, convert from source to destination gamut, then
finally gamma encode to non-linear RGB in the destination color space.
2025-08-06 11:18:42 +01:00
Erich Gubler
88a8147194
test(deno_webgpu): add --release to cargo xtask cts (#8053) 2025-08-05 19:35:20 -04:00
Andy Leiserson
910143d622
Check for more cases of unbalanced debug groups (#8048)
Fixes #3911
2025-08-05 16:52:50 +02:00
atlv
7cb642eba7
fix STATUS_HEAP_CORRUPTION crash in create_sampler (#8043)
Co-authored-by: Erich Gubler <erichdongubler@gmail.com>
2025-08-05 14:43:54 +00:00
Vecvec
a1168613d2
Prevent resources for acceleration structures being created if they are not enabled (#8036)
* Prevent resources for acceleration structures being created if acceleration structures aren't supported.
2025-08-04 09:37:09 -07:00
renovate[bot]
4938f86cfe
Update Cargo.lock (#8045)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-04 09:29:57 -07:00
renovate[bot]
fe22fe2bf2
Update cts digest to a46bb82 (#8044)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-04 09:28:36 -07:00
Connor Fitzgerald
3e153fb8ec Label no-op supporting tests 2025-08-01 01:54:01 -04:00
Connor Fitzgerald
09d0c94576 Use explicit test enumeration 2025-08-01 01:54:01 -04:00
Connor Fitzgerald
86d5211f84 Add support for running tests on the noop backend 2025-08-01 01:54:01 -04:00
Connor Fitzgerald
fdc4d421e7 Add cargo xtask miri 2025-08-01 01:54:01 -04:00
Connor Fitzgerald
df40889e1b Prepare for miri 2025-08-01 01:54:01 -04:00
Andy Leiserson
f25a79595a
Add a missing condition to viewport validation (#8040) 2025-08-01 01:10:15 -04:00
sagudev
45e96e593f
docs: Fix comment in COPY_BYTES_PER_ROW_ALIGNMENT to include copy_texture_to_buffer (#8029) 2025-07-31 16:05:05 -04:00
Connor Fitzgerald
58b6135872
hal/vulkan: Clear framebuffer cache during command buffer reset (#8031) 2025-07-30 19:58:08 -04:00
Jamie Nicol
59f815a9b9 [naga] Have validation reject shaders containing binding arrays of external textures
For simplicity's sake our initial implementation of external textures
will not support binding arrays of external textures. We should
therefore reject any shaders which use them during validation.

Their implementation will be tracked in #8027.

naga/src/valid/type.rs JJ: JJ: Lines starting with "JJ:" (like this
one) will be removed.
2025-07-30 14:33:00 -07:00
Jamie Nicol
e1ccb6632c [naga hlsl-out] Implement external texture support
This adds HLSL backend support for `ImageClass::External` (ie WGSL's
`external_texture` texture type).

For each external texture global variable in the IR, we declare 3
`Texture2D` globals as well as a `cbuffer` for the params. The
additional bindings required by these are found in the newly added
`external_texture_binding_map`. Unique names for each can be obtained
using `NameKey::ExternalTextureGlobalVariable`.

For functions that contain ImageQuery::Size, ImageLoad, or ImageSample
expressions for external textures, ensure we have generated wrapper
functions for those expressions. When emitting code for the
expressions themselves, simply insert a call to the wrapper function.

For size queries, we return the value provided in the params
struct. If that value is [0, 0] then we query the size of the plane 0
texture and return that.

For load and sample, we sample the textures based on the number of
planes specified in the params struct. If there is more than one plane
we additionally perform YUV to RGB conversion using the provided
matrix.

Unfortunately HLSL does not allow structs to contain textures, meaning
we are unable to wrap the 3 textures and params struct variables in a
single variable that can be passed around.

For our wrapper functions we therefore ensure they take the three
textures and the params as consecutive arguments. Likewise, when
declaring user-defined functions with external texture arguments, we
expand the single external texture argument into 4 consecutive
arguments. (Using NameKey::ExternalTextureFunctionArgument to ensure
unique names for each.)

Thankfully external textures can only be used as either global
variables or function arguments. This means we only have to handle the
`Expression::GlobalVariable` and `Expression::FunctionArgument` cases
of `write_expr()`. Since in both cases we know the external texture
can only be an argument to either a user-defined function or one of
our wrapper functions, we can simply emit the names of the variables
for each three textures and the params struct in a comma-separated
list.
2025-07-30 14:33:00 -07:00
Jamie Nicol
0448b46033 [naga] Reserve names for each plane and params buffer of external texture
Adds new `NameKey` variants `ExternalTextureGlobalVariable` and
`ExternalTextureFunctionArgument`, like their non-external-texture
cousins but additionally keyed by either being a specific plane index
or params buffer.

For each external texture global variable or function argument reserve
additional names for 3 planes and the params buffer. For Naga backends
which must represent external textures as multiple variables/arguments,
this will allow them to uniquely name each one.
2025-07-30 14:33:00 -07:00
Jamie Nicol
9f654c6235 [naga] Generate special type for external texture params buffer
During wgsl lowering, if we encounter an external texture type then
generate the `ExternalTextureParams` struct. This will be required by
most Naga backends to implement external textures.

This type is not actually used by wgsl-in or the IR. However,
generating it in Naga IR ensures tricky details such as member
alignment are handled for us.

wgsl-out must ensure it does *not* generate code for this type, as it
handles external textures natively.
2025-07-30 14:33:00 -07:00
Andy Leiserson
36ae215e9c
Fix image copy regressions (#8022)
* Restore allowance of unaligned buffer-texture copies

This fixes a regression introduced by #7948. However, it makes it
possible to reach a panic in initialize_buffer_memory if the copy
requires initializing a region of memory that is not 4B aligned.

* Fix CopyT2T of multi-layer depth/stencil textures

* Adjust test list
2025-07-30 14:35:12 +02:00
Andy Leiserson
5089063048
Allow copying one layer of depth/stencil textures (#8020)
This fixes a regression introduced by #7935.
2025-07-29 10:18:26 -07:00
Andy Leiserson
1583c2481a
Another fix for texture copy validation (#8019) 2025-07-28 22:19:17 -04:00
renovate[bot]
747384493d
Update Cargo.lock (#8017)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-28 11:38:57 -04:00
renovate[bot]
d913042f1d
Update Rust crate criterion to 0.7 (#8016)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-28 11:38:48 -04:00
renovate[bot]
ec1ab06bff
Update cts digest to e110f5e (#8015)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-28 11:38:26 -04:00
Andy Leiserson
bf86ac3489
Two small vulkan changes (#8001) 2025-07-25 11:16:57 -07:00
SupaMaggie70Incorporated
d8b7e81a02
Updated mesh shader limits to be llvmpipe compatible (#8004)
Co-authored-by: Andy Leiserson <aleiserson@mozilla.com>
2025-07-25 00:05:12 -04:00
SupaMaggie70Incorporated
074c0e7191
Add mesh shading api to wgpu & wgpu-core (#7345) 2025-07-24 20:58:56 -04:00
Florian Denis
68a10a01d9
[egl] Fix robust context creation failing on some devices (#7952) 2025-07-24 18:31:36 -04:00
Connor Fitzgerald
4bd0f751f8
Backport changelog from v26.0.2 (#7999) 2025-07-24 17:52:11 -04:00
Jim Blandy
dbe64a769b
[naga hlsl-out] Fix odd name for a Handle<GlobalVariable>. (#7996) 2025-07-23 16:48:49 -04:00
Jim Blandy
2fcd41377c
[naga] Make Naga tests build when no features are enabled. (#7989) 2025-07-23 12:09:45 -04:00
Lucas Abel
b8c462ac31
[core] fix missing applies of DISCARD_HAL_LABELS (#7991) 2025-07-23 12:06:42 -04:00
Jim Blandy
d9a6b4fa4a [naga, wgpu-core] Add some docs for Naga validator creation. 2025-07-23 08:51:13 -07:00
Andy Leiserson
1c43ac2c42
Additional validation of buffer-texture copies (#7948)
* Additional validation of buffer-texture copies

Fixes #7936, but leaves a TODO for #7947

* Skip tests failing on dx12

* Update comments and change unwrap_or to expect
2025-07-23 17:39:42 +02:00
Lucas Abel
ffd59691e0
[webgpu] fix device loss callback to be immediately drop (#7992) 2025-07-23 15:32:38 +00:00
Jamie Nicol
f8756a6e1b [wgpu] Add external texture validation tests
Adds validation tests using the noop backend covering creation of
external textures, and creation of bind groups containing external
textures.
2025-07-22 15:38:15 -07:00