enabel vsync

This commit is contained in:
2025-12-20 22:37:27 +00:00
parent b4e8715111
commit ab79317262
+25 -18
View File
@@ -4,6 +4,7 @@
const DUMP_SPV_TO_FILE: bool = false; const DUMP_SPV_TO_FILE: bool = false;
const PIPELINE_CACHING: bool = false; const PIPELINE_CACHING: bool = false;
const IGNORE_STENCIL: bool = true; const IGNORE_STENCIL: bool = true;
const VSYNC: bool = true;
const DEFAULT_SUBDIVISION: u32 = 16; const DEFAULT_SUBDIVISION: u32 = 16;
const MAXIMUM_SUBDIVISION: u32 = 64; const MAXIMUM_SUBDIVISION: u32 = 64;
@@ -678,25 +679,31 @@ impl ApplicationHandler for App {
let window_size = window.inner_size(); let window_size = window.inner_size();
let (swapchain, images) = { let (swapchain, images) = {
let present_modes = self let present_mode = if VSYNC {
.device PresentMode::Fifo
.physical_device() } else {
.surface_present_modes(&surface, Default::default()) let present_modes = self
.unwrap(); .device
.physical_device()
.surface_present_modes(&surface, Default::default())
.unwrap();
let present_mode = present_modes let present_mode = present_modes
.into_iter() .into_iter()
.min_by_key(|p| { .min_by_key(|p| {
// We assign a lower score to device types that are likely to be faster/better. // We assign a lower score to device types that are likely to be
match p { // faster/better.
PresentMode::Mailbox => 0, match p {
PresentMode::FifoRelaxed => 1, PresentMode::Mailbox => 0,
PresentMode::Immediate => 2, PresentMode::FifoRelaxed => 1,
PresentMode::Fifo => 3, PresentMode::Immediate => 2,
_ => 4, PresentMode::Fifo => 3,
} _ => 4,
}) }
.unwrap(); })
.unwrap();
present_mode
};
info!("Using present mode {:?}.", present_mode); info!("Using present mode {:?}.", present_mode);