Lugdunum  0.1.0
CommandPool.cpp
Go to the documentation of this file.
2 
4 
5 namespace lug {
6 namespace Graphics {
7 namespace Vulkan {
8 namespace API {
9 namespace Builder {
10 
11 CommandPool::CommandPool(const API::Device& device, const API::QueueFamily& queueFamily) : _device{device}, _queueFamily(queueFamily) {}
12 
13 bool CommandPool::build(API::CommandPool& commandPool, VkResult* returnResult) {
14  // Create the commandPool creation information for vkCreateCommandPool
15  const VkCommandPoolCreateInfo createInfo{
16  /* createInfo.sType */ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
17  /* createInfo.pNext */ nullptr,
18  /* createInfo.flags */ _flags,
19  /* createInfo.queueFamilyIndex */ _queueFamily.getIdx()
20  };
21 
22  // Create the commandPool
23  VkCommandPool vkCommandPool{VK_NULL_HANDLE};
24  VkResult result = vkCreateCommandPool(static_cast<VkDevice>(_device), &createInfo, nullptr, &vkCommandPool);
25 
26  if (returnResult) {
27  *returnResult = result;
28  }
29 
30  if (result != VK_SUCCESS) {
31  return false;
32  }
33 
34  commandPool = API::CommandPool(vkCommandPool, &_device, nullptr);
35 
36  return true;
37 }
38 
39 std::unique_ptr<API::CommandPool> CommandPool::build(VkResult* returnResult) {
40  std::unique_ptr<API::CommandPool> commandPool = std::make_unique<API::CommandPool>();
41  return build(*commandPool, returnResult) ? std::move(commandPool) : nullptr;
42 }
43 
44 } // Builder
45 } // API
46 } // Vulkan
47 } // Graphics
48 } // lug
bool build(API::CommandPool &instance, VkResult *returnResult=nullptr)
Definition: CommandPool.cpp:13
CommandPool(const API::Device &device, const API::QueueFamily &queueFamily)
Definition: CommandPool.cpp:11