Releases: gfx-rs/wgpu
v0.19.4
This release includes wgpu
, wgpu-core
, and wgpu-hal
. All other crates are unchanged.
Bug Fixes
General
- Don't depend on bind group and bind group layout entry order in backends. This caused incorrect command execution and, in some cases, crashes. By @ErichDonGubler in #5421.
- Properly clean up all write_buffer/texture temporary resources. By @robtfm in #5413.
- Fix deadlock in certain situations when mapping buffers using
wgpu-profiler
. By @cwfitzgerald in #5517
WebGPU
- Correctly pass through timestamp queries to WebGPU. By @cwfitzgerald in #5527.
v0.19.3
This release includes wgpu
, wgpu-core
, and wgpu-hal
. All other crates are unchanged.
Major Changes
Vendored WebGPU Bindings from web_sys
--cfg=web_sys_unstable_apis
is no longer needed in your RUSTFLAGS
to compile for WebGPU!!!
While WebGPU's javascript api is stable in the browsers, the web_sys
bindings for WebGPU are still improving. As such they are hidden behind the special cfg --cfg=web_sys_unstable_apis
and are not available by default. Everyone who wanted to use our WebGPU backend needed to enable this cfg in their RUSTFLAGS
. This was very inconvenient and made it hard to use WebGPU, especially when WebGPU is enabled by default. Additionally, the unstable APIs don't adhere to semver, so there were repeated breakages.
To combat this problem we have decided to vendor the web_sys
bindings for WebGPU within the crate. Notably we are not forking the bindings, merely vendoring, so any improvements we make to the bindings will be contributed directly to upstream web_sys
.
By @cwfitzgerald in #5325.
Bug Fixes
General
- Fix an issue where command encoders weren't properly freed if an error occurred during command encoding. By @ErichDonGubler in #5251.
Android
v0.19.2
This release includes wgpu
, wgpu-core
, wgpu-hal
, wgpu-types
, and naga
. All other crates are unchanged.
Added/New Features
General
wgpu::Id
now implementsPartialOrd
/Ord
allowing it to be put inBTreeMap
s. By @cwfitzgerald and @9291Sam in #5176
OpenGL
- Log an error when OpenGL texture format heuristics fail. By @PolyMeilex in #5266
wgsl-out
Documentation
- Fix link in
wgpu::Instance::create_surface
documentation. By @HexoKnight in #5280. - Fix typo in
wgpu::CommandEncoder::clear_buffer
documentation. By @PWhiddy in #5281. Surface
configuration incorrectly claimed thatwgpu::Instance::create_surface
was unsafe. By @hackaugusto in #5265.
Bug Fixes
General
- Device lost callbacks are invoked when replaced and when global is dropped. By @bradwerth in #5168
- Fix performance regression when allocating a large amount of resources of the same type. By @nical in #5229
- Fix docs.rs wasm32 builds. By @cwfitzgerald in #5310
- Improve error message when binding count limit hit. By @hackaugusto in #5298
- Remove an unnecessary
clone
during GLSL shader injestion. By @a1phyr in #5118. - Fix missing validation for
Device::clear_buffer
whereoffset + size > buffer.size
was not checked whensize
was omitted. By @ErichDonGubler in #5282.
DX12
OpenGL
- Fix internal format for the
Etc2Rgba8Unorm
format. By @andristarr in #5178 - Try to load
libX11.so.6
in addition tolibX11.so
on linux. #5307 - Make use of
GL_EXT_texture_shadow_lod
to support sampling a cube depth texture with an explicit LOD. By @cmrschwarz in #5171.
glsl-in
- Fix code generation from nested loops. By @cwfitzgerald and @teoxoy in #5311
v0.19.1
This release includes wgpu
and wgpu-hal
. The rest of the crates are unchanged since 0.19.0.
Bug Fixes
DX12
- Properly register all swapchain buffers to prevent error on surface present. By @dtzxporter in #5091
- Check for extra null states when creating resources. By @nical in #5096
- Fix depth-only and stencil-only views causing crashes. By @teoxoy in #5100
OpenGL
- In Surface::configure and Surface::present on Windows, fix the current GL context not being unset when releasing the lock that guards access to making the context current. This was causing other threads to panic when trying to make the context current. By @Imberflur in #5087.
WebGPU
- Improve error message when compiling WebGPU backend on wasm without the
web_sys_unstable_apis
set. By @rukai in #5104
Documentation
v0.19.0
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.
By @gents83 in #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
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.
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.
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.
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.
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.
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.
let tex = ctx.device.create_texture_with_data(
&queue,
&descriptor,
+ wgpu::util::TextureDataOrder::LayerMajor,
src_data,
);
By @cwfitzgerald in #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:
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
:
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:
let window: Arc<winit::Window>;
// ...
let surface = instance.create_surface(my_window.clone())?;
All platform specific surface creation using points have moved into SurfaceTargetUnsafe
as well.
For example:
Safety by @daxpedda in #4597
Unification by @Wumpf in #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:
vec3<f32>(1.0, 2.0, 3.0)
With this change, you can now simply write:
vec3<f32>(1, 2, 3)
Even though the literals are abstract integers, Naga recognizes
that it is safe and necessary to convert them to f32
values in
order to build the vector. You can also use abstract values as
initializers for global constants and global and local variables,
like this:
var unit_x: vec2<f32> = vec2(1, 0);
The literals 1
and 0
are abstract integers, and the expression
vec2(1, 0)
is an abstract vector. However, Naga recognizes that
it can convert that to the concrete type vec2<f32>
to satisfy
the given type of unit_x
.
The WGSL specification permits abstract integers and
floating-point values in almost all contexts, but Naga's support
for this is still incomplete. Many WGSL operators and builtin
functions are specified to produce abstract results when applied
to abstract inputs, but for now Naga simply concretizes them all
before applying the operation. We will expand Naga's abstract type
support in subsequent pull requests.
As part of this work, the public types naga::ScalarKind
and
naga::Literal
now have new variants, AbstractInt
and AbstractFloat
.
By @jimblandy in #4743, #4755.
Instance::enumerate_adapters
now returns Vec<Adapter>
instead of an ExactSizeIterator
This allows us to support WebGPU and WebGL in the same binary.
- let adapters: Vec<Adapter> = instance.enumerate_adapters(wgpu::Backends::all()).collect();
+ let adapters: Vec<Adapter> = instance.enumerate_adapters(wgpu::Backends::all());
device.poll()
now returns a MaintainResult
instead of a bool
This is a forward looking change, as we plan to add more information to the MaintainResult
in the future.
This enum has the same data as the boolean, but with some useful helper functions.
- let queue_finished: bool = device.poll(wgpu::Maintain::Wait);
+ let queue_finished: bool = device.poll(wgpu::Maintain::Wait).is_queue_empty();
By @cwfitzgerald in #5053
New Features
General
- Added
DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW
to know if@builtin(vertex_index)
and@builtin(instance_index)
will respect thefirst_vertex
/first_instance
in indirect calls. If this is not present, both will always start counting from 0. Currently enabled on all backends except DX12. By @cwfitzgerald in #4722. - Added support for the
FLOAT32_FILTERABLE
feature (web and native, corresponds to WebGPU'sfloat32-filterable
). By @almarklein in #4759. - GPU buffer memory is released during "lose the device". By @bradwerth in #4851.
- wgpu and wgpu-core cargo feature flags are now documented on docs.rs. By @Wumpf in #4886.
- DeviceLostClosure is guaranteed to be invoked exactly once. By @bradwerth in #4862.
- Log vulkan validation layer messages during instance creation and destruction: By @exrook in #4586.
TextureFormat::block_size
is deprecated, useTextureFormat::block_copy_size
instead: By @Wumpf in #4647.- Rename of
DispatchIndirect
,DrawIndexedIndirect
, andDrawIndirect
types in thewgpu::util
module toDispatchIndirectArgs
,DrawIndexedIndirectArgs
, andDrawIndirectArgs
. By @cwfitzgerald in #4723. - Make the size parameter of
encoder.clear_buffer
anOption<u64>
instead ofOption<NonZero<u64>>
. By @nical in #4737. - Reduce the
info
log level noise. By @nical in #4769, #4711 and #4772 - Rename
features
&limits
fields ofDeviceDescriptor
torequired_features
&required_limits
. By @teoxoy in #4803. - `SurfaceConfig...
v0.18.2
This release includes naga
version 0.14.2. The crates wgpu-core
, wgpu-hal
are still at 0.18.1
and the crates wgpu
and wgpu-types
are still at 0.18.0
.
Bug Fixes
Naga
- When evaluating const-expressions and generating SPIR-V, properly handle
Compose
expressions whose operands areSplat
expressions. Such expressions are created and marked as constant by the constant evaluator. By @jimblandy in #4695.
v0.18.1
This release includes the crates wgpu-core
and wgpu-hal
at 0.18.1, and naga
at 0.14.1. The crates wgpu
and wgpu-types
are still at 0.18.0
.
Bug Fixes
General
- Fix panic in
Surface::configure
in debug builds. By @cwfitzgerald in #4635 - Fix crash when all the following are true: By @teoxoy in ##4642
- Passing a naga module directly to
Device::create_shader_module
. InstanceFlags::DEBUG
is enabled.
- Passing a naga module directly to
DX12
Metal
v0.18.0
Desktop OpenGL 3.3+ Support on Windows
We now support OpenGL on Windows! This brings support for a vast majority of the hardware that used to be covered by our DX11 backend. As of this writing we support OpenGL 3.3+, though there are efforts to reduce that further.
This allows us to cover the last 12 years of Intel GPUs (starting with Ivy Bridge; aka 3xxx), and the last 16 years of AMD (starting with Terascale; aka HD 2000) / NVidia GPUs (starting with Tesla; aka GeForce 8xxx).
Timestamp Queries Supported on Metal and OpenGL
Timestamp queries are now supported on both Metal and Desktop OpenGL. On Apple chips on Metal, they only support timestamp queries in command buffers or in the renderpass descriptor,
they do not support them inside a pass.
Metal: By @Wumpf in #4008
OpenGL: By @Zoxc in #4267
Render/Compute Pass Query Writes
Addition of the TimestampWrites
type to compute and render pass descriptors to allow profiling on tilers which do not support timestamps inside passes.
Added an example to demonstrate the various kinds of timestamps.
Additionally, metal now supports timestamp queries!
By @FL33TW00D & @Wumpf in #3636.
Occlusion Queries
We now support binary occlusion queries! This allows you to determine if any of the draw calls within the query drew any pixels.
Use the new occlusion_query_set
field on RenderPassDescriptor
to give a query set that occlusion queries will write to.
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
// ...
+ occlusion_query_set: Some(&my_occlusion_query_set),
});
Within the renderpass do the following to write the occlusion query results to the query set at the given index:
rpass.begin_occlusion_query(index);
rpass.draw(...);
rpass.draw(...);
rpass.end_occlusion_query();
These are binary occlusion queries, so the result will be either 0 or an unspecified non-zero value.
Shader Improvements
// WGSL constant expressions are now supported!
const BLAH: u32 = 1u + 1u;
// `rgb10a2uint` and `bgra8unorm` can now be used as a storage image format.
var image: texture_storage_2d<rgb10a2uint, write>;
var image: texture_storage_2d<bgra8unorm, write>;
// You can now use dual source blending!
struct FragmentOutput{
@location(0) source1: vec4<f32>,
@location(0) @second_blend_source source2: vec4<f32>,
}
// `modf`/`frexp` now return structures
let result = modf(1.5);
result.fract == 0.5;
result.whole == 1.0;
let result = frexp(1.5);
result.fract == 0.75;
result.exponent == 2i;
// `modf`/`frexp` are currently disabled on GLSL and SPIR-V input.
Shader Validation Improvements
// Cannot get pointer to a workgroup variable
fn func(p: ptr<workgroup, u32>); // ERROR
// Cannot create Inf/NaN through constant expressions
const INF: f32 = 3.40282347e+38 + 1.0; // ERROR
const NAN: f32 = 0.0 / 0.0; // ERROR
// `outerProduct` function removed
// Error on repeated or missing `@workgroup_size()`
@workgroup_size(1) @workgroup_size(2) // ERROR
fn compute_main() {}
// Error on repeated attributes.
fn fragment_main(@location(0) @location(0) location_0: f32) // ERROR
RenderPass StoreOp
is now Enumeration
wgpu::Operations::store
used to be an underdocumented boolean value,
causing misunderstandings of the effect of setting it to false
.
The API now more closely resembles WebGPU which distinguishes between store
and discard
,
see WebGPU spec on GPUStoreOp.
// ...
depth_ops: Some(wgpu::Operations {
load: wgpu::LoadOp::Clear(1.0),
- store: false,
+ store: wgpu::StoreOp::Discard,
}),
// ...
Instance Descriptor Settings
The instance descriptor grew two more fields: flags
and gles_minor_version
.
flags
allow you to toggle the underlying api validation layers, debug information about shaders and objects in capture programs, and the ability to discard lables
gles_minor_version
is a rather niche feature that allows you to force the GLES backend to use a specific minor version, this is useful to get ANGLE to enable more than GLES 3.0.
let instance = wgpu::Instance::new(InstanceDescriptor {
...
+ flags: wgpu::InstanceFlags::default()
+ gles_minor_version: wgpu::Gles3MinorVersion::Automatic,
});
gles_minor_version
: By @PJB3005 in #3998
flags
: By @nical in #4230
Many New Examples!
- Added the following examples: By @JustAnotherCodemonkey in #3885.
Revamped Testing Suite
Our testing harness was completely revamped and now automatically runs against all gpus in the system, shows the expected status of every test, and is tolerant to flakes.
Additionally, we have filled out our CI to now run the latest versions of WARP and Mesa. This means we can test even more features on CI than before.
By @cwfitzgerald in #3873
The GLES backend is now optional on macOS
The angle
feature flag has to be set for the GLES backend to be enabled on Windows & macOS.
Added/New Features
- Re-export Naga. By @exrook in #4172
- Add WinUI 3 SwapChainPanel support. By @DDRBoxman in #4191
Changes
General
- Omit texture store bound checks since they are no-ops if out of bounds on all APIs. By @teoxoy in #3975
- Validate
DownlevelFlags::READ_ONLY_DEPTH_STENCIL
. By @teoxoy in #4031 - Add validation in accordance with WebGPU
setViewport
valid usage forx
,y
andthis.[[attachment_size]]
. By @James2022-rgb in #4058 wgpu::CreateSurfaceError
andwgpu::RequestDeviceError
now give details of the failure, but no longer implementPartialEq
and cannot be constructed. By @kpreid in #4066 and #4145- Make
WGPU_POWER_PREF=none
a valid value. By @fornwall in 4076 - Support dual source blending in OpenGL ES, Metal, Vulkan & DX12. By @freqmod in 4022
- Add stub support for device destroy and device validity. By @bradwerth in 4163 and in 4212
- Add trace-level logging for most entry points in wgpu-core By @nical in 4183
- Add
Rgb10a2Uint
format. By @teoxoy in 4199 - Validate that resources are used on the right device. By @nical in 4207
- Expose instance flags.
- Add support for the bgra8unorm-storage feature. By @jinleili and @nical in #4228
- Calls to lost devices now return
DeviceError::Lost
instead ofDeviceError::Invalid
. By @bradwerth in #4238 - Let the
"strict_asserts"
feature enable check that wgpu-core's lock-ordering tokens are unique per thread. By @jimblandy in #4258 - Allow filtering labels out before they are passed to GPU drivers by @nical in https://github.com/gfx-rs/wgpu/pull/4246
Vulkan
- Rename
wgpu_hal::vulkan::Instance::required_extensions
todesired_extensions
. By @jimblandy in #4115 - Don't bother calling
vkFreeCommandBuffers
whenvkDestroyCommandPool
will take care of that for us. By @jimblandy in #4059
DX12
- Bump
gpu-allocator
to 0.23. By @Elabajaba in #4198
Documentation
- Use WGSL for VertexFormat example types. By @ScanMountGoat in #4035
- Fix description of
Features::TEXTURE_COMPRESSION_ASTC_HDR
in #4157
Bug Fixes
General
- Derive storage bindings via
naga::StorageAccess
instead ofnaga::GlobalUse
. By @teoxoy in #3985. Queue::on_submitted_work_done
callbacks will now always be called after all previousBufferSlice::map_async
callbacks, even when there are no active submissions. By @cwfitzgerald in #4036.- Fix
clear
texture views being leaked whenwgpu::SurfaceTexture
is dropped before it is presented. By @rajveermalviy...
v0.17.2
v0.17.1
This release includes the crate wgpu
, wgpu-core
, and wgpu-hal
. The crate wgpu-types
is still at 0.17.0
.
Added/New Features
- Add
get_mapped_range_as_array_buffer
for faster buffer read-backs in wasm builds. By @ryankaplan in #4042.
Bug Fixes
DX12
- Fix panic on resize when using DX12. By @cwfitzgerald in #4106
Vulkan
- Suppress validation error caused by OBS layer. This was also fixed upstream. By @cwfitzgerald in #4002
- Work around bug in nvidia's vkCmdFillBuffer implementation. By @cwfitzgerald in #4132.