Lugdunum  0.1.0
Device.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <vector>
6 
8 
9 namespace lug {
10 namespace Graphics {
11 namespace Vulkan {
12 namespace API {
13 namespace Builder {
14 
15 class Device {
16 private:
17  struct Queue {
18  VkQueueFlags flagsUsed{};
19  std::vector<std::string> names;
20  };
21 
22  struct QueueFamily {
23  VkQueueFlags flags{};
24  uint32_t queuesUsed{0};
25  std::vector<Queue> queues;
26  };
27 
28 public:
29  Device(const PhysicalDeviceInfo& physicalDeviceInfo);
30 
31  Device(const Device&) = delete;
32  Device(Device&&) = delete;
33 
34  Device& operator=(const Device&) = delete;
35  Device& operator=(Device&&) = delete;
36 
37  ~Device() = default;
38 
39  // Setters
40  void setExtensions(const std::vector<const char*>& extensions);
41  void setFeatures(VkPhysicalDeviceFeatures features);
42 
43  uint8_t addQueues(VkQueueFlags queueFlags, const std::vector<std::string>& queuesNames);
44 
45  // Build methods
46  bool build(API::Device& device, VkResult* returnResult = nullptr);
47  std::unique_ptr<API::Device> build(VkResult* returnResult = nullptr);
48 
49 private:
50  bool addQueue(VkQueueFlags queueFlags, const std::string& queueName);
51 
52 private:
54 
55  // We don't have layers because it's deprecated
56  std::vector<const char*> _extensions;
57  VkPhysicalDeviceFeatures _features{};
58 
59  std::vector<QueueFamily> _queueFamiliesInfos;
60 };
61 
63 
64 } // Builder
65 } // API
66 } // Vulkan
67 } // Graphics
68 } // lug
VkPhysicalDeviceFeatures _features
Definition: Device.hpp:57
void setExtensions(const std::vector< const char *> &extensions)
Definition: Device.inl:1
bool addQueue(VkQueueFlags queueFlags, const std::string &queueName)
Definition: Device.cpp:138
std::vector< QueueFamily > _queueFamiliesInfos
Definition: Device.hpp:59
uint8_t addQueues(VkQueueFlags queueFlags, const std::vector< std::string > &queuesNames)
Definition: Device.cpp:23
bool build(API::Device &device, VkResult *returnResult=nullptr)
Definition: Device.cpp:49
void setFeatures(VkPhysicalDeviceFeatures features)
Definition: Device.inl:5
Device(const PhysicalDeviceInfo &physicalDeviceInfo)
Definition: Device.cpp:14
Device & operator=(const Device &)=delete
std::vector< const char * > _extensions
Definition: Device.hpp:56
const PhysicalDeviceInfo & _physicalDeviceInfo
Definition: Device.hpp:53