Skip to content

Releases: gfx-rs/wgpu

v26.0.1

10 Jul 20:19
0c978d0
Compare
Choose a tag to compare

This release includes v26.0.1 of wgpu and wgpu-core. All other crates remain at their previous versions.

Bug Fixes

  • Fixed build error inside wgpu::util::initialize_adapter_from_env when std feature is not enabled. By @kpreid in #7918.
  • Fixed build error occurring when the profiling dependency is configured to have profiling active. By @kpreid in #7916.
  • Emit a validation error instead of panicking when a query set index is OOB. By @ErichDonGubler in #7908.

v26.0.0

10 Jul 00:59
v26.0.0
Compare
Choose a tag to compare

Major Features

New method TextureView::texture

You can now call texture_view.texture() to get access to the texture that a given texture view points to.

By @cwfitzgerald and @Wumpf in #7907.

as_hal calls now return guards instead of using callbacks.

Previously, if you wanted to get access to the wgpu-hal or underlying api types, you would call as_hal and get the hal type as a callback. Now the function returns a guard which dereferences to the hal type.

- device.as_hal::<hal::api::Vulkan>(|hal_device| {...});
+ let hal_device: impl Deref<Item = hal::vulkan::Device> = device.as_hal::<hal::api::Vulkan>();

By @cwfitzgerald in #7863.

Enabling Vulkan Features/Extensions

For those who are doing vulkan/wgpu interop or passthrough and need to enable features/extensions that wgpu does not expose, there is a new wgpu_hal::vulkan::Adapter::open_with_callback that allows the user to modify the pnext chains and extension lists populated by wgpu before we create a vulkan device. This should vastly simplify the experience, as previously you needed to create a device yourself.

Underlying api interop is a quickly evolving space, so we welcome all feedback!

type VkApi = wgpu::hal::api::Vulkan;
let adapter: wgpu::Adapter = ...;

let mut buffer_device_address_create_info = ash::vk::PhysicalDeviceBufferDeviceAddressFeatures { .. };
let hal_device: wgpu::hal::OpenDevice<VkApi> = adapter
    .as_hal::<VkApi>()
    .unwrap()
    .open_with_callback(
        wgpu::Features::empty(),
        &wgpu::MemoryHints::Performance,
        Some(Box::new(|args| {
            // Add the buffer device address extension.
            args.extensions.push(ash::khr::buffer_device_address::NAME);
            // Extend the create info with the buffer device address create info.
            *args.create_info = args
                .create_info
                .push_next(&mut buffer_device_address_create_info);
            // We also have access to the queue create infos if we need them.
            let _ = args.queue_create_infos;
        })),
    )
    .unwrap();

let (device, queue) = adapter
    .create_device_from_hal(hal_device, &wgpu::DeviceDescriptor { .. })
    .unwrap();

More examples of this kind of interop will come soon.

By @Vecvec in #7829.

Naga

  • Added no_std support with default features disabled. By @bushrat011899 in #7585.
  • [wgsl-in,ir] Add support for parsing rust-style doc comments via naga::front::glsl::Frontend::new_with_options. By @Vrixyz in #6364.
  • When emitting GLSL, Uniform and Storage Buffer memory layouts are now emitted even if no explicit binding is given. By @cloone8 in #7579.
  • Diagnostic rendering methods (i.e., naga::{front::wgsl::ParseError,WithSpan}::emit_error_to_string_with_path) now accept more types for their path argument via a new sealed AsDiagnosticFilePath trait. By @atlv24, @bushrat011899, and @ErichDonGubler in #7643.
  • Add support for quad operations (requires SUBGROUP feature to be enabled). By @dzamkov and @valaphee in #7683.
  • Add support for atomicCompareExchangeWeak in HLSL and GLSL backends. By @cryvosh in #7658

General

  • Add support for astc-sliced-3d feature. By @mehmetoguzderin in #7577
  • Added wgpu_hal::dx12::Adapter::as_raw(). By @tronical in ##7852
  • Add support for rendering to slices of 3D texture views and single layered 2D-Array texture views (this requires VK_KHR_maintenance1 which should be widely available on newer drivers). By @teoxoy in #7596
  • Add extra acceleration structure vertex formats. By @Vecvec in #7580.
  • Add acceleration structure limits. By @Vecvec in #7845.
  • Add support for clip-distances feature for Vulkan and GL backends. By @dzamkov in #7730
  • Added wgpu_types::error::{ErrorType, WebGpuError} for classification of errors according to WebGPU's GPUError's classification scheme, and implement WebGpuError for existing errors. This allows users of wgpu-core to offload error classification onto the WGPU ecosystem, rather than having to do it themselves without sufficient information. By @ErichDonGubler in #6547.

Bug Fixes

