par_term_render/cell_renderer/
surface.rs1use super::CellRenderer;
2
3impl CellRenderer {
4 pub fn reconfigure_surface(&mut self) {
5 self.surface.configure(&self.device, &self.config);
6 }
7
8 pub fn supported_present_modes(&self) -> &[wgpu::PresentMode] {
10 &self.supported_present_modes
11 }
12
13 pub fn is_vsync_mode_supported(&self, mode: par_term_config::VsyncMode) -> bool {
15 self.supported_present_modes
16 .contains(&mode.to_present_mode())
17 }
18
19 pub fn update_vsync_mode(
22 &mut self,
23 mode: par_term_config::VsyncMode,
24 ) -> (par_term_config::VsyncMode, bool) {
25 let requested = mode.to_present_mode();
26 let current = self.config.present_mode;
27
28 let actual = if self.supported_present_modes.contains(&requested) {
30 requested
31 } else {
32 log::warn!(
33 "Requested present mode {:?} not supported, falling back to Fifo",
34 requested
35 );
36 wgpu::PresentMode::Fifo
37 };
38
39 if actual != current {
41 self.config.present_mode = actual;
42 self.surface.configure(&self.device, &self.config);
43 log::info!("VSync mode changed to {:?}", actual);
44 }
45
46 let actual_vsync = match actual {
48 wgpu::PresentMode::Immediate => par_term_config::VsyncMode::Immediate,
49 wgpu::PresentMode::Mailbox => par_term_config::VsyncMode::Mailbox,
50 wgpu::PresentMode::Fifo | wgpu::PresentMode::FifoRelaxed => {
51 par_term_config::VsyncMode::Fifo
52 }
53 _ => par_term_config::VsyncMode::Fifo,
54 };
55
56 (actual_vsync, actual != current)
57 }
58
59 pub fn current_vsync_mode(&self) -> par_term_config::VsyncMode {
61 match self.config.present_mode {
62 wgpu::PresentMode::Immediate => par_term_config::VsyncMode::Immediate,
63 wgpu::PresentMode::Mailbox => par_term_config::VsyncMode::Mailbox,
64 wgpu::PresentMode::Fifo | wgpu::PresentMode::FifoRelaxed => {
65 par_term_config::VsyncMode::Fifo
66 }
67 _ => par_term_config::VsyncMode::Fifo,
68 }
69 }
70}