21 #include "command_buffer_manager.hpp" 26 unsigned graphicsQueueIndex)
28 , commandBufferLevel(bufferLevel)
31 VkCommandPoolCreateInfo info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO };
32 info.queueFamilyIndex = graphicsQueueIndex;
33 info.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
34 VK_CHECK(vkCreateCommandPool(device, &info,
nullptr, &pool));
40 vkFreeCommandBuffers(device, pool, buffers.size(), buffers.data());
41 vkDestroyCommandPool(device, pool,
nullptr);
47 vkResetCommandPool(device, pool, 0);
54 VkCommandBuffer ret = VK_NULL_HANDLE;
55 if (count < buffers.size())
57 ret = buffers[count++];
61 VkCommandBufferAllocateInfo info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO };
62 info.commandPool = pool;
63 info.level = commandBufferLevel;
64 info.commandBufferCount = 1;
65 VK_CHECK(vkAllocateCommandBuffers(device, &info, &ret));
66 buffers.push_back(ret);
~CommandBufferManager()
Destructor.
void beginFrame()
Begins the frame. When this is called, all command buffers managed by this class are assumed to be re...
CommandBufferManager(VkDevice device, VkCommandBufferLevel bufferLevel, unsigned graphicsQueueIndex)
Constructor.
VkCommandBuffer requestCommandBuffer()
Requests a fresh or recycled command buffer which is in the reset state.