This release includes:
- `wgpu`
- `wgpu-core`
- `wgpu-hal`
- `wgpu-types`
- `wgpu-info`
- `naga` (skipped from 0.14 to 0.19)
- `naga-cli` (skipped from 0.14 to 0.19)
- `d3d12` (skipped from 0.7 to 0.19)
Improved Multithreading through internal use of Reference Counting
Large refactoring of wgpu’s internals aiming at reducing lock contention, and providing better performance when using wgpu on multiple threads.
[Check the blog post!](https://gfx-rs.github.io/2023/11/24/arcanization.html)
By gents83 in [3626](https://github.com/gfx-rs/wgpu/pull/3626) and thanks also to jimblandy, nical, Wumpf, Elabajaba & cwfitzgerald
All Public Dependencies are Re-Exported
All of wgpu's public dependencies are now re-exported at the top level so that users don't need to take their own dependencies.
This includes:
- wgpu-core
- wgpu-hal
- naga
- raw_window_handle
- web_sys
Feature Flag Changes
WebGPU & WebGL in the same Binary
Enabling `webgl` no longer removes the `webgpu` backend.
Instead, there's a new (default enabled) `webgpu` feature that allows to explicitly opt-out of `webgpu` if so desired.
If both `webgl` & `webgpu` are enabled, `wgpu::Instance` decides upon creation whether to target wgpu-core/WebGL or WebGPU.
This means that adapter selection is not handled as with regular adapters, but still allows to decide at runtime whether
`webgpu` or the `webgl` backend should be used using a single wasm binary.
By wumpf in [5044](https://github.com/gfx-rs/wgpu/pull/5044)
`naga-ir` Dedicated Feature
The `naga-ir` feature has been added to allow you to add naga module shaders without guessing about what other features needed to be enabled to get access to it.
By cwfitzgerald in [5063](https://github.com/gfx-rs/wgpu/pull/5063).
`expose-ids` Feature available unconditionally
This feature allowed you to call `global_id` on any wgpu opaque handle to get a unique hashable identity for the given resource. This is now available without the feature flag.
By cwfitzgerald in [4841](https://github.com/gfx-rs/wgpu/pull/4841).
`dx12` and `metal` Backend Crate Features
wgpu now exposes backend feature for the Direct3D 12 (`dx12`) and Metal (`metal`) backend. These are enabled by default, but don't do anything when not targeting the corresponding OS.
By daxpedda in [4815](https://github.com/gfx-rs/wgpu/pull/4815).
Direct3D 11 Backend Removal
This backend had no functionality, and with the recent support for GL on Desktop, which allows wgpu to run on older devices, there was no need to keep this backend.
By valaphee in [4828](https://github.com/gfx-rs/wgpu/pull/4828).
`WGPU_ALLOW_UNDERLYING_NONCOMPLIANT_ADAPTER` Environment Variable
This adds a way to allow a Vulkan driver which is non-compliant per `VK_KHR_driver_properties` to be enumerated. This is intended for testing new Vulkan drivers which are not Vulkan compliant yet.
By i509VCB in [4754](https://github.com/gfx-rs/wgpu/pull/4754).
`DeviceExt::create_texture_with_data` allows Mip-Major Data
Previously, `DeviceExt::create_texture_with_data` only allowed data to be provided in layer major order. There is now a `order` parameter which allows you to specify if the data is in layer major or mip major order.
diff
let tex = ctx.device.create_texture_with_data(
&queue,
&descriptor,
+ wgpu::util::TextureDataOrder::LayerMajor,
src_data,
);
By cwfitzgerald in [4780](https://github.com/gfx-rs/wgpu/pull/4780).
Safe & unified Surface Creation
It is now possible to safely create a `wgpu::Surface` with `wgpu::Instance::create_surface()` by letting `wgpu::Surface` hold a lifetime to `window`.
Passing an owned value `window` to `Surface` will return a `wgpu::Surface<'static>`.
All possible safe variants (owned windows and web canvases) are grouped using `wgpu::SurfaceTarget`.
Conversion to `wgpu::SurfaceTarget` is automatic for any type implementing `raw-window-handle`'s `HasWindowHandle` & `HasDisplayHandle` traits, i.e. most window types.
For web canvas types this has to be done explicitly:
rust
let surface: wgpu::Surface<'static> = instance.create_surface(wgpu::SurfaceTarget::Canvas(my_canvas))?;
All unsafe variants are now grouped under `wgpu::Instance::create_surface_unsafe` which takes the
`wgpu::SurfaceTargetUnsafe` enum and always returns `wgpu::Surface<'static>`.
In order to create a `wgpu::Surface<'static>` without passing ownership of the window use
`wgpu::SurfaceTargetUnsafe::from_window`:
rust
let surface = unsafe {
instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(&my_window))?
};
The easiest way to make this code safe is to use shared ownership:
rust
let window: Arc<winit::Window>;
// ...
let surface = instance.create_surface(window.clone())?;
All platform specific surface creation using points have moved into `SurfaceTargetUnsafe` as well.
For example:
Safety by daxpedda in [4597](https://github.com/gfx-rs/wgpu/pull/4597)
Unification by wumpf in [4984](https://github.com/gfx-rs/wgpu/pull/4984)
Add partial Support for WGSL Abstract Types
Abstract types make numeric literals easier to use, by
automatically converting literals and other constant expressions
from abstract numeric types to concrete types when safe and
necessary. For example, to build a vector of floating-point
numbers, Naga previously made you write:
rust