15 std::vector<API::CommandBuffer> descriptorSets(1);
16 if (!
build(descriptorSets, returnResult)) {
19 instance = std::move(descriptorSets[0]);
24 std::vector<API::CommandBuffer> commandBuffers(1);
25 return build(commandBuffers, returnResult) ? std::make_unique<API::CommandBuffer>(std::move(commandBuffers[0])) :
nullptr;
30 const VkCommandBufferAllocateInfo allocateInfo{
31 VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
35 static_cast<uint32_t>(commandBuffers.size()),
38 std::vector<VkCommandBuffer> vkCommandBuffers(commandBuffers.size());
41 VkResult result = vkAllocateCommandBuffers(static_cast<VkDevice>(
_device), &allocateInfo, vkCommandBuffers.data());
44 *returnResult = result;
47 if (result != VK_SUCCESS) {
51 for (uint32_t i = 0; i < commandBuffers.size(); ++i) {
58 std::vector<std::unique_ptr<API::CommandBuffer>>
CommandBuffer::build(uint32_t count, VkResult* returnResult) {
60 std::vector<API::CommandBuffer> commandBuffers(count);
61 std::vector<std::unique_ptr<API::CommandBuffer>> outCommandBuffers(count);
64 if (!
build(commandBuffers, returnResult)) {
69 for (uint32_t i = 0; i < count; ++i) {
70 outCommandBuffers[i] = std::make_unique<API::CommandBuffer>(std::move(commandBuffers[i]));
73 return outCommandBuffers;
const API::CommandPool & _commandPool
bool build(API::CommandBuffer &instance, VkResult *returnResult=nullptr)
const API::Device & _device
VkCommandBufferLevel _level
CommandBuffer(const API::Device &device, const API::CommandPool &commandPool)