MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
VKCommandManager.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vulkan/vulkan.hpp>
4
5namespace MayaFlux::Core {
6
7/**
8 * @class VKCommandManager
9 * @brief Manages Vulkan command pools and command buffers
10 *
11 * Handles command buffer allocation, recording, and submission.
12 * Creates per-thread command pools for thread safety.
13 */
15public:
16 VKCommandManager() = default;
18
19 /**
20 * @brief Initialize command manager
21 * @param device Logical device
22 * @param graphics_queue_family Graphics queue family index
23 * @return True if initialization succeeded
24 */
25 bool initialize(vk::Device device, uint32_t graphics_queue_family);
26
27 /**
28 * @brief Cleanup all command pools and buffers
29 */
30 void cleanup();
31
32 /**
33 * @brief Allocate a command buffer with specified level
34 * @param level Primary or secondary
35 * @return Allocated command buffer
36 */
37 vk::CommandBuffer allocate_command_buffer(
38 vk::CommandBufferLevel level = vk::CommandBufferLevel::ePrimary);
39
40 /**
41 * @brief Free a command buffer back to the pool
42 */
43 void free_command_buffer(vk::CommandBuffer command_buffer);
44
45 /**
46 * @brief Begin single-time command (for transfers, etc.)
47 * @return Command buffer ready for recording
48 */
49 vk::CommandBuffer begin_single_time_commands();
50
51 /**
52 * @brief End and submit single-time command
53 * @param command_buffer Command buffer to submit
54 * @param queue Queue to submit to
55 */
56 void end_single_time_commands(vk::CommandBuffer command_buffer, vk::Queue queue);
57
58 /**
59 * @brief Reset command pool (invalidates all allocated buffers)
60 */
61 void reset_pool();
62
63 /**
64 * @brief Get the command pool
65 */
66 [[nodiscard]] vk::CommandPool get_pool() const { return m_command_pool; }
67
68private:
69 vk::Device m_device;
70 vk::CommandPool m_command_pool;
72
73 std::vector<vk::CommandBuffer> m_allocated_buffers;
74};
75
76} // namespace MayaFlux::Core
void reset_pool()
Reset command pool (invalidates all allocated buffers)
void end_single_time_commands(vk::CommandBuffer command_buffer, vk::Queue queue)
End and submit single-time command.
void free_command_buffer(vk::CommandBuffer command_buffer)
Free a command buffer back to the pool.
vk::CommandBuffer begin_single_time_commands()
Begin single-time command (for transfers, etc.)
std::vector< vk::CommandBuffer > m_allocated_buffers
void cleanup()
Cleanup all command pools and buffers.
vk::CommandBuffer allocate_command_buffer(vk::CommandBufferLevel level=vk::CommandBufferLevel::ePrimary)
Allocate a command buffer with specified level.
vk::CommandPool get_pool() const
Get the command pool.
Manages Vulkan command pools and command buffers.
void initialize()
Definition main.cpp:11