General

  • Fix error message for sampler array limit. By @LPGhatguy in #7704.
  • Fix bug where using BufferSlice::get_mapped_range_as_array_buffer() on a buffer would prevent you from ever unmapping it. Note that this API has changed and is now BufferView::as_uint8array().

Naga

  • Naga now infers the correct binding layout when a resource appears only in an assignment to _. By @andyleiserson in #7540.
  • Implement dot4U8Packed and dot4I8Packed for all backends, using specialized intrinsics on SPIR-V, HSLS, and Metal if available, and polyfills everywhere else. By @robamler in #7494, #7574, and #7653.
  • Add polyfilled pack4x{I,U}8Clamped built-ins to all backends and WGSL frontend. By @ErichDonGubler in #7546.
  • Allow textureLoad's sample index arg to be unsigned. By @jimblandy in #7625.
  • Properly convert arguments to atomic operations. By @jimblandy in #7573.
  • Apply necessary automatic conversions to the value argument of textureStore. By @jimblandy in #7567.
  • Properly apply WGSL's automatic conversions to the arguments to texture sampling functions. By @jimblandy in #7548.
  • Properly evaluate abs(most negative abstract int). By @jimblandy in #7507.
  • Generate vectorized code for [un]pack4x{I,U}8[Clamp] on SPIR-V and MSL 2.1+. By @robamler in #7664.
  • Fix typing for select, which had issues particularly with a lack of automatic type conversion. By @ErichDonGubler in #7572.
  • Allow scalars as the first argument of the distance built-in function. By @bernhl in #7530.
  • Don't panic when handling f16 for pipeline constants, i.e., overrides in WGSL. By @ErichDonGubler in #7801.
  • Prevent aliased ray queries crashing naga when writing SPIR-V out. By @Vecvec in #7759.

DX12

  • Get vertex_index & instance_index builtins working for indirect draws. By @teoxoy in #7535

Vulkan

Metal

  • Remove extraneous main thread warning in fn surface_capabilities(). By @jamesordner in #7692

WebGPU

Changes

  • Loosen Viewport validation requirements to match the new specs. By @EbbDrop in #7564
  • wgpu and deno_webgpu now use wgpu-types::error::WebGpuError to classify errors. Any changes here are likely to be regressions; please report them if you find them! By @ErichDonGubler in #6547.

General

  • Support BLAS compaction in wgpu. By @Vecvec in #7285.
  • Removed MaintainBase in favor of using PollType. By @waywardmonkeys in #7508.
  • The destroy functions for buffers and textures in wgpu-core are now infallible. Previously, they returned an error if called multiple times for the same object. This only affects the wgpu-core API; the wgpu API already allowed multiple destroy calls. By @andyleiserson in #7686 and #7720.
  • Remove CommandEncoder::build_acceleration_structures_unsafe_tlas in favour of as_hal and apply
    simplifications allowed by this. By @Vecvec in #7513
  • The type of the size parameter to copy_buffer_to_buffer has changed from BufferAddress to impl Into<Option<BufferAddress>>. This achieves the spec-defined behavior of the value being optional, while still accepting existing calls without changes. By @andyleiserson in #7659.
  • To bring wgpu's error reporting into compliance with the WebGPU specification, the ...
Read more

v25.0.2

24 May 10:57
f35cf94
Compare
Choose a tag to compare

This release includes wgpu, wgpu-core and wgpu-hal version 25.0.2. All other crates remain at their previous versions.

Bug Fixes

General

  • Fix a possible deadlock within Queue::write_buffer. By @RedMindZ in #7582
  • Fix raw-window-handle dependency being too lenient. By @kpreid in #7526

WebGPU

  • Insert fragment pipeline constants into fragment descriptor instead of vertex descriptor. By @DerSchmale in #7621

v24.0.5

24 May 10:26
Compare
Choose a tag to compare

This release includes wgpu and wgpu-core version 24.0.5. All other crates remain at their previous versions.

Bug Fixes

General

  • Fix a possible deadlock within Queue::write_buffer. By @RedMindZ in #7582

WebGPU

  • Insert fragment pipeline constants into fragment descriptor instead of vertex descriptor. By @DerSchmale in #7621

v25.0.1

11 Apr 19:03
Compare
Choose a tag to compare

This release includes wgpu-core, wgpu-hal and naga version 25.0.1. All other crates remain at their previous versions.

Bug Fixes

  • Fix typos in various documentation. By @waywardmonkeys in #7510.
  • Fix compile error when building with profiling/profile-with-* feature enabled. By @waywardmonkeys in #7509.
  • Use once_cell::race::OnceBox instead of std::sync::LazyLock to allow naga::proc::Namer::default() to be available without backend features being enabled. By @cwfitzgerald in #7517.

DX12

v25.0.0

10 Apr 16:34
8c2c2ce
Compare
Choose a tag to compare

