Create command pool and allocate command buffer

This commit is contained in:
grayson committed 2025-02-11 19:45:47 -06:00
1 parent b1ac87d304
commit d30b37bfbd
2 files changed
+26

No files matched your search

@@ -25,6 +25,8 @@ namespace nf::client::render {
, m_swapchainFramebuffers()
, m_pipelineLayoutOutput()
, m_pipelineOutput()
, m_commandPool()
, m_commandBuffer()
{
NFLog("Initializing render engine");
m_window->setDisplay(m_display);
@@ -36,6 +38,7 @@ namespace nf::client::render {
createSwapchain();
createOutputRenderPass();
createOutputPipeline();
createCommandBuffer();
m_window->show();
}
@@ -377,7 +380,25 @@ namespace nf::client::render {
}
}
void RenderEngine::createCommandBuffer() {
VkCommandPoolCreateInfo commandPoolCI = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO };
commandPoolCI.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
commandPoolCI.queueFamilyIndex = m_queueFIGraphics;
if (vkCreateCommandPool(m_device, &commandPoolCI, nullptr, &m_commandPool) != VK_SUCCESS)
NFError("Could not create command pool.");
VkCommandBufferAllocateInfo commandBufferAI = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO };
commandBufferAI.commandPool = m_commandPool;
commandBufferAI.commandBufferCount = 1;
if (vkAllocateCommandBuffers(m_device, &commandBufferAI, &m_commandBuffer) != VK_SUCCESS)
NFError("Could not create command buffer.");
}
RenderEngine::~RenderEngine() {
vkDestroyCommandPool(m_device, m_commandPool, nullptr);
for (int i = 0; i < m_swapchainFramebuffers.size(); i++)
vkDestroyFramebuffer(m_device, m_swapchainFramebuffers[i], nullptr);
@@ -18,6 +18,7 @@ namespace nf::client::render {
void createSwapchain();
void createOutputRenderPass();
void createOutputPipeline();
void createCommandBuffer();
std::shared_ptr<Window> m_window;
DisplayConfig m_display;
@@ -41,5 +42,9 @@ namespace nf::client::render {
// Pipelines
VkPipelineLayout m_pipelineLayoutOutput;
VkPipeline m_pipelineOutput;
// Command buffers
VkCommandPool m_commandPool;
VkCommandBuffer m_commandBuffer;
};
}