vOOlkan
An object oriented approach to Vulkan
Semaphore.h
Go to the documentation of this file.
1#ifndef VULKAN_SEMAPHORE
2#define VULKAN_SEMAPHORE
3
4#include <vulkan/vulkan.h>
5#include <iostream>
6
7#include "VulkanException.h"
8#include "LogicalDevice.h"
9
10
11namespace Vulkan::SynchronizationPrimitives { class Semaphore; }
12
14public:
15
16 Semaphore(const LogicalDevice& virtualGpu) : virtualGpu{ virtualGpu } {
17 VkSemaphoreCreateInfo semaphoreInfo{};
18 semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
19
20 if (VkResult result = vkCreateSemaphore(+virtualGpu, &semaphoreInfo, nullptr, &semaphore); result != VK_SUCCESS) {
21 throw VulkanException{ "Failed to create semaphore", result };
22 }
23
24 std::cout << "\n+ Semaphore created";
25 }
26
27 Semaphore(const Semaphore&) = delete;
28 Semaphore& operator=(const Semaphore&) = delete;
29
30
31 Semaphore(Semaphore&& movedFrom) noexcept : semaphore{ movedFrom.semaphore }, virtualGpu{ movedFrom.virtualGpu } {
32 movedFrom.semaphore = nullptr;
33 std::cout << "\n> Semaphore moved";
34 }
35
36 //FIXTHIS implement this the right way
38
40 vkDestroySemaphore(+virtualGpu, semaphore, nullptr);
41 std::cout << "\n- Semaphore destroyed";
42 }
43
44 const VkSemaphore& operator+() const {
45 return semaphore;
46 }
47
48
49private:
50 VkSemaphore semaphore;
51 const LogicalDevice& virtualGpu;
52};
53
54#endif
A logical device is an abstraction of the physical GPU which we can mainly use to send commands.
Definition: LogicalDevice.h:15
const VkSemaphore & operator+() const
Definition: Semaphore.h:44
~Semaphore()
Definition: Semaphore.h:39
Semaphore(const LogicalDevice &virtualGpu)
Definition: Semaphore.h:16
Semaphore(Semaphore &&movedFrom) noexcept
Definition: Semaphore.h:31
Semaphore & operator=(Semaphore &&)=default
Semaphore & operator=(const Semaphore &)=delete
Generic runtime exception thrown by Vulkan-related functions.
Definition: VulkanException.h:13
Definition: Barriers.h:10