From 9e5e2aaf0d23727fb80f19aecb90d3fef4cd0a75 Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Sun, 18 Sep 2022 20:23:14 +0800 Subject: [PATCH] impl Default for `SurfaceConfiguration`, simplify the use of users. --- wgpu-types/src/lib.rs | 12 ++++++++++++ wgpu/examples/framework.rs | 4 +--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 8718d797942..719c8826a66 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -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)] diff --git a/wgpu/examples/framework.rs b/wgpu/examples/framework.rs index 0d8ed6df4b2..6035761d131 100644 --- a/wgpu/examples/framework.rs +++ b/wgpu/examples/framework.rs @@ -539,11 +539,9 @@ pub fn test(mut params: FrameworkRefTest) { let mut example = E::init( &wgpu::SurfaceConfiguration { - usage: wgpu::TextureUsages::RENDER_ATTACHMENT, - format: wgpu::TextureFormat::Rgba8UnormSrgb, width: params.width, height: params.height, - present_mode: wgpu::PresentMode::Fifo, + ..Default::default() }, &ctx.adapter, &ctx.device,