diff --git a/core/src/settings.rs b/core/src/settings.rs index 68d88864..1b86c50e 100644 --- a/core/src/settings.rs +++ b/core/src/settings.rs @@ -33,6 +33,13 @@ pub struct Settings { /// /// By default, it is enabled. pub antialiasing: bool, + + /// Whether or not to attempt to synchronize rendering when possible. + /// + /// Disabling it can improve rendering performance on some platforms. + /// + /// By default, it is enabled. + pub vsync: bool, } impl Default for Settings { @@ -43,6 +50,7 @@ impl Default for Settings { default_font: Font::default(), default_text_size: Pixels(16.0), antialiasing: true, + vsync: true, } } } diff --git a/graphics/src/settings.rs b/graphics/src/settings.rs index 0b1881c9..ff4a9c75 100644 --- a/graphics/src/settings.rs +++ b/graphics/src/settings.rs @@ -16,6 +16,11 @@ pub struct Settings { /// /// By default, it is `None`. pub antialiasing: Option, + + /// Whether or not to synchronize frames. + /// + /// By default, it is `true`. + pub vsync: bool, } impl Default for Settings { @@ -24,6 +29,7 @@ impl Default for Settings { default_font: Font::default(), default_text_size: Pixels(16.0), antialiasing: None, + vsync: true, } } } diff --git a/wgpu/src/settings.rs b/wgpu/src/settings.rs index b3c3cf6a..646263b7 100644 --- a/wgpu/src/settings.rs +++ b/wgpu/src/settings.rs @@ -44,6 +44,11 @@ impl Default for Settings { impl From for Settings { fn from(settings: graphics::Settings) -> Self { Self { + present_mode: if settings.vsync { + wgpu::PresentMode::AutoVsync + } else { + wgpu::PresentMode::AutoNoVsync + }, default_font: settings.default_font, default_text_size: settings.default_text_size, antialiasing: settings.antialiasing,