20#ifndef RHI_SWAPCHAIN_CONTROLLER_H
21#define RHI_SWAPCHAIN_CONTROLLER_H
47 using CLOCK = std::chrono::steady_clock;
60 RHI_PHASE_STALL_TRACKER::CLOCK::time_point aNow,
61 std::chrono::milliseconds aStallThreshold = std::chrono::milliseconds( 1000 ),
62 uint64_t aGenerationThreshold = 60,
63 std::chrono::milliseconds aRepeatThreshold = std::chrono::milliseconds( 1000 ) )
68 bool firstObservation = aTracker.
phaseStartTime.time_since_epoch().count() == 0;
72 if( firstObservation || phaseChanged || generationRewound )
82 result.stallAge = std::chrono::duration_cast<std::chrono::milliseconds>(
85 if(
result.stalledGenerations < aGenerationThreshold
86 ||
result.stallAge < aStallThreshold )
91 if( aTracker.
lastLogTime.time_since_epoch().count() != 0
92 && std::chrono::duration_cast<std::chrono::milliseconds>(
124 uint32_t aWidth, uint32_t aHeight,
float aDpiScale = 1.0f );
129 bool OnResize( uint32_t aWidth, uint32_t aHeight,
float aDpiScale = 1.0f );
143 std::chrono::milliseconds aTimeout = std::chrono::milliseconds( 2000 ) );
Lock-free single-slot mailbox carrying frame state from the main thread to the render thread.
Thread that owns the RHI device.
SWAPCHAIN_CONTROLLER(RENDER_THREAD &aRenderThread, RHI_WINDOW_ID aWindowId)
SWAPCHAIN_CONTROLLER(const SWAPCHAIN_CONTROLLER &)=delete
uint64_t m_lastLoggedGeneration
void SetRefreshRate(float aHz)
Display refresh rate sent with each frame request, 0 when unknown.
RHI_PHASE_STALL_TRACKER m_phaseStallTracker
RENDER_THREAD & m_renderThread
FRAME_MAILBOX * m_frameMailbox
void SetFrameMailbox(FRAME_MAILBOX *aMailbox)
bool OnResize(uint32_t aWidth, uint32_t aHeight, float aDpiScale=1.0f)
SWAPCHAIN_CONTROLLER & operator=(const SWAPCHAIN_CONTROLLER &)=delete
bool OnCloseSync(std::chrono::milliseconds aTimeout=std::chrono::milliseconds(2000))
Close and wait for the render thread to release the window's GPU resources, so the native window can ...
bool OnPaint(const RHI_NATIVE_WINDOW_HANDLE &aHandle, uint32_t aWidth, uint32_t aHeight, float aDpiScale=1.0f)
The first call creates the swapchain.
The Cairo implementation of the graphics abstraction layer.
RHI_PHASE_STALL_RESULT EvaluateRenderThreadPhaseStall(RHI_PHASE_STALL_TRACKER &aTracker, int aPhase, uint64_t aGeneration, RHI_PHASE_STALL_TRACKER::CLOCK::time_point aNow, std::chrono::milliseconds aStallThreshold=std::chrono::milliseconds(1000), uint64_t aGenerationThreshold=60, std::chrono::milliseconds aRepeatThreshold=std::chrono::milliseconds(1000))
uint32_t RHI_WINDOW_ID
Routes control commands to a swapchain.
std::chrono::milliseconds stallAge
uint64_t stalledGenerations
CLOCK::time_point phaseStartTime
std::chrono::steady_clock CLOCK
CLOCK::time_point lastLogTime
uint64_t generationAtPhaseStart
Platform-agnostic wrapper for a native window handle.
wxString result
Test unit parsing edge cases and error handling.