Change default PresentMode and update enable_vsync (#325)

- Fixes #263
This commit is contained in:
Jay Oster 2022-12-17 19:06:15 -08:00 committed by GitHub
parent 9e943dd9eb
commit b4fc48c740
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,7 +68,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
width, width,
height, height,
_pixel_aspect_ratio: 1.0, _pixel_aspect_ratio: 1.0,
present_mode: wgpu::PresentMode::Fifo, present_mode: wgpu::PresentMode::AutoVsync,
surface_texture, surface_texture,
texture_format: wgpu::TextureFormat::Rgba8UnormSrgb, texture_format: wgpu::TextureFormat::Rgba8UnormSrgb,
render_texture_format: None, render_texture_format: None,
@ -125,16 +125,16 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>
/// Enable or disable Vsync. /// Enable or disable Vsync.
/// ///
/// Vsync is enabled by default. /// Vsync is enabled by default. It cannot be disabled on Web targets.
/// ///
/// The `wgpu` present mode will be set to `Fifo` when Vsync is enabled, or `Immediate` when /// The `wgpu` present mode will be set to `AutoVsync` when Vsync is enabled, or `AutoNoVsync`
/// Vsync is disabled. To set the present mode to `Mailbox` or another value, use the /// when Vsync is disabled. To set the present mode to `Mailbox` or another value, use the
/// [`PixelsBuilder::present_mode`] method. /// [`PixelsBuilder::present_mode`] method.
pub fn enable_vsync(mut self, enable_vsync: bool) -> Self { pub fn enable_vsync(mut self, enable_vsync: bool) -> Self {
self.present_mode = if enable_vsync { self.present_mode = if enable_vsync {
wgpu::PresentMode::Fifo wgpu::PresentMode::AutoVsync
} else { } else {
wgpu::PresentMode::Immediate wgpu::PresentMode::AutoNoVsync
}; };
self self
} }