@@ -5,6 +5,40 @@ use raw_window_handle::RawWindowHandle;
5
5
#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
6
6
pub struct WindowId ( Uuid ) ;
7
7
8
+ /// Presentation mode for a window.
9
+ ///
10
+ /// The presentation mode specifies when a frame is presented to the window. The `Fifo`
11
+ /// option corresponds to a traditional `VSync`, where the framerate is capped by the
12
+ /// display refresh rate. Both `Immediate` and `Mailbox` are low-latency and are not
13
+ /// capped by the refresh rate, but may not be available on all platforms. Tearing
14
+ /// may be observed with `Immediate` mode, but will not be observed with `Mailbox` or
15
+ /// `Fifo`.
16
+ ///
17
+ /// `Immediate` or `Mailbox` will gracefully fallback to `Fifo` when unavailable.
18
+ ///
19
+ /// The presentation mode may be declared in the
20
+ /// [`WindowSetupDescriptor`](WindowSetupDescriptor::present_mode) or updated on a
21
+ /// [`Window`](Window::set_present_mode).
22
+ #[ repr( C ) ]
23
+ #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
24
+ #[ doc( alias = "vsync" ) ]
25
+ pub enum PresentMode {
26
+ /// The presentation engine does **not** wait for a vertical blanking period and
27
+ /// the request is presented immediately. This is a low-latency presentation mode,
28
+ /// but visible tearing may be observed. Will fallback to `Fifo` if unavailable on the
29
+ /// selected platform and backend. Not optimal for mobile.
30
+ Immediate = 0 ,
31
+ /// The presentation engine waits for the next vertical blanking period to update
32
+ /// the current image, but frames may be submitted without delay. This is a low-latency
33
+ /// presentation mode and visible tearing will **not** be observed. Will fallback to `Fifo`
34
+ /// if unavailable on the selected platform and backend. Not optimal for mobile.
35
+ Mailbox = 1 ,
36
+ /// The presentation engine waits for the next vertical blanking period to update
37
+ /// the current image. The framerate will be capped at the display refresh rate,
38
+ /// corresponding to the `VSync`. Tearing cannot be observed. Optimal for mobile.
39
+ Fifo = 2 , // NOTE: The explicit ordinal values mirror wgpu and the vulkan spec.
40
+ }
41
+
8
42
impl WindowId {
9
43
pub fn new ( ) -> Self {
10
44
WindowId ( Uuid :: new_v4 ( ) )
0 commit comments