669 Commits

Author SHA1 Message Date
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
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
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
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
Connor Fitzgerald
ff0de91ad7
Bump REPO_MSRV to 1.88 (#7960) 2025-07-17 13:00:40 -04:00
Connor Fitzgerald
e5b10e07e8 Adjust InstanceDescriptor docs 2025-07-16 15:10:00 -04:00
Jim Blandy
c51fe577dc
Improve docs for wgpu_types::InstanceFlags::VALIDATION. (#7939) 2025-07-13 01:04:19 -04:00
Andy Leiserson
c868142709
Validate vertex and index buffer alignment (#7929) 2025-07-11 14:43:03 -07: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
Andy Leiserson
468632f207 Restore plumbing of implicit remainder-of-buffer size to backends 2025-07-10 09:52:20 -07:00
Andy Leiserson
27e7408f16 Restore the buffer size changes 2025-07-10 09:52:20 -07:00
Andy Leiserson
b0527800a1 Revert "Restore unintentional support for zero-size buffers"
This reverts commit c0a580d6f0343a725b3defa8be4fdf0a9691eaad.
2025-07-09 16:29:41 -04:00
Andy Leiserson
c0a580d6f0 Restore unintentional support for zero-size buffers 2025-07-08 14:45:12 -07:00
Andy Leiserson
3d0fe3a003 Check the math for buffer-texture copies 2025-07-08 12:11:56 -07:00
Andy Leiserson
b695317a9b
Rg11b10ufloat should be resolvable when it is renderable (#7878) 2025-07-03 17:51:48 -04:00
teoxoy
918fdc98b5 remove reason from ErrorType::DeviceLost since it's always "unknown" and users should register the lost callback instead 2025-07-02 11:11:37 +02:00
Erich Gubler
7ff0bd784e fix!: remove WebGpuError impl. for Request{Adapter,Device}Error 2025-06-30 10:58:56 -04:00
Erich Gubler
964c5bbf4c feat(core): impl WebGpuError for API errors 2025-06-30 10:58:56 -04:00
Erich Gubler
c8752e5118 feat(types): add error::{ErrorType, WebGpuError} APIs 2025-06-30 10:58:56 -04:00
Erich Gubler
c3922d53d7 docs(types): Make docs. on DeviceLostReason variants less terse 2025-06-30 10:58:56 -04:00
SupaMaggie70Incorporated
e40e66d205
DXIL & HLSL passthrough (#7831)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-06-25 18:12:58 -04:00
Vecvec
dc0d457a9a
Add limits for acceleration structures (#7845) 2025-06-25 14:49:55 -04:00
Jamie Nicol
8cdbcc1755 Add ExternalTexture BindingType behind new Feature flag
Adds a new feature flag, `EXTERNAL_TEXTURE`, indicating device support
for our implementation of WebGPU's `GPUExternalTexture` [1] which will
land in upcoming patches. Conceptually this would make more sense as a
downlevel flag, as it is a core part of the WebGPU spec which we do not
yet support. We do not want, however, to cause applications to reject
adapters because we have not finished implementing this, so for now we
are making it an opt-in feature.

As an initial step towards supporting this feature, this patch adds a
new `BindingType` corresponding to WebGPU's
`GPUExternalTextureBindingLayout` [2]. This binding type dictates that
when creating a bind group the corresponding entry must be either an
external texture or a texture view with certain additional requirements
[3].

As of yet wgpu has no concept of an external texture (that will follow
in later patches) but for now this patch ensures that texture views
corresponding to an external texture binding type are validated
correctly. Note that as the feature flag is not yet supported on any
real backends, bind group layout creation will fail before getting the
chance to attempt to create a bind group. But in the added tests using
the noop backend we can see this validation taking place.

[1] https://www.w3.org/TR/webgpu/#gpuexternaltexture
[1] https://www.w3.org/TR/webgpu/#dictdef-gpuexternaltexturebindinglayout
[2] https://gpuweb.github.io/gpuweb/#bind-group-creation
2025-06-17 15:00:29 -07:00
Dmitry Zamkov
bbb7cc79ef
Implement clip-distances extension for GL and Vulkan backends (#7730)
* Basic implementation of `clip_distances` for Vulkan and GL backends

* Added GPU test for `clip-distances`

* Update feature array size

* Add changelog entry

* Validate `clip_distances` array size

* Check for `clip_distances` enable directive

* Consolidate code for generating `enable` directives in WGSL backend and add `clip_distances`.
2025-06-16 10:33:31 +02:00
Erich Gubler
cf83de3a5d
chore!: remove deprecated type aliases for idents. in 2024-08 spec. rename (#7790)
This backs out commit 9436d56271c6f3141ee5da882355ea45784c446c.
2025-06-12 09:55:00 -04:00
Vecvec
73eb83ded1
[wgpu] Blas compaction (#7285)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-06-11 21:40:10 -04:00
Vecvec
efbac5dfba
Add extra acceleration structure vertex formats. (#7580) 2025-06-11 18:17:14 -04:00
andristarr
0e1baff277
Navigatable docs for BufferUsages::MAP_WRITE (#7742) 2025-06-01 20:22:56 +09:00
Raphael Hetzel
0d569d5550
Optional web-specific deps for wasm32 (#7565) 2025-05-29 22:26:01 +00:00
Dmitry Zamkov
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
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
Connor Fitzgerald
9fccdf5cf3
Extract texture <-> buffer copy logic to wgpu-types (#7553) 2025-04-28 21:15:59 +00:00
Florian Denis
1806414771
[wgpu-types]: Expose wgpu::Limits::defaults() (#7622) 2025-04-24 09:56:14 -04:00
teoxoy
3b72d59a3c make memory pressure detection optional and configurable 2025-04-22 09:21:27 +02:00
Teodor Tanasoaia
6ea7962da7
[d3d12] remove the need for dxil.dll (#7566) 2025-04-17 16:21:36 +02:00
teoxoy
edbadd2b99 expand on InstanceFlags::VALIDATION_INDIRECT_CALL docs 2025-04-15 17:56:17 +02:00
teoxoy
45d78e2fb4 remove DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW 2025-04-15 17:56:17 +02:00
Connor Fitzgerald
45d8f42513 Use workspace package information everywhere 2025-04-10 20:41:28 -04:00
Connor Fitzgerald
8c2c2ce203
Release v25 (#7505) 2025-04-10 16:13:02 +00:00
Sylvain Benner
14690470bb
[metal] Metal compute shader passthrough (#7326)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-04-09 14:25:41 +00:00
Connor Fitzgerald
460eff4866 [d3d12] Always associate a size with an allocation 2025-04-07 21:03:43 -04:00
Connor Fitzgerald
6a986f4bc4 Timestamp normalization 2025-04-03 10:35:20 -04:00
teoxoy
2ab3b6da8d guarantee DownlevelFlags::COMPUTE_SHADERS when DownlevelFlags::INDIRECT_EXECUTION is enabled 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
Connor Fitzgerald
4687973c9a
Use bytemuck instead of slice::from_raw_parts for transmutes (#7376) 2025-03-19 22:05:21 -04:00
Christopher Fleetwood
c6286791fe
feat: implement F16 support in shaders (#5701)
Co-authored-by: FL33TW00D <fleetwoodpersonal@gmail.com>
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
Co-authored-by: ErichDonGubler <erichdongubler@gmail.com>
2025-03-19 16:26:50 +00:00
SupaMaggie70Incorporated
e8ce3ae973
Add mesh shader stages to wgt::ShaderStages and naga::ShaderStage (#7292)
* Initial changes

* Fixed metal backend in wgpu-hal, ran tests
2025-03-15 05:34:20 +00:00
Kevin Reid
029bdb107a docs: Add links and examples for VertexAttribute and friends.
* Added “upward” links from `VertexAttribute` and `VertexBufferLayout`
  to the places they are used.
* Documented the exact expected inputs of `vertex_attr_array!` and hid
  the internal implementation.
* Added doc-test examples for:
    * `VertexBufferLayout`, demonstrating how to construct a
      `VertexBufferLayout` that corresponds to a `struct`.
    * `vertex_attr_array!`, demonstrating exactly what the output of the
      macro is.
2025-03-14 18:31:30 -04:00
Kevin Reid
fbe005f11a Make request_adapter() report which backends were tried.
This will help users determine whether the problem is:

* a backend is not statically enabled
* a backend is not dynamically enabled
* no drivers or physical adapters are present for that backend
  (further distinction would be useful here)
* no adapters met the required criteria

There are deficiencies in the reporting of WebGPU vs. WebGL support.
Those would best be fixed by also fixing the mutual exclusion of those
backends.
2025-03-14 11:45:49 +01:00