KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rhi_present_mode.h File Reference
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

Go to the source code of this file.

Enumerations

enum class  RHI_PRESENT_MODE : uint8_t { FIFO , MAILBOX , IMMEDIATE }
 How a swapchain hands finished images to the display. More...
 

Functions

RHI_PRESENT_MODE RhiChoosePresentMode (const std::vector< RHI_PRESENT_MODE > &aOffered, bool aComposited, bool aImmediateUnderCompositor=false)
 Choose the present mode for a swapchain from the modes the surface offers.
 
template<typename TIME_POINT>
TIME_POINT RhiNextFrameAt (TIME_POINT aFrameStart, double aRefreshHz, std::optional< TIME_POINT > aVblank)
 The earliest time the frame after one started at aFrameStart may start, for a window whose presents do not wait for the display.
 

Variables

constexpr int RHI_PRESENTS_IN_FLIGHT = 2
 Presents allowed to wait for the display at once while frames are paced.
 

Enumeration Type Documentation

◆ RHI_PRESENT_MODE

enum class RHI_PRESENT_MODE : uint8_t
strong

How a swapchain hands finished images to the display.

Enumerator
FIFO 

Waits for a vertical blank, never tears, adds up to a refresh of latency.

MAILBOX 

Replaces the queued image at each blank, never tears, no wait.

IMMEDIATE 

Shows the image at once, tears unless a compositor owns the final present.

Definition at line 40 of file rhi_present_mode.h.

Function Documentation

◆ RhiChoosePresentMode()

RHI_PRESENT_MODE RhiChoosePresentMode ( const std::vector< RHI_PRESENT_MODE > & aOffered,
bool aComposited,
bool aImmediateUnderCompositor = false )
inline

Choose the present mode for a swapchain from the modes the surface offers.

MAILBOX is preferred. Without it a composited window uses IMMEDIATE, since the compositor's vsynced frame keeps it from tearing, and anything else uses FIFO, which every surface offers. With aImmediateUnderCompositor a composited window prefers IMMEDIATE over MAILBOX because Mesa's MAILBOX adds latency under a compositor.

Parameters
aCompositedtrue when a compositor owns the final present.
aImmediateUnderCompositortrue on Linux.

Definition at line 59 of file rhi_present_mode.h.

References FIFO, IMMEDIATE, and MAILBOX.

Referenced by RHI_VULKAN_DEVICE::ChoosePresentMode().

◆ RhiNextFrameAt()

template<typename TIME_POINT>
TIME_POINT RhiNextFrameAt ( TIME_POINT aFrameStart,
double aRefreshHz,
std::optional< TIME_POINT > aVblank )

The earliest time the frame after one started at aFrameStart may start, for a window whose presents do not wait for the display.

With a known vertical blank this is the next blank after aFrameStart, so at most one frame starts per refresh and frames do not drift against the display. Without one it is a refresh later.

Parameters
aRefreshHzthe display's refresh rate, above zero.
aVblanka time the display refreshed, before or after aFrameStart.

Division truncates towards zero, and a blank reported after the frame start needs the floor.

Definition at line 91 of file rhi_present_mode.h.

Referenced by KIGFX::RENDER_THREAD::ProcessActiveWindows().

Variable Documentation

◆ RHI_PRESENTS_IN_FLIGHT

int RHI_PRESENTS_IN_FLIGHT = 2
constexpr

Presents allowed to wait for the display at once while frames are paced.

Definition at line 34 of file rhi_present_mode.h.

Referenced by KIGFX::RENDER_THREAD::ProcessActiveWindows().