MayaFlux 0.1.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 from the pool
34 * @return Command buffer handle
35 */
36 vk::CommandBuffer allocate_command_buffer();
37
38 /**
39 * @brief Free a command buffer back to the pool
40 */
41 void free_command_buffer(vk::CommandBuffer command_buffer);
42
43 /**
44 * @brief Begin single-time command (for transfers, etc.)
45 * @return Command buffer ready for recording
46 */
47 vk::CommandBuffer begin_single_time_commands();
48
49 /**
50 * @brief End and submit single-time command
51 * @param command_buffer Command buffer to submit
52 * @param queue Queue to submit to
53 */
54 void end_single_time_commands(vk::CommandBuffer command_buffer, vk::Queue queue);
55
56 /**
57 * @brief Reset command pool (invalidates all allocated buffers)
58 */
59 void reset_pool();
60
61 /**
62 * @brief Get the command pool
63 */
64 [[nodiscard]] vk::CommandPool get_pool() const { return m_command_pool; }
65
66private:
67 vk::Device m_device;
68 vk::CommandPool m_command_pool;
70
71 std::vector<vk::CommandBuffer> m_allocated_buffers;
72};
73
74} // 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 allocate_command_buffer()
Allocate a command buffer from 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::CommandPool get_pool() const
Get the command pool.
Manages Vulkan command pools and command buffers.
void initialize()
Definition main.cpp:11