Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
VulkanFrameSync Class Reference

Manages Vulkan semaphores and fences to synchronize frames in flight. More...

#include <VulkanFrameSync.hpp>

Public Member Functions

 VulkanFrameSync ()=default
 Construct a new Vulkan Frame Sync object.
 ~VulkanFrameSync ()
 Destroy the Vulkan Frame Sync object and release sync objects.
 VulkanFrameSync (const VulkanFrameSync &)=delete
VulkanFrameSync & operator= (const VulkanFrameSync &)=delete
void create (VkDevice device, uint32_t maxFramesInFlight=2)
 Allocates synchronization semaphores and fences.
void destroy ()
 Safely destroys synchronization primitives.
VkSemaphore getImageAvailableSemaphore () const
 Gets image acquisition semaphore.
VkSemaphore getRenderFinishedSemaphore () const
 Gets render completion semaphore.
VkFence getInFlightFence () const
 Gets current in-flight queue submission fence.
void waitForCurrentFrame ()
 Blocks host execution until current frame fence is signaled, then resets it.
void nextFrame ()
 Progresses the frame index counter.
uint32_t getCurrentFrameIndex () const
 Gets current active double-buffered index.

Private Attributes

VkDevice device = VK_NULL_HANDLE
 Reference to logical device.
uint32_t maxFrames = 0
 Max frames allowed in flight.
uint32_t currentFrame = 0
 Active frame index.
std::vector< VkSemaphore > imageAvailableSemaphores
 Semaphores waiting for image availability.
std::vector< VkSemaphore > renderFinishedSemaphores
 Semaphores waiting for render passes to complete.
std::vector< VkFence > inFlightFences
 Fences waiting for queue work execution completion.

Detailed Description

Manages Vulkan semaphores and fences to synchronize frames in flight.

Constructor & Destructor Documentation

◆ VulkanFrameSync() [1/2]

VulkanFrameSync::VulkanFrameSync ( )
default

Construct a new Vulkan Frame Sync object.

◆ ~VulkanFrameSync()

VulkanFrameSync::~VulkanFrameSync ( )

Destroy the Vulkan Frame Sync object and release sync objects.

Destroy the Vulkan Frame Sync:: Vulkan Frame Sync object.

◆ VulkanFrameSync() [2/2]

VulkanFrameSync::VulkanFrameSync ( const VulkanFrameSync & )
delete

Member Function Documentation

◆ create()

void VulkanFrameSync::create ( VkDevice dev,
uint32_t maxFramesInFlight = 2 )

Allocates synchronization semaphores and fences.

Creates synchronization objects (semaphores, fences) for in-flight frames.

Parameters
deviceVulkan logical device context.
maxFramesInFlightMaximum frame buffers in flight concurrently.
devLogical device context.
maxFramesInFlightMaximum frames allowed concurrently in flight.

◆ destroy()

void VulkanFrameSync::destroy ( )

Safely destroys synchronization primitives.

Safely destroys synchronization semaphores and fences.

◆ getCurrentFrameIndex()

uint32_t VulkanFrameSync::getCurrentFrameIndex ( ) const
inline

Gets current active double-buffered index.

Returns
Index value.

◆ getImageAvailableSemaphore()

VkSemaphore VulkanFrameSync::getImageAvailableSemaphore ( ) const
inline

Gets image acquisition semaphore.

Returns
VkSemaphore handle.

◆ getInFlightFence()

VkFence VulkanFrameSync::getInFlightFence ( ) const
inline

Gets current in-flight queue submission fence.

Returns
VkFence handle.

◆ getRenderFinishedSemaphore()

VkSemaphore VulkanFrameSync::getRenderFinishedSemaphore ( ) const
inline

Gets render completion semaphore.

Returns
VkSemaphore handle.

◆ nextFrame()

void VulkanFrameSync::nextFrame ( )

Progresses the frame index counter.

Advances active frame buffer index.

◆ operator=()

VulkanFrameSync & VulkanFrameSync::operator= ( const VulkanFrameSync & )
delete

◆ waitForCurrentFrame()

void VulkanFrameSync::waitForCurrentFrame ( )

Blocks host execution until current frame fence is signaled, then resets it.

Blocks CPU thread until active frame fence is signaled, then resets it.

Member Data Documentation

◆ currentFrame

uint32_t VulkanFrameSync::currentFrame = 0
private

Active frame index.

◆ device

VkDevice VulkanFrameSync::device = VK_NULL_HANDLE
private

Reference to logical device.

◆ imageAvailableSemaphores

std::vector<VkSemaphore> VulkanFrameSync::imageAvailableSemaphores
private

Semaphores waiting for image availability.

◆ inFlightFences

std::vector<VkFence> VulkanFrameSync::inFlightFences
private

Fences waiting for queue work execution completion.

◆ maxFrames

uint32_t VulkanFrameSync::maxFrames = 0
private

Max frames allowed in flight.

◆ renderFinishedSemaphores

std::vector<VkSemaphore> VulkanFrameSync::renderFinishedSemaphores
private

Semaphores waiting for render passes to complete.


The documentation for this class was generated from the following files: