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 PIPELINE_CACHING: bool = false;
const IGNORE_STENCIL: bool = true;
const VSYNC: bool = true;
const DEFAULT_SUBDIVISION: u32 = 16;
const MAXIMUM_SUBDIVISION: u32 = 64;
@@ -678,25 +679,31 @@ impl ApplicationHandler for App {
let window_size = window.inner_size();
let (swapchain, images) = {
let present_modes = self
.device
.physical_device()
.surface_present_modes(&surface, Default::default())
.unwrap();
let present_mode = if VSYNC {
PresentMode::Fifo
} else {
let present_modes = self
.device
.physical_device()
.surface_present_modes(&surface, Default::default())
.unwrap();
let present_mode = present_modes
.into_iter()
.min_by_key(|p| {
// We assign a lower score to device types that are likely to be faster/better.
match p {
PresentMode::Mailbox => 0,
PresentMode::FifoRelaxed => 1,
PresentMode::Immediate => 2,
PresentMode::Fifo => 3,
_ => 4,
}
})
.unwrap();
let present_mode = present_modes
.into_iter()
.min_by_key(|p| {
// We assign a lower score to device types that are likely to be
// faster/better.
match p {
PresentMode::Mailbox => 0,
PresentMode::FifoRelaxed => 1,
PresentMode::Immediate => 2,
PresentMode::Fifo => 3,
_ => 4,
}
})
.unwrap();
present_mode
};
info!("Using present mode {:?}.", present_mode);