1345 Commits

Author SHA1 Message Date
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
Connor Fitzgerald
86d5211f84 Add support for running tests on the noop backend 2025-08-01 01:54:01 -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
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
Andy Leiserson
bf86ac3489
Two small vulkan changes (#8001) 2025-07-25 11:16:57 -07: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
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
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
Connor Fitzgerald
979487024e
hal/vulkan: generate separate hash identity for Texture/TextureViews (#7972) 2025-07-21 13:48:37 +02:00
Connor Fitzgerald
ff0de91ad7
Bump REPO_MSRV to 1.88 (#7960) 2025-07-17 13:00:40 -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
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
dc924bc715 Remove unsafe from hal::BufferBinding::new_unchecked 2025-07-10 09:52:20 -07: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
9834d9a446 Revert "Validate binding ranges against buffer size"
This reverts commit ef428fcab8059e898b42542b6445bd94a9683e69.
2025-07-09 16:29:41 -04:00
Andy Leiserson
b0527800a1 Revert "Restore unintentional support for zero-size buffers"
This reverts commit c0a580d6f0343a725b3defa8be4fdf0a9691eaad.
2025-07-09 16:29:41 -04:00
SupaMaggie70Incorporated
18691f5730
Rework of wgpu_hal vulkan buffer importing (#7824)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-07-09 15:19:37 -04:00
Andy Leiserson
c0a580d6f0 Restore unintentional support for zero-size buffers 2025-07-08 14:45:12 -07:00
Andy Leiserson
ef428fcab8 Validate binding ranges against buffer size 2025-07-08 14:45:12 -07:00
teoxoy
e10e17907f remove DeviceError::ResourceCreationFailed 2025-07-02 11:11:37 +02:00
Andy Leiserson
768d5f4879
[metal] Increase MAX_COMMAND_BUFFERS (#7858) 2025-06-27 14:18:40 -04:00
Zachary Harrold
4c39227510
Allow Naga spv-in and spv-out in no_std (#7760)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-06-26 16:45:47 -04:00
Vecvec
0d61648eeb
Allow enabling additional vulkan extensions in Adapter::open and Instance::init (#7829)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-06-26 20:39:41 +00:00
Simon Hausmann
208fe4c23d
Expose the DxgiAdapter in the Hal adapter (#7852) 2025-06-26 16:34:59 -04:00
Andreas Reich
12808193fe
Fix warnings for unrecognized Vulkan present mode (#7850) 2025-06-26 09:33:20 -04:00
Zachary Harrold
995efddc62
Fix portable-atomic on wgpu-hal (#7735) 2025-06-26 08:48:41 +02:00
SupaMaggie70Incorporated
e40e66d205
DXIL & HLSL passthrough (#7831)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-06-25 18:12:58 -04:00
Mendy Berger
4c08c37a46
Expose raw_factory (#7827)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-06-25 19:43:23 +00:00
Vecvec
dc0d457a9a
Add limits for acceleration structures (#7845) 2025-06-25 14:49:55 -04:00
Erich Gubler
9d14871f01
Fix OpenBSD compilation of wgpu_hal::vulkan::drm (#7810) 2025-06-25 18:02:35 +00:00
Andy Leiserson
402a479027
[metal] Retain references with command buffers (#7842) 2025-06-25 11:40:25 -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
Jamie Nicol
ad4286102a [dx12] Return OOM error when GetResourceAllocationInfo() returns SizeInBytes == 0
Some versions of WARP return an allocation info with SizeInBytes == 0
for very large allocations. Proceeding to attempt to allocate a zero-
sized resource results in a device lost error. It's preferable to
instead return an out of memory error.
2025-06-17 09:14:44 -04: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
Xiaopeng Li
65337894f6
Fix texture_from_d3d11_shared_handle compatibility on AMD/Nvidia GPUs (#7782)
* wrapper dedicated allocate info

* comment on why p_next is set manually
2025-06-13 14:48:56 -04:00
Andy Leiserson
82fa8e2a94 [naga] Remove non-essential override references via compaction
Adds a mode to compaction that removes unused functions, global
variables, and named types and overrides. This mode is used
everywhere except the compaction at the end of lowering, where
it is important to preserve unused items for type checking and
other validation of the module.

Pruning all but the active entry point and then compacting makes
`process_overrides` tolerant of missing values for overrides that are
not used by the active entry point.

Fixes #5885
2025-06-12 14:22:18 +09:00
Vecvec
efbac5dfba
Add extra acceleration structure vertex formats. (#7580) 2025-06-11 18:17:14 -04:00
Jim Blandy
41616d9ddf
wgpu_hal::vulkan: Introduce SemaphoreList helper type. (#7749) 2025-06-11 21:01:57 +00:00
Teodor Tanasoaia
e10bceb1dc
[d3d12] increase max_compute_workgroup_storage_size (#7777) 2025-06-09 22:37:07 +02:00
Teodor Tanasoaia
dcada3d858
[d3d12] add a shader cache to avoid calling into DXC/FXC (#7729) 2025-06-05 15:20:51 +02:00
Connor Fitzgerald
24752af93a Suppress VUID-StandaloneSpirv-None-10684 2025-06-04 08:26:11 -07:00
James Ordner
921c6ab597
[metal] remove extraneous main thread check (#7692) 2025-06-02 11:19:49 +02:00
Doublonmousse
1da7cd4811
External gles framebuffer (#7671) 2025-05-30 19:16:47 +00:00