1397 Commits

Author SHA1 Message Date
Christian Legnitto
09a641bdf4 Fix include_spirv_raw macro (#7503) 2025-04-09 20:56:22 -04:00
Vecvec
1c4b73c098 Implement as_hal for BLASes and TLASes (#7303) 2025-04-09 14:50:43 -04: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
c860a2cf8c Rename and unsafe start_capture -> start_graphics_debugger_capture (#7470)
* Improve `start_capture` docs

* Docs
2025-04-03 13:07:22 -04:00
Connor Fitzgerald
a9279de793 Fix assorted issues with WebGL (#7448)
* Fix validation error when configuring the surface on WebGL

* Remove unneeded `webgl` feature

* Fix compilation of the `noop` backend on `wasm32`

* Prevent `webgpu` examples from incorrectly falling back to WebGL

* Reduce dependency set when building wasm examples

* Fix various warnings
2025-03-31 22:02:21 -04:00
Christian Legnitto
1ef9940114 Reduce repo MSRV from 1.85 to 1.84 (#7425)
* Reduce repo MSRV from 1.85 to 1.84

Fixes https://github.com/gfx-rs/wgpu/issues/7409

* Replace usage of task::Waker::noop()

* Gate waker code to `noop` feature

* Remove unused copied waker function

* Remove doctest from copied code
2025-03-27 14:25:19 -04: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
sagudev
94dd3a7dc7 Fix some cfg guards (#7418)
All guards should actually refer to `wgpu_core` instead of `native`

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-03-25 08:25:59 -04:00
Bruce Mitchener
f89ede7cd8 [doc] Fix unbalanced backticks (#7385) 2025-03-21 03:03:37 +00:00
Kevin Reid
03ab3a27d8 Make buffer mapping example runnable and remove obsolete Arc. 2025-03-14 20:59:28 -04:00
Kevin Reid
fcac8a9b28 Add Device::noop().
This is a useful shortcut for tests and example code, allowing it to
create a noop device without needing to deal with nonexistent
fallibility and asynchrony.
2025-03-14 20:59:28 -04:00
Dawid Sz.
21e7f3f102 Remove Arc from buffer in util::DownloadBuffer (#7341) 2025-03-14 18:34:41 -04: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
Kevin Reid
a369bfa8d1 Revise documentation for write_buffer(), write_buffer_with(), and write_texture().
* Add `# Performance considerations` heading, to separate the facts
  about how to use the method from the advice about how best to use the
  method.

  Back when I was learning `wgpu`, I thought that “does *not* submit the
  transfer to the GPU immediately” was a claim about *ordering* relevant
  to correctness, not just performance. This reorganization and
  rewording should help future readers build an accurate model quicker.

* Clarify when it is best to use `write_buffer_with()` — in particular,
  if you just copy from other memory, then you aren't making any
  improvement over `write_buffer()`, and the advantage comes from being
  able to assemble your data in-place.

* Flesh out the first `queue.submit([])` example code block,
  and trim back the second one.

* Mention what techniques you might use for writing to a texture other
  other than `write_texture()`.
2025-03-14 11:33:39 +01:00
Kevin Reid
326ad03ce1 Move trace_dir/trace_path to a custom enum inside DeviceDescriptor.
This allows `wgpu` to not unconditionally depend on `std::path::Path`.
It’s also, in my opinion, more user-friendly, because the feature which
most users will not use (and is not currently functional) is now a
defaultable struct field instead of a required parameter.

The disadvantage is that `wgpu-types` now has to know about tracing.
2025-03-10 22:17:06 -04:00
Andreas Reich
fedc80eb80 [wgsl-in, wgsl-out, glsl-in] WebGPU compliant dual source blending feature (#7146)
Makes the dual source implementation in wgpu WebGPU spec compliant.
Furthermore, makes the dual source blending extension available when targeting WebGPU.
2025-03-08 21:07:37 +01:00
Kevin Reid
7319512778 Additional documentation for buffer mapping, types, and constants. (#7283)
* Additional documentation for buffer mapping, types, and constants.

* Clarify `Snorm` texture format conversion.

* Fix typo.
2025-03-06 19:08:34 +00:00
Bruce Mitchener
e446551b27 docs: Improve linking, backticks (#7281) 2025-03-06 12:37:19 -05:00
Marc Pabst
38f3c47a46 Add as_hal for Queue (#7182)
* add as_hal for Queue

* add as_raw for dx12 queue

* return Mutex + add as_raw for Vulkan

* return reference

* restore Cargo.lock

* fix  Cargo.lock

---------

Co-authored-by: Marc Pabst <“marcpabst@users.noreply.github.com”>
2025-03-04 21:24:06 +00:00
Samson
7e66495049 Support extern context impl (#6658)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-03-04 16:07:03 -05:00
Matilde Morrone
7eb69f43b6 Add DRM support to Vulkan backend (#7212)
* Add basic drm support to vulkan backend

* Move vulkan drm implementation to its own module

* Properly feature gate drm support and add safety docs

* Disable drm on wasm targets

* Remove old fixme comment from vulkan drm backend

* Move cfg check inside drm module

* Use expect instead of allow for create_surface_from_drm

* Document that drm is not available on apple platforms
2025-03-04 20:53:38 +00:00
Vecvec
5b3266db23 Support getting hit vertex positions (#7183) 2025-03-04 20:06:44 +01:00
Erich Gubler
0b5197d8d0 refactor: sync. wgpu-core's allow(clippy::arc_with_non_send_sync) to wgpu (#6771) 2025-02-28 12:37:30 -05:00
Erich Gubler
6f0c2434a7 chore(hal,core): use core::{error::Error,format} instead of std
This allows `wgpu-hal` to be used in `no_std` environments, except that
currently, only the `noop` backend supports `no_std`.
In the future, `cfg(all(gles, webgl))` should also be `no_std`, but that
requires further work.

Co-Authored_by: Kevin Reid <kpreid@switchb.org>
2025-02-26 22:58:50 -05:00
Connor Fitzgerald
8fb09a5ad6 Move REPO_MSRV to 1.85 (#7218) 2025-02-24 23:39:34 -05:00
Andreas Reich
f98bd602b9 Update enabled_backend_features to take improved backend feature flags into account (#7195) 2025-02-24 17:51:17 -05:00
Flávio J. Saraiva
a26171b2a0 Fix compilation for targets that don't have AtomicU64. (#7118)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-02-24 22:07:13 +00:00
Connor Fitzgerald
ae5dc0e7cb Target Specific Compilation (#7076) 2025-02-22 12:38:58 +01:00
Erich Gubler
143ad278f2 typo: s/viritualization/virtualization (#7192) 2025-02-21 17:06:42 +00:00
Kevin Reid
12ec5fd16f wgpu: Make macros usable from no_std and use strictly $crate paths. 2025-02-21 08:47:16 +01:00
Kevin Reid
b3b54b6941 wgpu: Adjust imports to allow no_std.
Remaining uses of `std`:
* `trace_path` / `trace_dir`
* `std::error::Error` (waiting for Rust 1.81)
* `std::ffi::c_void`
* Various uses in `util`
2025-02-21 08:47:16 +01:00
Kevin Reid
9c0fa2975f Use BufferSlice in StagingBelt::allocate(). (#7179)
* Use `BufferSlice` in `StagingBelt::allocate()`.

* Make `StagingBelt::allocate()` return just the slice.
2025-02-20 10:05:30 +01:00
Teodor Tanasoaia
b5e32cec58 add max_shader_model to Dx12Compiler (#7167) 2025-02-18 13:44:23 +01:00
Erich Gubler
6a01091397 move(core): s/create_compute_pass/begin_compute_pass/ 2025-02-17 12:42:10 -05:00
Erich Gubler
25a51606d1 move(core): s/create_render_pass/begin_render_pass/ 2025-02-17 12:42:10 -05:00
Connor Fitzgerald
194d4b1f36 New Binding Array Limit (#6952) 2025-02-17 09:22:24 -05:00
Kevin Reid
9da04c2b0b Add getters and From implementations to BufferSlice. (#7148)
* Add getters to `BufferSlice` to obtain its parts.

* Add conversions from `BufferSlice` to `BufferBinding` and `BindingResource`.
2025-02-17 11:06:13 +01:00
Connor Fitzgerald
7e119968ce Properly Deal with Timeouts (#7030) 2025-02-14 23:19:51 +00:00
Connor Fitzgerald
106b709798 Remove HashMaps from wgpu API (#7133)
* Remove HashMaps from Surface API

* Fix Comments and Errors
2025-02-14 14:36:22 -05:00
Bruce Mitchener
3710de8e5b Fix clippy::doc_overindented_list_items lints (#7139) 2025-02-14 16:36:41 +00:00
Kevin Reid
2f50426b35 Remove unnecessary chunk size field from StagingBelt. 2025-02-13 12:46:29 -05:00
Kevin Reid
ec6c7225da Remove unnecessary Arc from StagingBelt.
`Buffer` now implements `Clone` on its own.
2025-02-13 12:46:29 -05:00
Kevin Reid
fd896695d5 Expose StagingBelt allocation directly.
This allows using `StagingBelt` for copying to textures or any other
operation where copying to an existing buffer is not the desired outcome.

One unfortunate feature of the API is that `allocate()` returns the entire
buffer and an offset, so applications could accidentally touch parts of
the belt buffer outside the intended allocation. It might make more sense
to return `wgpu::BufferSlice`, but that struct cannot be used in
operations like `copy_buffer_to_texture` and does not have getters, so it
is not currently suitable for that purpose.

I also moved `Exclusive` into a module so that its unsafe-to-access field
is properly private, and made various improvements to the `StagingBelt`
documentation, such as acknowledging that `write_buffer_with()` exists.
2025-02-13 12:46:29 -05:00
Connor Fitzgerald
c39d37fc36 Fix Send/Sync of RequestDeviceErrorKind (#7122) 2025-02-13 08:46:50 -05:00
Kevin Reid
c4b25b8794 Duplicate BufferSlice methods onto Buffer and vice versa. (#7123)
This allows users to skip creation of `BufferSlice` if they have no use
for it, and brings `wgpu` closer to the WebGPU API without removing any
Rust convenience. New functions:

* `BufferSlice::slice()`
* `Buffer::map_async()`
* `Buffer::get_mapped_range()`
* `Buffer::get_mapped_range_mut()`
* `Buffer::get_mapped_range()`
2025-02-13 14:40:09 +01:00
Kevin Reid
118a985ccd Allow creating Noop backend through the normal mechanisms. 2025-02-12 22:31:47 -05:00
Daniel McNab
97704099de Document Queue::write_buffer's allocation on native APIs (#7114)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2025-02-12 20:20:35 +00:00
Andreas Reich
e5e7138169 Expose FeaturesWGPU & FeaturesWebGPU via wgpu crate & implement From (#7086)
* move tests into conditionally compiled mod and place them at the end. add some whitespace for readability

* allow creation of `Features` from `FeaturesWGPU` & `FeaturesWebGPU`
2025-02-10 09:19:14 +01:00
sagudev
8e943e828c Unify ResolvedSurfaceOutput into SurfaceOutput
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-02-07 16:16:13 -05:00