SimpleGL  1.1.0
A framework for platform independent rendering
synchronization.cpp
Go to the documentation of this file.
1 
9 
10 #include <stdexcept>
11 
13 
14 using namespace std;
15 
16 namespace sgl {
17 
18  Semaphore::Semaphore(void) {
19  VkDevice device = VulkanContext::getCurrent()->getDevice()->getHandle();
20 
21  /* Initialize a semaphore create info */
22  VkSemaphoreCreateInfo createInfo = {};
23  createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
24 
25  /* Create the semaphore */
26  if (vkCreateSemaphore(device, &createInfo, nullptr, &handle) != VK_SUCCESS) {
27  throw runtime_error("Could not create a semaphore!");
28  }
29  }
30 
31  Semaphore::~Semaphore(void) {
32  VkDevice device = VulkanContext::getCurrent()->getDevice()->getHandle();
33 
34  /* Destroy the semaphore */
35  vkDestroySemaphore(device, handle, nullptr);
36  }
37 
38  VkSemaphore Semaphore::getHandle() {
39  return handle;
40  }
41 
42  Fence::Fence(void) {
43  VkDevice device = VulkanContext::getCurrent()->getDevice()->getHandle();
44 
45  /* Initialize a fence create info */
46  VkFenceCreateInfo createInfo = {};
47  createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
48  createInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
49 
50  /* Create the fence */
51  if (vkCreateFence(device, &createInfo, nullptr, &handle) != VK_SUCCESS) {
52  throw runtime_error("Could not create a fence!");
53  }
54  }
55 
56  Fence::~Fence(void) {
57  VkDevice device = VulkanContext::getCurrent()->getDevice()->getHandle();
58 
59  /* Destroy the fence */
60  vkDestroyFence(device, handle, nullptr);
61  }
62 
63  VkFence Fence::getHandle() {
64  return handle;
65  }
66 }
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18