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 18, 2022
1 parent b752c7d commit 7024df7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ the same every time it is rendered, we now warn if it is missing.
- 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
12 changes: 12 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3085,6 +3085,18 @@ pub struct SurfaceConfiguration {
pub present_mode: PresentMode,
}

impl Default for SurfaceConfiguration {
fn default() -> Self {
Self {
usage: crate::TextureUsages::RENDER_ATTACHMENT,
format: TextureFormat::Bgra8UnormSrgb,
width: 0,
height: 0,
present_mode: PresentMode::Fifo,
}
}
}

/// 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,11 +268,10 @@ 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,
..Default::default()
};
surface.configure(&device, &config);

Expand Down

0 comments on commit 7024df7

Please sign in to comment.