20#ifndef RHI_PRESENT_MODE_H
21#define RHI_PRESENT_MODE_H
60 bool aImmediateUnderCompositor =
false )
64 return std::find( aOffered.begin(), aOffered.end(), aMode ) != aOffered.end();
90template <
typename TIME_POINT>
91TIME_POINT
RhiNextFrameAt( TIME_POINT aFrameStart,
double aRefreshHz, std::optional<TIME_POINT> aVblank )
93 using DURATION =
typename TIME_POINT::duration;
95 const DURATION period = std::chrono::round<DURATION>( std::chrono::duration<double>( 1.0 / aRefreshHz ) );
97 if( !aVblank || period <= DURATION::zero() )
98 return aFrameStart + period;
100 const DURATION since = aFrameStart - *aVblank;
101 auto refreshes = since / period;
106 if( since < DURATION::zero() && refreshes * period != since )
109 return *aVblank + ( refreshes + 1 ) * period;
RHI_PRESENT_MODE
How a swapchain hands finished images to the display.
@ MAILBOX
Replaces the queued image at each blank, never tears, no wait.
@ FIFO
Waits for a vertical blank, never tears, adds up to a refresh of latency.
@ IMMEDIATE
Shows the image at once, tears unless a compositor owns the final present.
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 d...
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.
constexpr int RHI_PRESENTS_IN_FLIGHT
Presents allowed to wait for the display at once while frames are paced.