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.hpp
Go to the documentation of this file.
1#pragma once
2#include <vulkan/vulkan.h>
3#include <vector>
4
10public:
19 FrameManager(VkDevice dev, VkQueue graphicsQ, VkQueue presentQ, VkSwapchainKHR sc, uint32_t framesInFlight = 2);
24
29 void init(VkCommandPool commandPool);
34 void beginFrame(uint32_t& imageIndex);
39 void endFrame(uint32_t imageIndex);
40
45 VkCommandBuffer getCurrentCommandBuffer() const { return commandBuffers[currentFrame]; }
46
47private:
48 VkDevice device;
50 VkQueue presentQueue;
51 VkSwapchainKHR swapchain;
53
54 std::vector<VkSemaphore> imageAvailableSemaphores;
55 std::vector<VkSemaphore> renderFinishedSemaphores;
56 std::vector<VkFence> inFlightFences;
57 std::vector<VkCommandBuffer> commandBuffers;
58
59 uint32_t currentFrame = 0;
60};
void init(VkCommandPool commandPool)
Allocates command buffers and creates semaphores and fences.
Definition FrameManager.cpp:31
VkQueue presentQueue
Definition FrameManager.hpp:50
void endFrame(uint32_t imageIndex)
Submits command buffers to the graphics queue and presents the swapchain image.
Definition FrameManager.cpp:81
VkCommandBuffer getCurrentCommandBuffer() const
Gets command buffer active for the current in-flight frame.
Definition FrameManager.hpp:45
std::vector< VkCommandBuffer > commandBuffers
Definition FrameManager.hpp:57
std::vector< VkSemaphore > renderFinishedSemaphores
Definition FrameManager.hpp:55
VkDevice device
Definition FrameManager.hpp:48
VkQueue graphicsQueue
Definition FrameManager.hpp:49
~FrameManager()
Destroy the Frame Manager object, releasing sync handles.
Definition FrameManager.cpp:19
std::vector< VkFence > inFlightFences
Definition FrameManager.hpp:56
VkSwapchainKHR swapchain
Definition FrameManager.hpp:51
uint32_t maxFramesInFlight
Definition FrameManager.hpp:52
std::vector< VkSemaphore > imageAvailableSemaphores
Definition FrameManager.hpp:54
uint32_t currentFrame
Definition FrameManager.hpp:59
void beginFrame(uint32_t &imageIndex)
Prepares for frame drawing by waiting for the in-flight fence, acquiring the next swapchain image,...
Definition FrameManager.cpp:68
FrameManager(VkDevice dev, VkQueue graphicsQ, VkQueue presentQ, VkSwapchainKHR sc, uint32_t framesInFlight=2)
Construct a new Frame Manager object.
Definition FrameManager.cpp:12