This commit is contained in:
2021-11-03 05:01:42 +01:00
parent 9125878840
commit d995d66f89
2 changed files with 23 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ use std::{convert::TryInto, fs};
use serde_derive::{Deserialize, Serialize};
use toml;
use vulkano::image::SampleCount;
use vulkano::{image::SampleCount, swapchain::PresentMode};
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub struct LogConfigInput {
@@ -27,7 +27,8 @@ impl LogConfig {
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub struct RenderConfig {
pub msaa_samples: u32
pub msaa_samples: u32,
pub vsync: PresentModeConfig,
}
impl RenderConfig {
@@ -39,3 +40,22 @@ impl RenderConfig {
if self.msaa_samples > 0 { self.msaa_samples.try_into().ok() } else { None }
}
}
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
pub enum PresentModeConfig {
Immediate,
Mailbox,
Fifo,
FifoRelaxed,
}
impl Into<PresentMode> for PresentModeConfig {
fn into(self) -> PresentMode {
match self {
PresentModeConfig::Immediate => PresentMode::Immediate,
PresentModeConfig::Mailbox => PresentMode::Mailbox,
PresentModeConfig::Fifo => PresentMode::Fifo,
PresentModeConfig::FifoRelaxed => PresentMode::Relaxed,
}
}
}

View File

@@ -245,7 +245,7 @@ impl VulkanRenderer {
.sharing_mode(&queue)
.transform(SurfaceTransform::Identity)
.composite_alpha(alpha)
.present_mode(PresentMode::Fifo)
.present_mode(render_config.vsync.into())
.fullscreen_exclusive(FullscreenExclusive::Default)
.clipped(true)
.color_space(color_space)