18 vk::CommandPoolCreateInfo pool_info {};
19 pool_info.queueFamilyIndex = graphics_queue_family;
20 pool_info.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
24 }
catch (
const vk::SystemError& e) {
26 "Failed to create command pool: {}", e.what());
30 pool_info.queueFamilyIndex = compute_queue_family;
33 }
catch (
const vk::SystemError& e) {
35 "Failed to create compute command pool: {}", e.what());
40 "Command manager initialized");
69 vk::CommandBufferAllocateInfo alloc_info {};
71 alloc_info.level = level;
72 alloc_info.commandBufferCount = 1;
74 vk::CommandBuffer cmd_buffer;
76 auto result =
m_device.allocateCommandBuffers(&alloc_info, &cmd_buffer);
77 if (result != vk::Result::eSuccess) {
79 "Failed to allocate command buffer");
83 }
catch (
const vk::SystemError& e) {
85 "Failed to allocate command buffer: {}", e.what());
90 "Allocated {} command buffer",
91 level == vk::CommandBufferLevel::ePrimary ?
"primary" :
"secondary");
98 if (!command_buffer) {
119 vk::CommandBufferBeginInfo begin_info {};
120 begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
122 command_buffer.begin(begin_info);
124 return command_buffer;
129 vk::CommandBufferAllocateInfo alloc_info {};
131 alloc_info.level = vk::CommandBufferLevel::ePrimary;
132 alloc_info.commandBufferCount = 1;
134 vk::CommandBuffer cmd =
m_device.allocateCommandBuffers(alloc_info).front();
137 vk::CommandBufferBeginInfo begin_info {};
138 begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
139 cmd.begin(begin_info);
145 command_buffer.end();
147 vk::SubmitInfo submit_info {};
148 submit_info.commandBufferCount = 1;
149 submit_info.pCommandBuffers = &command_buffer;
151 if (
auto result = queue.submit(1, &submit_info,
nullptr); result != vk::Result::eSuccess) {
153 "Failed to submit single time command buffer: {}", vk::to_string(result));
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_RT_TRACE(comp, ctx,...)
void reset_pool()
Reset command pool (invalidates all allocated buffers)
uint32_t m_graphics_queue_family
void end_single_time_commands(vk::CommandBuffer command_buffer, vk::Queue queue)
End and submit single-time command.
vk::CommandPool m_compute_command_pool
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.
uint32_t m_compute_queue_family
vk::CommandBuffer begin_single_time_commands()
Begin single-time command (for transfers, etc.)
std::vector< vk::CommandBuffer > m_allocated_buffers
bool initialize(vk::Device device, uint32_t graphics_queue_family, uint32_t compute_queue_family)
Initialize command manager.
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 m_command_pool
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.