diff --git a/CHANGELOG.md b/CHANGELOG.md index d88698cc38..c200200796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -109,6 +109,7 @@ SurfaceConfiguration { - Update Winit to version 0.27 and raw-window-handle to 0.5 by @wyatt-herkamp in [#2918](https://github.com/gfx-rs/wgpu/pull/2918) - Address Clippy 0.1.63 complaints. By @jimblandy in [#2977](https://github.com/gfx-rs/wgpu/pull/2977) - Don't use `PhantomData` for `IdentityManager`'s `Input` type. By @jimblandy in [#2972](https://github.com/gfx-rs/wgpu/pull/2972) +- Impl Default for `SurfaceConfiguration`, simplify the use of users. By @jinleili in [#3034](https://github.com/gfx-rs/wgpu/pull/3034) #### Metal - Extract the generic code into `get_metal_layer` by @jinleili in [#2826](https://github.com/gfx-rs/wgpu/pull/2826) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 1b698bd9d4..37daff37da 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -3122,6 +3122,19 @@ pub struct SurfaceConfiguration { pub alpha_mode: CompositeAlphaMode, } +impl Default for SurfaceConfiguration { + fn default() -> Self { + Self { + usage: crate::TextureUsages::RENDER_ATTACHMENT, + format: TextureFormat::Bgra8UnormSrgb, + width: 0, + height: 0, + present_mode: PresentMode::AutoNoVsync, + alpha_mode: CompositeAlphaMode::Auto, + } + } +} + /// Status of the recieved surface image. #[repr(C)] #[derive(Debug)] diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index 795765e653..74807f0ea9 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -268,12 +268,11 @@ fn start( ) { let spawner = Spawner::new(); let mut config = wgpu::SurfaceConfiguration { - usage: wgpu::TextureUsages::RENDER_ATTACHMENT, format: surface.get_supported_formats(&adapter)[0], width: size.width, height: size.height, - present_mode: wgpu::PresentMode::Fifo, alpha_mode: surface.get_supported_alpha_modes(&adapter)[0], + ..Default::default() }; surface.configure(&device, &config);