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
FrameManager Class Reference

Manages frame synchronization, swapchain image acquisition, queue submission, and command buffers. More...

#include <FrameManager.hpp>

Public Member Functions

 FrameManager (VkDevice dev, VkQueue graphicsQ, VkQueue presentQ, VkSwapchainKHR sc, uint32_t framesInFlight=2)
 Construct a new Frame Manager object.
 ~FrameManager ()
 Destroy the Frame Manager object, releasing sync handles.
void init (VkCommandPool commandPool)
 Allocates command buffers and creates semaphores and fences.
void beginFrame (uint32_t &imageIndex)
 Prepares for frame drawing by waiting for the in-flight fence, acquiring the next swapchain image, and resetting command buffers.
void endFrame (uint32_t imageIndex)
 Submits command buffers to the graphics queue and presents the swapchain image.
VkCommandBuffer getCurrentCommandBuffer () const
 Gets command buffer active for the current in-flight frame.

Private Attributes

VkDevice device
VkQueue graphicsQueue
VkQueue presentQueue
VkSwapchainKHR swapchain
uint32_t maxFramesInFlight
std::vector< VkSemaphore > imageAvailableSemaphores
std::vector< VkSemaphore > renderFinishedSemaphores
std::vector< VkFence > inFlightFences
std::vector< VkCommandBuffer > commandBuffers
uint32_t currentFrame = 0

Detailed Description

Manages frame synchronization, swapchain image acquisition, queue submission, and command buffers.

Constructor & Destructor Documentation

◆ FrameManager()

FrameManager::FrameManager ( VkDevice dev,
VkQueue gQ,
VkQueue pQ,
VkSwapchainKHR sc,
uint32_t framesInFlight = 2 )

Construct a new Frame Manager object.

Construct a new Frame Manager:: Frame Manager object.

Parameters
devLogical Vulkan device.
graphicsQQueue for rendering submissions.
presentQQueue for presentation.
scTarget Vulkan swapchain.
framesInFlightNumber of frames allowed in flight concurrently.
devLogical device context.
gQGraphics queue.
pQPresent queue.
scSwapchain.
framesInFlightFrame buffer count.

◆ ~FrameManager()

FrameManager::~FrameManager ( )

Destroy the Frame Manager object, releasing sync handles.

Destroy the Frame Manager:: Frame Manager object and clean up synchronization handles.

Member Function Documentation

◆ beginFrame()

void FrameManager::beginFrame ( uint32_t & imageIndex)

Prepares for frame drawing by waiting for the in-flight fence, acquiring the next swapchain image, and resetting command buffers.

Waits on in-flight synchronization fences, gets next swapchain index and resets command buffers.

Parameters
imageIndexOut parameter for acquired image index.
imageIndexTarget index reference.

◆ endFrame()

void FrameManager::endFrame ( uint32_t imageIndex)

Submits command buffers to the graphics queue and presents the swapchain image.

Submits rendering command buffer to graphics queue and registers present requests.

Parameters
imageIndexAcquired swapchain image index.
imageIndexTarget swapchain index.

◆ getCurrentCommandBuffer()

VkCommandBuffer FrameManager::getCurrentCommandBuffer ( ) const
inline

Gets command buffer active for the current in-flight frame.

Returns
Current command buffer.

◆ init()

void FrameManager::init ( VkCommandPool commandPool)

Allocates command buffers and creates semaphores and fences.

Initializes frame resources, creating semaphores, fences, and allocating command buffers.

Parameters
commandPoolParent Vulkan command pool.
commandPoolThe Vulkan command pool.

Member Data Documentation

◆ commandBuffers

std::vector<VkCommandBuffer> FrameManager::commandBuffers
private

◆ currentFrame

uint32_t FrameManager::currentFrame = 0
private

◆ device

VkDevice FrameManager::device
private

◆ graphicsQueue

VkQueue FrameManager::graphicsQueue
private

◆ imageAvailableSemaphores

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

◆ inFlightFences

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

◆ maxFramesInFlight

uint32_t FrameManager::maxFramesInFlight
private

◆ presentQueue

VkQueue FrameManager::presentQueue
private

◆ renderFinishedSemaphores

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

◆ swapchain

VkSwapchainKHR FrameManager::swapchain
private

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