Mandrill 2025.6.0
Loading...
Searching...
No Matches
Device.h
1#pragma once
2
3#include "Common.h"
4
5namespace Mandrill
6{
7 struct MANDRILL_API DeviceProperties {
8 VkPhysicalDeviceProperties physicalDevice;
9 VkPhysicalDeviceMemoryProperties memory;
10 VkPhysicalDeviceRayTracingPipelinePropertiesKHR rayTracingPipeline;
11 VkPhysicalDeviceAccelerationStructurePropertiesKHR accelerationStucture;
12 };
13
17 class Device
18 {
19 public:
20 MANDRILL_NON_COPYABLE(Device)
21
22
31 MANDRILL_API Device(GLFWwindow* pWindow,
32 const std::vector<const char*>& extensions = std::vector<const char*>(),
33 VkPhysicalDeviceFeatures2* pFeatures = nullptr, uint32_t physicalDeviceIndex = 0);
34
38 MANDRILL_API ~Device();
39
44 MANDRILL_API VkDevice getDevice() const
45 {
46 return mDevice;
47 }
48
53 MANDRILL_API VkInstance getInstance() const
54 {
55 return mInstance;
56 }
57
62 MANDRILL_API VkPhysicalDevice getPhysicalDevice() const
63 {
64 return mPhysicalDevice;
65 }
66
71 MANDRILL_API DeviceProperties getProperties() const
72 {
73 return mProperties;
74 }
75
80 MANDRILL_API GLFWwindow* getWindow() const
81 {
82 return mpWindow;
83 }
84
89 MANDRILL_API VkSurfaceKHR getSurface() const
90 {
91 return mSurface;
92 }
93
98 MANDRILL_API VkCommandPool getCommandPool() const
99 {
100 return mCommandPool;
101 }
102
107 MANDRILL_API VkQueue getQueue() const
108 {
109 return mQueue;
110 }
111
116 MANDRILL_API uint32_t getQueueFamily() const
117 {
118 return mQueueFamilyIndex;
119 }
120
125 MANDRILL_API bool supportsRayTracing() const
126 {
127 return mRayTracingSupport;
128 }
129
134 MANDRILL_API bool getVsync() const
135 {
136 return mVsync;
137 }
138
144 MANDRILL_API void setVsync(bool vsync)
145 {
146 mVsync = vsync;
147 }
148
153 MANDRILL_API VkSampleCountFlagBits getSampleCount() const;
154
155 private:
156#if defined(_DEBUG)
157 void createDebugMessenger();
158#endif
159 void createInstance();
160 void createDevice(const std::vector<const char*>& extensions, VkPhysicalDeviceFeatures2* pFeatures,
161 uint32_t physicalDeviceIndex);
162 void createCommandPool();
163 void createSurface();
164 void createExtensionProcAddrs();
165
166 GLFWwindow* mpWindow;
167
168#if defined(_DEBUG)
169 VkDebugUtilsMessengerEXT mDebugMessenger;
170#endif
171
172 VkInstance mInstance;
173 VkPhysicalDevice mPhysicalDevice;
174 VkDevice mDevice;
175 VkSurfaceKHR mSurface;
176
177 DeviceProperties mProperties;
178
179 uint32_t mQueueFamilyIndex;
180 VkCommandPool mCommandPool;
181 VkQueue mQueue;
182
183 bool mRayTracingSupport;
184 bool mVsync;
185 };
186} // namespace Mandrill
Device class abstracting the physical and logical Vulkan device, as well as handling extensions and f...
Definition Device.h:18
MANDRILL_API void setVsync(bool vsync)
Set a vertical sync mode.
Definition Device.h:144
MANDRILL_API VkDevice getDevice() const
Get Vulkan device handle.
Definition Device.h:44
MANDRILL_API bool getVsync() const
Get the current verical sync mode.
Definition Device.h:134
MANDRILL_API VkPhysicalDevice getPhysicalDevice() const
Get Vulkan physical device handle.
Definition Device.h:62
MANDRILL_API uint32_t getQueueFamily() const
Get the queue family.
Definition Device.h:116
MANDRILL_API VkQueue getQueue() const
Get the queue.
Definition Device.h:107
MANDRILL_API VkSampleCountFlagBits getSampleCount() const
Get the multisample anti-aliasing sample count.
Definition Device.cpp:118
MANDRILL_API bool supportsRayTracing() const
Check if the given context supports ray tracing.
Definition Device.h:125
MANDRILL_API VkInstance getInstance() const
Get Vulkan instance handle.
Definition Device.h:53
MANDRILL_API ~Device()
Destructor for device.
Definition Device.cpp:97
MANDRILL_API GLFWwindow * getWindow() const
Get the window that the device is bound to.
Definition Device.h:80
MANDRILL_API VkCommandPool getCommandPool() const
Get the command pool.
Definition Device.h:98
MANDRILL_API VkSurfaceKHR getSurface() const
Get the presentation surface of the application.
Definition Device.h:89
MANDRILL_API DeviceProperties getProperties() const
Get device and physical device properties.
Definition Device.h:71