17 vk::CommandPoolCreateInfo pool_info {};
18 pool_info.queueFamilyIndex = graphics_queue_family;
19 pool_info.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
23 }
catch (
const vk::SystemError& e) {
25 "Failed to create command pool: {}", e.what());
30 "Command manager initialized");
50 vk::CommandBufferAllocateInfo alloc_info {};
52 alloc_info.level = level;
53 alloc_info.commandBufferCount = 1;
55 vk::CommandBuffer cmd_buffer;
57 auto result =
m_device.allocateCommandBuffers(&alloc_info, &cmd_buffer);
58 if (result != vk::Result::eSuccess) {
60 "Failed to allocate command buffer");
64 }
catch (
const vk::SystemError& e) {
66 "Failed to allocate command buffer: {}", e.what());
71 "Allocated {} command buffer",
72 level == vk::CommandBufferLevel::ePrimary ?
"primary" :
"secondary");
79 if (!command_buffer) {
94 vk::CommandBufferBeginInfo begin_info {};
95 begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
97 command_buffer.begin(begin_info);
99 return command_buffer;
104 command_buffer.end();
106 vk::SubmitInfo submit_info {};
107 submit_info.commandBufferCount = 1;
108 submit_info.pCommandBuffers = &command_buffer;
110 if (
auto result = queue.submit(1, &submit_info,
nullptr); result != vk::Result::eSuccess) {
112 "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.
void free_command_buffer(vk::CommandBuffer command_buffer)
Free a command buffer back to the pool.
bool initialize(vk::Device device, uint32_t graphics_queue_family)
Initialize command manager.
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 m_command_pool
@ GraphicsBackend
Graphics/visual rendering backend (Vulkan, OpenGL)
@ Core
Core engine, backend, subsystems.