MayaFlux 0.3.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 * @param compute_queue_family Compute queue family index (optional, for compute operations)
24 * @return True if initialization succeeded
25 */
26 // bool initialize(vk::Device device, uint32_t graphics_queue_family);
27 bool initialize(vk::Device device, uint32_t graphics_queue_family, uint32_t compute_queue_family);
28
29 /**
30 * @brief Cleanup all command pools and buffers
31 */
32 void cleanup();
33
34 /**
35 * @brief Allocate a command buffer with specified level
36 * @param level Primary or secondary
37 * @return Allocated command buffer
38 */
39 vk::CommandBuffer allocate_command_buffer(
40 vk::CommandBufferLevel level = vk::CommandBufferLevel::ePrimary);
41
42 /**
43 * @brief Free a command buffer back to the pool
44 */
45 void free_command_buffer(vk::CommandBuffer command_buffer);
46
47 /**
48 * @brief Begin single-time command (for transfers, etc.)
49 * @return Command buffer ready for recording
50 */
51 vk::CommandBuffer begin_single_time_commands();
52
53 /**
54 * @brief End and submit single-time command
55 * @param command_buffer Command buffer to submit
56 * @param queue Queue to submit to
57 */
58 void end_single_time_commands(vk::CommandBuffer command_buffer, vk::Queue queue);
59
60 /**
61 * @brief Reset command pool (invalidates all allocated buffers)
62 */
63 void reset_pool();
64
65 /**
66 * @brief Get the command pool
67 */
68 [[nodiscard]] vk::CommandPool get_pool() const { return m_command_pool; }
69
70 /**
71 * @brief Begin single-time command for compute operations
72 * @return Command buffer ready for recording
73 */
74 [[nodiscard]] vk::CommandBuffer begin_single_time_commands_compute();
75
76private:
77 vk::Device m_device;
78 vk::CommandPool m_command_pool;
79 vk::CommandPool m_compute_command_pool;
82
83 std::vector<vk::CommandBuffer> m_allocated_buffers;
84 std::vector<vk::CommandBuffer> m_compute_allocated_buffers;
85};
86
87} // 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.
std::vector< vk::CommandBuffer > m_compute_allocated_buffers
vk::CommandBuffer begin_single_time_commands_compute()
Begin single-time command for compute operations.
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