From 76ed4fe2d3f96c1c25905875a0d5dacc5ff7ed8a Mon Sep 17 00:00:00 2001 From: Micha White Date: Tue, 11 Oct 2022 21:42:10 -0400 Subject: Big performance improvement --- src/config.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 7eedb21..9376049 100644 --- a/src/config.rs +++ b/src/config.rs @@ -101,6 +101,14 @@ impl<'a> RenderWindowConfig<'a> { } } + fn alpha_mode(supported_modes: &[wgpu::CompositeAlphaMode]) -> wgpu::CompositeAlphaMode { + if supported_modes.contains(&wgpu::CompositeAlphaMode::PostMultiplied) { + wgpu::CompositeAlphaMode::PostMultiplied + } else { + wgpu::CompositeAlphaMode::Auto + } + } + /// Create a `WindowBuilder` from the configuration given. This window is /// initially invisible and must later be made visible. pub(crate) fn to_window(&self) -> WindowBuilder { @@ -154,10 +162,12 @@ impl<'a> RenderWindowConfig<'a> { /// Gets a surface configuration out of the config. pub(crate) fn to_surface_configuration( &self, - supported_modes: &[wgpu::PresentMode], + supported_present_modes: &[wgpu::PresentMode], + supported_alpha_modes: &[wgpu::CompositeAlphaMode], texture_format: wgpu::TextureFormat, ) -> wgpu::SurfaceConfiguration { - let present_mode = Self::present_mode(self.vsync, supported_modes); + let present_mode = Self::present_mode(self.vsync, supported_present_modes); + let alpha_mode = Self::alpha_mode(supported_alpha_modes); // configuration for the surface wgpu::SurfaceConfiguration { @@ -165,6 +175,7 @@ impl<'a> RenderWindowConfig<'a> { format: texture_format, width: self.default_width.get(), height: self.default_height.get(), + alpha_mode, present_mode, } } -- cgit v1.2.3