Skip to content

Commit 6093385

Browse files
authored
Update bevy_window::PresentMode to mirror wgpu::PresentMode (#9230)
# Objective - Update `bevy_window::PresentMode` to mirror `wgpu::PresentMode`, Fixes #9151. ## Solution Add `bevy_window::PresentMode::FifoRelaxed` to `bevy_window::PresentMode`, add documents. --- ## Changelog ### Added - Add `bevy_window::PresentMode::FifoRelaxed` to `bevy_window::PresentMode`. ## Migration Guide - Handle `bevy_window::PresentMode::FifoRelaxed` when tweaking window present mode manually.
1 parent ad011d0 commit 6093385

File tree

2 files changed

+58
-19
lines changed

2 files changed

+58
-19
lines changed

crates/bevy_render/src/view/window.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ pub fn prepare_windows(
266266
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
267267
present_mode: match window.present_mode {
268268
PresentMode::Fifo => wgpu::PresentMode::Fifo,
269+
PresentMode::FifoRelaxed => wgpu::PresentMode::FifoRelaxed,
269270
PresentMode::Mailbox => wgpu::PresentMode::Mailbox,
270271
PresentMode::Immediate => wgpu::PresentMode::Immediate,
271272
PresentMode::AutoVsync => wgpu::PresentMode::AutoVsync,

crates/bevy_window/src/window.rs

Lines changed: 57 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ pub enum MonitorSelection {
801801
/// [`Immediate`] or [`Mailbox`] will panic if not supported by the platform.
802802
///
803803
/// [`Fifo`]: PresentMode::Fifo
804+
/// [`FifoRelaxed`]: PresentMode::FifoRelaxed
804805
/// [`Immediate`]: PresentMode::Immediate
805806
/// [`Mailbox`]: PresentMode::Mailbox
806807
/// [`AutoVsync`]: PresentMode::AutoVsync
@@ -819,30 +820,67 @@ pub enum PresentMode {
819820
/// Chooses FifoRelaxed -> Fifo based on availability.
820821
///
821822
/// Because of the fallback behavior, it is supported everywhere.
822-
AutoVsync = 0,
823+
AutoVsync = 0, // NOTE: The explicit ordinal values mirror wgpu.
823824
/// Chooses Immediate -> Mailbox -> Fifo (on web) based on availability.
824825
///
825826
/// Because of the fallback behavior, it is supported everywhere.
826827
AutoNoVsync = 1,
827-
/// The presentation engine does **not** wait for a vertical blanking period and
828-
/// the request is presented immediately. This is a low-latency presentation mode,
829-
/// but visible tearing may be observed. Not optimal for mobile.
830-
///
831-
/// Selecting this variant will panic if not supported, it is preferred to use
832-
/// [`PresentMode::AutoNoVsync`].
833-
Immediate = 2,
834-
/// The presentation engine waits for the next vertical blanking period to update
835-
/// the current image, but frames may be submitted without delay. This is a low-latency
836-
/// presentation mode and visible tearing will **not** be observed. Not optimal for mobile.
837-
///
838-
/// Selecting this variant will panic if not supported, it is preferred to use
839-
/// [`PresentMode::AutoNoVsync`].
840-
Mailbox = 3,
841-
/// The presentation engine waits for the next vertical blanking period to update
842-
/// the current image. The framerate will be capped at the display refresh rate,
843-
/// corresponding to the `VSync`. Tearing cannot be observed. Optimal for mobile.
828+
/// Presentation frames are kept in a First-In-First-Out queue approximately 3 frames
829+
/// long. Every vertical blanking period, the presentation engine will pop a frame
830+
/// off the queue to display. If there is no frame to display, it will present the same
831+
/// frame again until the next vblank.
832+
///
833+
/// When a present command is executed on the gpu, the presented image is added on the queue.
834+
///
835+
/// No tearing will be observed.
836+
///
837+
/// Calls to get_current_texture will block until there is a spot in the queue.
838+
///
839+
/// Supported on all platforms.
840+
///
841+
/// If you don't know what mode to choose, choose this mode. This is traditionally called "Vsync On".
844842
#[default]
845-
Fifo = 4, // NOTE: The explicit ordinal values mirror wgpu.
843+
Fifo = 2,
844+
/// Presentation frames are kept in a First-In-First-Out queue approximately 3 frames
845+
/// long. Every vertical blanking period, the presentation engine will pop a frame
846+
/// off the queue to display. If there is no frame to display, it will present the
847+
/// same frame until there is a frame in the queue. The moment there is a frame in the
848+
/// queue, it will immediately pop the frame off the queue.
849+
///
850+
/// When a present command is executed on the gpu, the presented image is added on the queue.
851+
///
852+
/// Tearing will be observed if frames last more than one vblank as the front buffer.
853+
///
854+
/// Calls to get_current_texture will block until there is a spot in the queue.
855+
///
856+
/// Supported on AMD on Vulkan.
857+
///
858+
/// This is traditionally called "Adaptive Vsync"
859+
FifoRelaxed = 3,
860+
/// Presentation frames are not queued at all. The moment a present command
861+
/// is executed on the GPU, the presented image is swapped onto the front buffer
862+
/// immediately.
863+
///
864+
/// Tearing can be observed.
865+
///
866+
/// Supported on most platforms except older DX12 and Wayland.
867+
///
868+
/// This is traditionally called "Vsync Off".
869+
Immediate = 4,
870+
/// Presentation frames are kept in a single-frame queue. Every vertical blanking period,
871+
/// the presentation engine will pop a frame from the queue. If there is no frame to display,
872+
/// it will present the same frame again until the next vblank.
873+
///
874+
/// When a present command is executed on the gpu, the frame will be put into the queue.
875+
/// If there was already a frame in the queue, the new frame will _replace_ the old frame
876+
/// on the queue.
877+
///
878+
/// No tearing will be observed.
879+
///
880+
/// Supported on DX11/12 on Windows 10, NVidia on Vulkan and Wayland on Vulkan.
881+
///
882+
/// This is traditionally called "Fast Vsync"
883+
Mailbox = 5,
846884
}
847885

848886
/// Specifies how the alpha channel of the textures should be handled during compositing, for a [`Window`].

0 commit comments

Comments
 (0)