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 @rajveermalviya in #4057. - Add
Feature::SHADER_UNUSED_VERTEX_OUTPUT
to allow unused vertex shader outputs. By @Aaron1011 in #4116. - Fix a panic in
surface_configure
. By @nical in #4220 and #4227
Vulkan
- Fix enabling
wgpu::Features::PARTIALLY_BOUND_BINDING_ARRAY
not being actually enabled in vulkan backend. By @39ali in#3772. - Don't pass
vk::InstanceCreateFlags::ENUMERATE_PORTABILITY_KHR
unless theVK_KHR_portability_enumeration
extension is available. By @jimblandy in#4038. - Enhancement of [#4038], using ash's definition instead of hard-coded c_str. By @hybcloud in#4044.
- Enable vulkan presentation on (Linux) Intel Mesa >= v21.2. By @flukejones in#4110
DX12
- DX12 doesn't support `Features::POLYGON_MODE_POINT``. By @teoxoy in #4032.
- Set
Features::VERTEX_WRITABLE_STORAGE
based on the right feature level. By @teoxoy in #4033.
Metal
- Ensure that MTLCommandEncoder calls endEncoding before it is deallocated. By @bradwerth in #4023
WebGPU
- Ensure that limit requests and reporting is done correctly. By @OptimisticPeach in #4107
- Validate usage of polygon mode. By @teoxoy in #4196
GLES
- enable/disable blending per attachment only when available (on ES 3.2 or higher). By @teoxoy in #4234
Documentation
Examples
- Created
wgpu-example::utils
module to contain misc functions and such that are common code but aren't part of the example framework. Add to it the functionsoutput_image_wasm
andoutput_image_native
, both for outputtingVec<u8>
RGBA images either to the disc or the web page. By @JustAnotherCodemonkey in #3885. - Removed
capture
example as it had issues (did not run on wasm) and has been replaced byrender-to-texture
(see above). By @JustAnotherCodemonkey in #3885.