Major Features

Hashmaps Removed from APIs

Both PipelineCompilationOptions::constants and ShaderSource::Glsl::defines now take
slices of key-value pairs instead of hashmaps. This is to prepare for no_std
support and allow us to keep which hashmap hasher and such as implementation details. It
also allows more easily creating these structures inline.

By @cwfitzgerald in #7133

All Backends Now Have Features

Previously, the vulkan and gles backends were non-optional on windows, linux, and android and there was no way to disable them. We have now figured out how to properly make them disablable! Additionally, if you turn on the webgl feature, you will only get the GLES backend on WebAssembly, it won't leak into native builds, like previously it might have.

Warning

If you use wgpu with default-features = false and you want to retain the vulkan and gles backends, you will need to add them to your feature list.

-wgpu = { version = "24", default-features = false, features = ["metal", "wgsl", "webgl"] }
+wgpu = { version = "25", default-features = false, features = ["metal", "wgsl", "webgl", "vulkan", "gles"] }

By @cwfitzgerald in #7076.

device.poll Api Reworked

This release reworked the poll api significantly to allow polling to return errors when polling hits internal timeout limits.

Maintain was renamed PollType. Additionally, poll now returns a result containing information about what happened during the poll.

-pub fn wgpu::Device::poll(&self, maintain: wgpu::Maintain) -> wgpu::MaintainResult
+pub fn wgpu::Device::poll(&self, poll_type: wgpu::PollType) -> Result<wgpu::PollStatus, wgpu::PollError>

-device.poll(wgpu::Maintain::Poll);
+device.poll(wgpu::PollType::Poll).unwrap();
pub enum PollType<T> {
    /// On wgpu-core based backends, block until the given submission has
    /// completed execution, and any callbacks have been invoked.
    ///
    /// On WebGPU, this has no effect. Callbacks are invoked from the
    /// window event loop.
    WaitForSubmissionIndex(T),
    /// Same as WaitForSubmissionIndex but waits for the most recent submission.
    Wait,
    /// Check the device for a single time without blocking.
    Poll,
}

pub enum PollStatus {
    /// There are no active submissions in flight as of the beginning of the poll call.
    /// Other submissions may have been queued on other threads during the call.
    ///
    /// This implies that the given Wait was satisfied before the timeout.
    QueueEmpty,

    /// The requested Wait was satisfied before the timeout.
    WaitSucceeded,

    /// This was a poll.
    Poll,
}

pub enum PollError {
    /// The requested Wait timed out before the submission was completed.
    Timeout,
}

Warning

As part of this change, WebGL's default behavior has changed. Previously device.poll(Wait) appeared as though it functioned correctly. This was a quirk caused by the bug that these PRs fixed. Now it will always return Timeout if the submission has not already completed. As many people rely on this behavior on WebGL, there is a new options in BackendOptions. If you want the old behavior, set the following on instance creation:

instance_desc.backend_options.gl.fence_behavior = wgpu::GlFenceBehavior::AutoFinish;

You will lose the ability to know exactly when a submission has completed, but device.poll(Wait) will behave the same as it does on native.

By @cwfitzgerald in #6942 and #7030.

wgpu::Device::start_capture renamed, documented, and made unsafe

- device.start_capture();
+ unsafe { device.start_graphics_debugger_capture() }
// Your code here
- device.stop_capture();
+ unsafe { device.stop_graphics_debugger_capture() }

There is now documentation to describe how this maps to the various debuggers' apis.

By @cwfitzgerald in #7470

Ensure loops generated by SPIR-V and HLSL Naga backends are bounded

Make sure that all loops in shaders generated by these naga backends are bounded
to avoid undefined behaviour due to infinite loops. Note that this may have a
performance cost. As with the existing implementation for the MSL backend this
can be disabled by using Device::create_shader_module_trusted().

By @jamienicol in #6929 and #7080.

Split up Features internally

Internally split up the Features struct and recombine them internally using a macro. There should be no breaking
changes from this. This means there are also namespaces (as well as the old Features::*) for all wgpu specific
features and webgpu feature (FeaturesWGPU and FeaturesWebGPU respectively) and Features::from_internal_flags which
allow you to be explicit about whether features you need are available on the web too.

By @Vecvec in #6905, #7086

WebGPU compliant dual source blending feature

Previously, dual source blending was implemented with a wgpu native only feature flag and used a custom syntax in wgpu.
By now, dual source blending was added to the WebGPU spec as an extension.
We're now following suite and implement the official syntax.

Existing shaders using dual source blending need to be updated:

struct FragmentOutput{
-    @location(0) source0: vec4<f32>,
-    @location(0) @second_blend_source source1: vec4<f32>,
+    @location(0) @blend_src(0) source0: vec4<f32>,
+    @location(0) @blend_src(1) source1: vec4<f32>,
}

