Vulkan: Refactor command buffer and introduce command pool

This commit is contained in:
Lynix
2020-04-07 21:10:16 +02:00
parent f6d21d066e
commit 87f1209327
27 changed files with 313 additions and 85 deletions

View File

@@ -210,6 +210,8 @@ int main()
Nz::VkRenderWindow& vulkanWindow = *static_cast<Nz::VkRenderWindow*>(window.GetImpl());
Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice();
std::unique_ptr<Nz::CommandPool> commandPool = vulkanWindow.CreateCommandPool(Nz::QueueType::Graphics);
Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount();
std::vector<std::unique_ptr<Nz::CommandBuffer>> renderCmds(imageCount);
@@ -258,7 +260,7 @@ int main()
clearValues.data() // const VkClearValue *pClearValues
};
commandBufferPtr = vulkanWindow.BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder)
commandBufferPtr = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder)
{
Nz::Vk::CommandBuffer& vkCommandBuffer = static_cast<Nz::VulkanCommandBufferBuilder&>(builder).GetCommandBuffer();
@@ -372,11 +374,11 @@ int main()
builder.PostTransferBarrier();
}
builder.EndDebugRegion();
}, false);
}, Nz::QueueType::Transfer);
Nz::UInt32 imageIndex = renderImage.GetImageIndex();
renderImage.SubmitCommandBuffer(renderCmds[imageIndex].get(), true);
renderImage.SubmitCommandBuffer(renderCmds[imageIndex].get(), Nz::QueueType::Graphics);
renderImage.Present();