Skip to content

Commit

Permalink
impl Default for SurfaceConfiguration, simplify the use of users.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Sep 19, 2022
1 parent 41006d7 commit 1d5ee0a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 1 addition & 2 deletions wgpu/examples/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,11 @@ fn start<E: Example>(
) {
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);

Expand Down

0 comments on commit 1d5ee0a

Please sign in to comment.