SimpleGL  1.1.0
A framework for platform independent rendering
vulkan_context.hpp
Go to the documentation of this file.
1 
8 #ifndef VULKAN_CONTEXT_HPP
9 #define VULKAN_CONTEXT_HPP
10 
11 #include <SimpleGL_vk/SimpleGL_vk_Export.h>
12 
13 #include <vector>
14 
15 #include <glm/glm.hpp>
16 
17 #include "vulkan_instance.hpp"
18 #include "debug_report.hpp"
19 #include "surface.hpp"
20 #include "physical_device.hpp"
21 #include "logical_device.hpp"
22 #include "swapchain.hpp"
23 #include "render_pass.hpp"
24 #include "framebuffer.hpp"
25 #include "command_buffer.hpp"
26 #include "descriptor_set.hpp"
27 #include "synchronization.hpp"
28 
29 namespace sgl {
30 
36  class SIMPLEGL_VK_EXPORT VulkanContext {
37 
38  private:
40  static VulkanContext* current;
41 
43  Instance* instance;
44 
46  DebugReportCallback* debugReportCallback;
47 
49  std::vector<PhysicalDevice*> availablePhysicalDevices;
50 
52  PhysicalDevice* physicalDevice;
53 
55  Device* device;
56 
58  Swapchain* swapchain;
59 
61  std::vector<FramebufferVK*> swapchainFramebuffers;
62 
64  CommandPool* commandPool;
65 
67  DescriptorPool* descriptorPool;
68 
70  Fence* renderFence;
71 
72  public:
78  static VulkanContext* getCurrent();
79 
85  static void setCurrent(VulkanContext* context);
86 
88  VulkanContext(void);
89 
91  ~VulkanContext(void);
92 
98  Instance* getInstance();
99 
105  DebugReportCallback* getDebugReportCallback();
106 
112  std::vector<PhysicalDevice*> getAvailablePhysicalDevices();
113 
119  PhysicalDevice* getPhysicalDevice();
120 
126  Device* getDevice();
127 
133  Swapchain* getSwapchain();
134 
140  uint32_t getSwapchainCount();
141 
147  uint32_t getSwapchainIndex();
148 
154  FramebufferVK* getSwapchainFramebuffer();
155 
161  CommandPool* getCommandPool();
162 
168  DescriptorPool* getDescriptorPool();
169 
175  Fence* getRenderFence();
176 
178  void setupDebugCallback();
179 
185  void pickPhysicalDevice(Surface* surface);
186 
188  void createLogicalDevice();
189 
196  void createSwapchain(Surface* surface, glm::ivec2 size);
197 
203  void createFramebuffers(RenderPass* renderPass);
204 
206  void createCommandPool();
207 
209  void createDescriptorPool();
210 
212  void createRenderFence();
213  };
214 }
215 
216 #endif /* VULKAN_CONTEXT_HPP */
This class wraps a Vulkan instance.
This class wraps a Vulkan descriptor pool.
This class wraps a Vulkan physical device and represents a graphics card.
This class contains all relevant Vulkan objects to setup a Vulkan application.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
This class wraps a Vulkan command pool.
This class wraps a Vulkan framebuffer.
Definition: framebuffer.hpp:44
This class wraps a Vulkan swapchain.
Definition: swapchain.hpp:51
This class wraps a Vulkan debug report callback.
This class wraps a Vulkan render pass.
Definition: render_pass.hpp:22
This class wraps a Vulkan fence.
This class wraps a Vulkan surface.
Definition: surface.hpp:25
This class wraps a Vulkan logical device.