Lugdunum  0.1.0
Fence.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 Fence::Fence(const API::Device& device) : _device{device} {}
12 
13 bool Fence::build(API::Fence& fence, VkResult* returnResult) {
14  // Create the fence creation information for vkCreateFence
15  const VkFenceCreateInfo createInfo{
16  /* createInfo.sType */ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
17  /* createInfo.pNext */ nullptr,
18  /* createInfo.flags */ _flags
19  };
20 
21  // Create the fence
22  VkFence vkFence{VK_NULL_HANDLE};
23  VkResult result = vkCreateFence(static_cast<VkDevice>(_device), &createInfo, nullptr, &vkFence);
24 
25  if (returnResult) {
26  *returnResult = result;
27  }
28 
29  if (result != VK_SUCCESS) {
30  return false;
31  }
32 
33  fence = API::Fence(vkFence, &_device);
34 
35  return true;
36 }
37 
38 std::unique_ptr<API::Fence> Fence::build(VkResult* returnResult) {
39  std::unique_ptr<API::Fence> fence = std::make_unique<API::Fence>();
40  return build(*fence, returnResult) ? std::move(fence) : nullptr;
41 }
42 
43 } // Builder
44 } // API
45 } // Vulkan
46 } // Graphics
47 } // lug
Fence(const API::Device &device)
Definition: Fence.cpp:11
bool build(API::Fence &instance, VkResult *returnResult=nullptr)
Definition: Fence.cpp:13