diff options
| author | Micha White <botahamec@outlook.com> | 2022-10-11 21:42:10 -0400 |
|---|---|---|
| committer | Micha White <botahamec@outlook.com> | 2022-10-11 21:42:10 -0400 |
| commit | 76ed4fe2d3f96c1c25905875a0d5dacc5ff7ed8a (patch) | |
| tree | b327a5decfc7a7706c8911f050545556135f1aa5 /src/config.rs | |
| parent | 19811a235d8b6791e4a70a89c0cd21a928de6e95 (diff) | |
Big performance improvement
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 15 |
1 files changed, 13 insertions, 2 deletions
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, } } |
