|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
Centralized timeline semaphore management for the rendering pipeline. More...
#include <TimelineSynchronizer.h>
Public Member Functions | |
| TimelineSynchronizer (ApplicationContext *context, uint32_t framesInFlight) | |
| Constructs a timeline synchronizer. | |
| ~TimelineSynchronizer () | |
| TimelineSynchronizer (const TimelineSynchronizer &)=delete | |
| TimelineSynchronizer & | operator= (const TimelineSynchronizer &)=delete |
| TimelineSynchronizer (TimelineSynchronizer &&other) noexcept | |
| TimelineSynchronizer & | operator= (TimelineSynchronizer &&other) noexcept |
| uint64_t | getStageValue (uint64_t frameNumber, PipelineStage stage) const |
| Gets the timeline value for a specific stage at a specific frame. | |
| std::optional< uint64_t > | getWaitValue (uint64_t currentFrame, PipelineStage waitForStage, uint32_t framesBack=1) const |
| Gets the value to wait for from a previous frame's stage. | |
| std::optional< uint64_t > | getResourceReuseWaitValue (uint64_t currentFrame, PipelineStage waitForStage) const |
| Gets the wait value for resource reuse (frames-in-flight synchronization) | |
| uint64_t | getCurrentValue () const |
| Gets the current GPU timeline semaphore value. | |
| void | waitForValue (uint64_t value, uint64_t timeout=UINT64_MAX) const |
| CPU-side wait for a specific timeline value. | |
| void | waitForStage (uint64_t frameNumber, PipelineStage stage, uint64_t timeout=UINT64_MAX) const |
| CPU-side wait for a specific stage to complete. | |
| void | signalValue (uint64_t value) const |
| CPU-side signal of the timeline semaphore. | |
| VkSemaphore | getSemaphore () const |
| Gets the underlying Vulkan timeline semaphore. | |
| uint32_t | getFramesInFlight () const |
| Gets the number of frames in flight. | |
Private Attributes | |
| ApplicationContext * | context_ = nullptr |
| VkSemaphore | timelineSemaphore_ = VK_NULL_HANDLE |
| uint32_t | framesInFlight_ = 0 |
Centralized timeline semaphore management for the rendering pipeline.
Manages a single timeline semaphore used for synchronizing all pipeline stages. Timeline values are computed using the formula: timelineValue = frameNumber * PIPELINE_STAGE_COUNT + stageIndex
This provides:
Definition at line 28 of file TimelineSynchronizer.h.
|
explicit |
Constructs a timeline synchronizer.
| context | The application context for Vulkan device access |
| framesInFlight | Number of frames that can be processed concurrently |
Definition at line 10 of file TimelineSynchronizer.cpp.
References context_, framesInFlight_, and timelineSemaphore_.
Referenced by operator=(), operator=(), TimelineSynchronizer(), and TimelineSynchronizer().
| EngineCore::TimelineSynchronizer::~TimelineSynchronizer | ( | ) |
Definition at line 39 of file TimelineSynchronizer.cpp.
References context_, and timelineSemaphore_.
|
delete |
|
noexcept |
Definition at line 48 of file TimelineSynchronizer.cpp.
References context_, framesInFlight_, timelineSemaphore_, and TimelineSynchronizer().
|
nodiscard |
Gets the current GPU timeline semaphore value.
Definition at line 81 of file TimelineSynchronizer.cpp.
References context_, and timelineSemaphore_.
|
inlinenodiscard |
Gets the number of frames in flight.
Definition at line 152 of file TimelineSynchronizer.h.
References framesInFlight_.
|
inlinenodiscard |
Gets the wait value for resource reuse (frames-in-flight synchronization)
Waits for the frame that last used this resource slot. Use this when waiting to reuse per-frame resources like command buffers or staging buffers.
| currentFrame | The current frame number |
| waitForStage | The stage to wait for |
Definition at line 93 of file TimelineSynchronizer.h.
References framesInFlight_, getStageValue(), and waitForStage().
|
inlinenodiscard |
Gets the underlying Vulkan timeline semaphore.
Definition at line 146 of file TimelineSynchronizer.h.
References timelineSemaphore_.
|
inlinenodiscard |
Gets the timeline value for a specific stage at a specific frame.
| frameNumber | The absolute frame number |
| stage | The pipeline stage |
Definition at line 56 of file TimelineSynchronizer.h.
References EngineCore::PIPELINE_STAGE_COUNT.
Referenced by getResourceReuseWaitValue(), getWaitValue(), and waitForStage().
|
inlinenodiscard |
Gets the value to wait for from a previous frame's stage.
| currentFrame | The current frame number |
| waitForStage | The stage to wait for |
| framesBack | How many frames back to wait (default: 1) |
Definition at line 71 of file TimelineSynchronizer.h.
References getStageValue(), and waitForStage().
|
delete |
|
noexcept |
Definition at line 58 of file TimelineSynchronizer.cpp.
References context_, framesInFlight_, timelineSemaphore_, and TimelineSynchronizer().
| void EngineCore::TimelineSynchronizer::signalValue | ( | uint64_t | value | ) | const |
CPU-side signal of the timeline semaphore.
Use this during shutdown to unblock GPU work that is waiting on timeline semaphore values that will never be signaled by subsequent GPU submissions.
| value | The value to signal (must be greater than current value) |
Definition at line 106 of file TimelineSynchronizer.cpp.
References context_, and timelineSemaphore_.
|
inline |
CPU-side wait for a specific stage to complete.
| frameNumber | The frame number |
| stage | The pipeline stage |
| timeout | Maximum wait time in nanoseconds (default: infinite) |
Definition at line 125 of file TimelineSynchronizer.h.
References getStageValue(), and waitForValue().
Referenced by getResourceReuseWaitValue(), and getWaitValue().
| void EngineCore::TimelineSynchronizer::waitForValue | ( | uint64_t | value, |
| uint64_t | timeout = UINT64_MAX ) const |
CPU-side wait for a specific timeline value.
| value | The value to wait for |
| timeout | Maximum wait time in nanoseconds (default: infinite) |
Definition at line 88 of file TimelineSynchronizer.cpp.
References context_, and timelineSemaphore_.
Referenced by waitForStage().
|
private |
Definition at line 155 of file TimelineSynchronizer.h.
Referenced by getCurrentValue(), operator=(), signalValue(), TimelineSynchronizer(), TimelineSynchronizer(), waitForValue(), and ~TimelineSynchronizer().
|
private |
Definition at line 157 of file TimelineSynchronizer.h.
Referenced by getFramesInFlight(), getResourceReuseWaitValue(), operator=(), TimelineSynchronizer(), and TimelineSynchronizer().
|
private |
Definition at line 156 of file TimelineSynchronizer.h.
Referenced by getCurrentValue(), getSemaphore(), operator=(), signalValue(), TimelineSynchronizer(), TimelineSynchronizer(), waitForValue(), and ~TimelineSynchronizer().