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
VulkanCommandManager.hpp
Go to the documentation of this file.
1#pragma once
2#include <vulkan/vulkan.h>
3#include <vector>
4#include <stdexcept>
5
11public:
20
23
30 void create(VkDevice device, uint32_t queueFamilyIndex, uint32_t commandBufferCount = 2);
34 void destroy();
35
40 VkCommandPool getCommandPool() const { return commandPool; }
45 VkCommandBuffer getCurrentCommandBuffer() const { return commandBuffers[currentFrame]; }
51 VkCommandBuffer getCommandBuffer(size_t index) const { return commandBuffers.at(index); }
56 size_t getCurrentFrame() const { return currentFrame; }
57
61 void beginFrame();
65 void endFrame();
66
71 VkCommandBuffer beginOneTimeCommand();
77 void endOneTimeCommand(VkCommandBuffer commandBuffer, VkQueue queue);
78
79private:
81 VkDevice device = VK_NULL_HANDLE;
83 VkCommandPool commandPool = VK_NULL_HANDLE;
85 std::vector<VkCommandBuffer> commandBuffers;
87 size_t currentFrame = 0;
88};
VulkanCommandManager()=default
Construct a new Vulkan Command Manager object.
std::vector< VkCommandBuffer > commandBuffers
Array of primary frame command buffers.
Definition VulkanCommandManager.hpp:85
void endOneTimeCommand(VkCommandBuffer commandBuffer, VkQueue queue)
Ends, submits, waits on, and releases a one-time utility command buffer.
Definition VulkanCommandManager.cpp:105
size_t currentFrame
Active frame command buffer array index.
Definition VulkanCommandManager.hpp:87
~VulkanCommandManager()
Destroy the Vulkan Command Manager object and release command pool.
Definition VulkanCommandManager.cpp:6
size_t getCurrentFrame() const
Gets active double buffering frame index.
Definition VulkanCommandManager.hpp:56
VkCommandPool commandPool
Raw command pool handle.
Definition VulkanCommandManager.hpp:83
VkCommandPool getCommandPool() const
Gets raw Vulkan command pool.
Definition VulkanCommandManager.hpp:40
VkCommandBuffer getCurrentCommandBuffer() const
Gets command buffer corresponding to current frame index.
Definition VulkanCommandManager.hpp:45
void beginFrame()
Alternates the frame index and begins recording the next frame command buffer.
Definition VulkanCommandManager.cpp:53
void destroy()
Safely destroys the command pool and associated command buffers.
Definition VulkanCommandManager.cpp:13
VulkanCommandManager(const VulkanCommandManager &)=delete
VkCommandBuffer getCommandBuffer(size_t index) const
Gets command buffer at specified array index.
Definition VulkanCommandManager.hpp:51
VkDevice device
Reference to Vulkan logical device.
Definition VulkanCommandManager.hpp:81
VkCommandBuffer beginOneTimeCommand()
Allocates and begins recording a one-time utility command buffer.
Definition VulkanCommandManager.cpp:80
void create(VkDevice device, uint32_t queueFamilyIndex, uint32_t commandBufferCount=2)
Creates command pool and command buffers.
Definition VulkanCommandManager.cpp:26
void endFrame()
Ends command buffer recording for the active frame.
Definition VulkanCommandManager.cpp:70
VulkanCommandManager & operator=(const VulkanCommandManager &)=delete
static ufbxi_noinline ufbxi_aa_node index
Definition ufbx.cpp:4444