With that wgpu::Features::DUAL_SOURCE_BLENDING is now available on WebGPU.

Furthermore, GLSL shaders now support dual source blending as well via the index layout qualifier:

layout(location = 0, index = 0) out vec4 output0;
layout(location = 0, index = 1) out vec4 output1;

By @Wumpf in #7144

Unify interface for SpirV shader passthrough

Replace device create_shader_module_spirv function with a generic create_shader_module_passthrough function
taking a ShaderModuleDescriptorPassthrough enum as parameter.

Update your calls to create_shader_module_spirv and use create_shader_module_passthrough instead:

-    device.create_shader_module_spirv(
-        wgpu::ShaderModuleDescriptorSpirV {
-            label: Some(&name),
-            source: Cow::Borrowed(&source),
-        }
-    )
+    device.create_shader_module_passthrough(
+        wgpu::ShaderModuleDescriptorPassthrough::SpirV(
+            wgpu::ShaderModuleDescriptorSpirV {
+                label: Some(&name),
+                source: Cow::Borrowed(&source),
+            },
+        ),
+    )

By @syl20bnr in #7326.

Noop Backend

It is now possible to create a dummy wgpu device even when no GPU is available. This may be useful for testing of code which manages graphics resources. Currently, it supports reading and writing buffers, and other resource types can be created but do nothing.

To use it, enable the noop feature of wgpu, and either call Device::noop(), or add NoopBackendOptions { enable: true } to the backend options of your Instance (this is an additional safeguard beyond the Backends bits).

By @kpreid in #7063 and #7342.

SHADER_F16 feature is now available with naga shaders

Previously this feature only allowed you to use f16 on SPIR-V passthrough shaders. Now you can use it on all shaders, including WGSL, SPIR-V, and GLSL!

enable f16;

fn hello_world(a: f16) -> f16 {
    return a + 1.0h;
}

By @FL33TW00D, @ErichDonGubler, and @cwfitzgerald in #5701

Bindless support improved and validation rules changed.

Metal support for bindless has significantly improved and the limits for binding arrays have been increased.

Previously, all resources inside binding arrays contributed towards the standard limit of their type (texture_2d arrays for example would contribute to max_sampled_textures_per_shader_stage). Now these resources will only contribute towards binding-array specific limits:

  • max_binding_array_elements_per_shader_stage for all non-sampler resources
  • max_binding_array_sampler_elements_per_shader_stage for sampler resources.

This change has allowed the metal binding array limits to go from between 32 and 128 resources, all the way 500,000 sampled textures. Additionally binding arrays are now bound more efficiently on Metal.

This change also enabled legacy Intel GPUs to support 1M bindless resources, instead of the previous 1800.

To facilitate this change, there was an additional validation rule put in place: if there is a binding array in a bind group, you may not use dynamic offset buffers or uniform buffers in that bind group. This requirement comes from vulkan rules on UpdateAfterBind descriptors.
By @cwfitzgerald in #6811, #6815, and #6952.

New Features

General

  • Add Buffer methods corresponding to BufferSlice methods, so you can skip creating a BufferSlice when it offers no benefit, and BufferSlice::slice() for sub-slicing a slice. By @kpreid in [#7123](https:...
Read more

v24.0.4

04 Apr 01:36
993fc39
Compare
Choose a tag to compare

This release updates wgpu-hal to 24.0.4. All other crates remain at their previous versions.

Metal

  • Use resize observers for smoother resizing. By @madsmtm in #7026.

v24.0.3

19 Mar 17:56
8a38f5f
Compare
Choose a tag to compare

This release updated the wgpu crate only. All other crates remain at their previous versions.

Bug Fixes

  • Fix drop order in Surface, solving segfaults on exit on some systems. By @ed-2100 in #6997

v24.0.2

27 Feb 02:21
d06da58
Compare
Choose a tag to compare

This release bumps wgpu-core and wgpu-hal to 24.0.2. All other crates remain at their previous verions.

Bug Fixes

  • Fix GLES renderpass clears causing violation of max_color_attachments limit. By @adrian17 in #6994.
  • Fix a possible deadlock within Queue::write_texture. By @metamuffin in #7004
  • Decrement max_storage_buffer_binding_size by 1 to match max_buffer_size. By @minus1ms in #7217

v24.0.1

23 Jan 00:22
f6a4834
Compare
Choose a tag to compare

This release contains wgpu v24.0.1. All other crates remain at v24.0.0.

Bug Fixes

  • Fix wgpu not building with --no-default-features on when targeting wasm32-unknown-unknown. By @Wumpf in #6946.
  • Implement Clone on ShaderModule. By @a1phyr in #6937.
  • Fix CopyExternalImageDestInfo not exported on wgpu. By @Wumpf in #6962.