A cross-platform, safe, pure-Rust graphics API.
This release includes wgpu
, and wgpu-core
. The crates wgpu-hal
and wgpu-types
are still at 0.14.1.
get_mapped_range
by @nical in #3233
This release includes wgpu-hal
, and wgpu-types
. The crates wgpu
and wgpu-core
are still at 0.14.0.
wgpu::TextureFormat::Depth24PlusStencil8
available on all backends by making the feature unconditionally available and the feature unneeded to use the format. By @Healthire and @cwfitzgerald in #3165
When using CompareFunction::Equal or CompareFunction::NotEqual on a pipeline, there is now a warning logged if the vertex shader does not have a @invariant tag on it. On some machines, rendering the same triangles multiple times without an @invariant tag will result in slightly different depths for every pixel. Because the *Equal functions rely on depth being the same every time it is rendered, we now warn if it is missing.
-@vertex
-fn vert_main(v_in: VertexInput) -> @builtin(position) vec4<f32> {...}
+@vertex
+fn vert_main(v_in: VertexInput) -> @builtin(position) @invariant vec4<f32> {...}
Surface supports alpha_mode
now. When alpha_mode is equal to PreMultiplied
or PostMultiplied
,
the alpha channel of framebuffer is respected in the compositing process, but which mode is available depends on
the different API and Device
. If don't care about alpha_mode, you can set it to Auto
.
SurfaceConfiguration {
// ...
+ alpha_mode: surface.get_supported_alpha_modes(&adapter)[0],
}
The function to enumerate supported presentation modes changed:
- pub fn wgpu::Surface::get_supported_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
+ pub fn wgpu::Surface::get_supported_present_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
This will allow use of the latest version of winit. As such the bound on create_surface is now RWH 0.5 and requires
both raw_window_handle::HasRawWindowHandle
and raw_window_handle::HasRawDisplayHandle
.
Buffer::size()
and Buffer::usage()
; by @kpreid in #2923
alpha_mode
on SurfaceConfiguration, by @jinleili in #2836
AdapterInfo
, by @i509VCB in #3037
copy_external_image_to_texture
on WebGPU, by @ybiletskyi in #2781
StagingBuffers
even when an error occurs in the operation that consumes them. By @jimblandy in #2961
wasm32-unknown-unknown
by @Seamooo in #2922
BufferUsages
mismatches when Features::MAPPABLE_PRIMARY_BUFFERS
is not
enabled. By @imberflur in #3023
CommandEncoder
not being Send
and Sync
on web by @i509VCB in #3025
vendor
in AdapterInfo
if the vendor has no PCI id.msg_send![view, retain]
call within from_view
by @jinleili in #2976
max_buffer
max_texture
and max_vertex_buffers
limits by @jinleili in #2978
format_rgb10a2_unorm_surface
field by @jinleili in #2981
_buffer_sizes
encoding by @dtiselice in #3047
astc_hdr
formats support by @jinleili in [#2971]](https://github.com/gfx-rs/wgpu/pull/2971)VUID-StandaloneSpirv-Flat-06202
and VUID-StandaloneSpirv-Flat-04744
. By @jimblandy in
#3008
Instance::as_hal<A>
to just return an Option<&A::Instance>
rather than taking a callback. By @jimb in #2991
InvalidFormatUsages
error by @Seamooo in #2886
PhantomData
for IdentityManager
's Input
type. By @jimblandy in #2972
Cow<'static, Module>
, to allow loading global variables by @daxpedda in #2903
get_metal_layer
by @jinleili in #2826
wgpu
users to access vk::Queue
and the queue index. By @anlumo in #2950
VkPhysicalDeviceProperties.apiVersion
is the actual version of the device. By @i509VCB in #3011
Rgba16Float
format support for color attachments. By @jinleili in #3045
TEXTURE_COMPRESSION_ASTC_HDR
feature detection by @jinleili in #3042
StagingBelt::write_buffer()
check more thoroughly for reusable memory; by @kpreid in #2906
wgpu_core
resource allocation. @jimblandy in #2973
StagingBelt
documentation by @kpreid in #2905
Instance::create_surface_from_canvas
and
Instance::create_surface_from_offscreen_canvas
regarding their
safety contract. These functions are not unsafe. By @jimblandy #2990
write_buffer_with()
is sound but unwise to read from by @kpreid in #3006
Adapter::as_hal
and Device::as_hal
have to take callback functions. By @jimblandy in #2992
alpha_mode
on web target by @jinleili in #3040
"strict_asserts"
feature, to enable additional internal
run-time validation in wgpu-core
. By @jimblandy in
#2872.Manual concatination of cargo public-api --diff-git-checkouts v0.13.2 v0.14.0 -p wgpu
and cargo public-api --diff-git-checkouts v0.13.2 v0.14.0 -p wgpu-types
Removed items from the public API
=================================
-pub fn wgpu::Surface::get_supported_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
-pub const wgpu::Features::DEPTH24UNORM_STENCIL8: Self
-pub enum variant wgpu::TextureFormat::Depth24UnormStencil8
Changed items in the public API
===============================
-pub unsafe fn wgpu::Instance::as_hal<A: wgc::hub::HalApi, F: FnOnce(Option<&<A as >::Instance>) -> R, R>(&self, hal_instance_callback: F) -> R
+pub unsafe fn wgpu::Instance::as_hal<A: wgc::hub::HalApi>(&self) -> Option<&<A as >::Instance>
-pub unsafe fn wgpu::Instance::create_surface<W: raw_window_handle::HasRawWindowHandle>(&self, window: &W) -> wgpu::Surface
+pub unsafe fn wgpu::Instance::create_surface<W: raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle>(&self, window: &W) -> wgpu::Surface
Added items to the public API
=============================
+pub fn wgpu::Buffer::size(&self) -> wgt::BufferAddress
+pub fn wgpu::Buffer::usage(&self) -> BufferUsages
+pub fn wgpu::Surface::get_supported_alpha_modes(&self, adapter: &wgpu::Adapter) -> Vec<CompositeAlphaMode>
+pub fn wgpu::Surface::get_supported_present_modes(&self, adapter: &wgpu::Adapter) -> Vec<PresentMode>
+#[repr(C)] pub enum wgpu::CompositeAlphaMode
+impl RefUnwindSafe for wgpu::CompositeAlphaMode
+impl Send for wgpu::CompositeAlphaMode
+impl Sync for wgpu::CompositeAlphaMode
+impl Unpin for wgpu::CompositeAlphaMode
+impl UnwindSafe for wgpu::CompositeAlphaMode
+pub const wgpu::Features::DEPTH24PLUS_STENCIL8: Self
+pub const wgpu::TextureFormatFeatureFlags::BLENDABLE: Self
+pub enum variant wgpu::CompositeAlphaMode::Auto = 0
+pub enum variant wgpu::CompositeAlphaMode::Inherit = 4
+pub enum variant wgpu::CompositeAlphaMode::Opaque = 1
+pub enum variant wgpu::CompositeAlphaMode::PostMultiplied = 3
+pub enum variant wgpu::CompositeAlphaMode::PreMultiplied = 2
+pub enum variant wgpu::TextureFormat::Depth16Unorm
+pub fn wgpu::CompositeAlphaMode::clone(&self) -> wgpu::CompositeAlphaMode
+pub fn wgpu::CompositeAlphaMode::eq(&self, other: &wgpu::CompositeAlphaMode) -> bool
+pub fn wgpu::CompositeAlphaMode::fmt(&self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
+pub fn wgpu::CompositeAlphaMode::hash<__H: $crate::hash::Hasher>(&self, state: &mut __H) -> ()
+pub struct field wgpu::AdapterInfo::driver: String
+pub struct field wgpu::AdapterInfo::driver_info: String
+pub struct field wgpu::SurfaceConfiguration::alpha_mode: wgpu_types::CompositeAlphaMode
This release includes wgpu-core
, wgpu-hal
, and wgpu-types
. The crate wgpu
is still at 0.13.1.
DeviceType::DiscreteGpu
over DeviceType::Other
for PowerPreference::LowPower
so Vulkan is preferred over OpenGL again by @Craig-Macomber in #2853
get_texture_format_features
on unsupported texture formats (returning no flags) by @cwfitzgerald in #2856
TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
is enabled by @cwfitzgerald in #2856
get_texture_format_features
only lists the COPY_* usages if the adapter actually supports that usage by @cwfitzgerald in #2856
as_hal
functions when the hal generic type does not match the hub being looked up in by @i509VCB #2871
DownlevelCapabilities::default()
now returns the ANISOTROPIC_FILTERING
flag set to true so DX12 lists ANISOTROPIC_FILTERING
as true again by @cwfitzgerald in #2851
get_texture_format_features
now only returns usages for formats it actually supports by @cwfitzgerald in #2856
Adapter::from_external
in gles hal by @i509VCB in #2863
This release includes wgpu
, wgpu-core
, and wgpu-hal
. The crate wgpu-types
is still at 0.13.0.
This release includes wgpu
, wgpu-core
, wgpu-hal
, and wgpu-types
.
WGSL syntax has changed in a couple ways. The new syntax is easier to read and work with.
Attribute declarations are written differently:
- [[group(1), binding(0)]]
+ @group(1) @binding(0)
Stage declarations are now separate attributes rather than part of the stage
attribute:
- [[stage(vertex)]]
+ @vertex
Structs now use ,
as field separator and no longer need semicolons after the declaration:
- struct MyStruct {
- my_member: u32;
- };
+ struct MyStruct {
+ my_member: u32,
+ }
The method of getting the preferred swapchain format has changed to allow viewing all formats supported by the surface.
- let format = surface.get_preferred_format(&adapter).unwrap();
+ let format = surface.get_supported_formats(&adapter)[0];
Presentation modes now need to match exactly what the surface supports. FIFO
is always supported,
but all other modes vary from API to API and Device
to Device
. To get a list of all supported modes,
call the following. The order does not indicate preference.
let modes = surface.get_supported_present_modes(&adapter);
Timestamp queries are now restricted behind multiple features to allow implementation on TBDR (Tile-Based Deferred Rendering) based GPUs, such as mobile devices and Apple's M chips.
Features::TIMESTAMP_QUERIES
now allows for calling write_timestamp
only on CommandEncoder
s.
Features::WRITE_TIMESTAMP_INSIDE_PASSES
is needed to call write_timestamp
on RenderPassEncoder
s or ComputePassEncoder
s.
The function for mapping buffers no longer returns a future, and instead calls a callback when the buffer is mapped.
This aligns with the use of the API more clearly - you aren't supposed to block and wait on the future to resolve, you are supposed to keep rendering and wait until the buffer maps on its own. Mapping and the flow of mapping is an under-documented area that we hope to improve in the future.
- let future = buffer.slice(..).map_async(MapMode::Read);
+ buffer.slice(..).map_async(MapMode::Read, || {
+ // Called when buffer is mapped.
+ })
Calling queue.submit
now returns an opaque submission index that can be used as an argument to
device.poll
to say which submission to wait to complete.
Device::create_shader_module
now takes the shader descriptor by value:
- device.create_shader_module(&shader_module_descriptor)
+ device.create_shader_module(shader_module_descriptor)
Color attachments can be sparse, so they are now optional:
FragmentState {
- targets: &[color_target_state]
+ targets: &[Some(color_target_state)]
// ..
}
RenderPassDescriptor {
- color_attachments: &[render_pass_color_attachment]
+ color_attachments: &[Some(render_pass_color_attachment)]
// ..
}
RenderBundleEncoderDescriptor {
- color_formats: &[texture_format]
+ color_formats: &[Some(texture_format)]
// ..
}
Extent3d::max_mips
now requires you to pass a TextureDimension to specify whether or not depth_or_array_layers should be ignored:
Extent3d {
width: 1920,
height: 1080,
depth_or_array_layers: 6,
- }.max_mips()
+ }.max_mips(wgpu::TextureDimension::D3)
Limits
has a new field, max_buffer_size
(not an issue if you don't define limits manually):
Limits {
// ...
+ max_buffer_size: 256 * 1024 * 1024, // adjust as you see fit
}
ComputePass::dispatch
has been renamed to ComputePass::dispatch_workgroups
- cpass.dispatch(self.work_group_count, 1, 1)
+ cpass.dispatch_workgroups(self.work_group_count, 1, 1)
util::indirect::*
helper structs by @IcanDivideBy0 in #2365
AddressMode::ClampToZero
by @laptou in #2364
(wgpu)
. by @kpreid in #2590
queue_empty
for Device::poll by @xiaopengli89 in #2643
SHADER_FLOAT16
feature by @jinleili in #2646
vulkan-portability
feature by @jinleili in #2488
Features::MULTI_DRAW_INDIRECT
to Metal by @expenses in #2737
Option<std::time::Duration>
timeouts by @rib in #2724
execute_bundles()
receive IntoIterator by @maku693 in #2410
wgpu_hal::MAX_COLOR_TARGETS
to 8. by @jimblandy in #2640
create_surface
by @jinleili in #2736
wgpu::Device
is dropped. by @jimblandy in #2567
Storage::get
by @SparkyPotato in #2657
WEBGPU_TEXTURE_FORMAT_SUPPORT
to 1 << 14
instead of 1 << 15
by @expenses in #2772
TextureDimensionError::LimitExceeded
. by @kpreid in #2799
#[cfg]
conditions from backend/direct.rs
. by @jimblandy in #2811
wgpu_types::Features
values. by @jimblandy in #2817
Surface::from_uiview
can not guarantee set correct contentScaleFactor
by @jinleili in #2470
max_buffer_size
by the correct physical device restriction by @jinleili in #2502
PrivateCapabilities
creation by @jinleili in #2509
push | pop_debug_marker
by @jinleili in #2537
Rgb9e5Ufloat
capabilities and sampler_lod_average
support by @jinleili in #2656
log::error!
debugging statement from the gles queue by @expenses in #2630
webgl
feature by @jakobhellermann in #2355
GpuFuture
. by @jimblandy in #2644
VertexStepMode
. by @jimblandy in #2685
wgpu_core
's Id
and gfx_select!
. by @jimblandy in #2766
ash
to 0.37
by @a1phyr in #2557
cgmath
to glam
in examples by @a1phyr in #2544
from_index
method is unneeded. by @jimblandy in #2424
new
method for RefCount
. by @jimblandy in #2570
gles::egl
module. by @jimblandy in #2576
timeout_us
to timeout_ns
, to match actual units. by @jimblandy in #2645
Global::create_buffer_error
. by @jimblandy in #2673
VertexStep
: a stride and a step mode. by @jimblandy in #2768