Lugdunum  0.1.0
Fence.cpp
Go to the documentation of this file.
2 
5 
6 namespace lug {
7 namespace Graphics {
8 namespace Vulkan {
9 namespace API {
10 
11 Fence::Fence(VkFence fence, const Device* device) : _fence(fence), _device(device) {}
12 
13 Fence::Fence(Fence&& fence) {
14  _fence = fence._fence;
15  _device = fence._device;
16  fence._fence = VK_NULL_HANDLE;
17  fence._device = nullptr;
18 }
19 
21  destroy();
22 
23  _fence = fence._fence;
24  _device = fence._device;
25  fence._fence = VK_NULL_HANDLE;
26  fence._device = nullptr;
27 
28  return *this;
29 }
30 
32  destroy();
33 }
34 
35 VkResult Fence::getStatus() const {
36  return vkGetFenceStatus(static_cast<VkDevice>(*_device), _fence);
37 }
38 
39 bool Fence::reset() const {
40  VkResult result = vkResetFences(static_cast<VkDevice>(*_device), 1, &_fence);
41 
42  if (result != VK_SUCCESS) {
43  LUG_LOG.error("Fence::reset: Can't reset fence: {}", result);
44  return false;
45  }
46 
47  return true;
48 }
49 
50 bool Fence::wait() const {
51  VkResult result = vkWaitForFences(static_cast<VkDevice>(*_device), 1, &_fence, VK_TRUE, UINT64_MAX);
52 
53  if (result != VK_SUCCESS) {
54  LUG_LOG.error("Fence::wait: Can't wait for fence: {}", result);
55  return false;
56  }
57 
58  return true;
59 }
60 
62  if (_fence != VK_NULL_HANDLE) {
63  vkDestroyFence(static_cast<VkDevice>(*_device), _fence, nullptr);
64  _fence = VK_NULL_HANDLE;
65  }
66  _device = nullptr;
67 }
68 
69 } // API
70 } // Vulkan
71 } // Graphics
72 } // lug
VkResult getStatus() const
Definition: Fence.cpp:35
Fence & operator=(const Fence &)=delete
#define LUG_LOG
Definition: Logger.hpp:73